From 4550423211063010a2fa482037d8233bb80e3773 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 07:18:08 -0700 Subject: radeon-gallium: Don't permit reading and writing a BO in one CS. This fixes some silent problems in current libdrm_radeon. surface_copy still locks up hard. --- src/gallium/drivers/r300/r300_cs.h | 5 +++-- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 82a3942248..2abf04d27e 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -93,8 +93,9 @@ } while (0) #define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \ - debug_printf("r300: writing relocation for buffer %p, offset %d\n", \ - bo, offset); \ + debug_printf("r300: writing relocation for buffer %p, offset %d, " \ + "domains (%d, %d, %d)\n", \ + bo, offset, rd, wd, flags); \ assert(bo); \ OUT_CS(offset); \ cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 65366e242c..995bf6aa22 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -69,6 +69,16 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) return TRUE; } + /* XXX should probably be its own function */ + for (i = 0; i < priv->bo_count; i++) { + if (sc[i].read_domains && sc[i].write_domain) { + /* Cute, cute. We need to flush first. */ + debug_printf("radeon: BO %p can't be read and written; " + "requesting flush.\n", sc[i].bo); + return TRUE; + } + } + /* Things are fine, we can proceed as normal. */ return FALSE; } @@ -109,9 +119,15 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, { struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; + int retval = 0; - radeon_cs_write_reloc(priv->cs, + retval = radeon_cs_write_reloc(priv->cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + + if (retval) { + debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", + pbuffer, rd, wd, flags); + } } static void radeon_r300_end_cs(struct r300_winsys* winsys, -- cgit v1.2.3 From 65946ef0813e00944763ae959698e281871ee642 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 11:46:26 -0700 Subject: r300-gallium: Make surface_copy work, and refactor buffer validation. --- src/gallium/drivers/r300/r300_emit.c | 13 ++++++--- src/gallium/drivers/r300/r300_surface.c | 50 +++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 0cb0507fc8..5e4b179505 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -452,8 +452,8 @@ void r300_emit_dirty_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_texture* tex; - int i; - int dirty_tex = 0; + int i, dirty_tex = 0; + boolean invalid = FALSE; if (!(r300->dirty_state)) { return; @@ -462,6 +462,7 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_update_derived_state(r300); /* XXX check size */ +validate: /* Color buffers... */ for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture; @@ -490,10 +491,14 @@ void r300_emit_dirty_state(struct r300_context* r300) } else { debug_printf("No VBO while emitting dirty state!\n"); } - if (r300->winsys->validate(r300->winsys)) { - /* XXX */ r300->context.flush(&r300->context, 0, NULL); + if (invalid) { + /* Well, hell. */ + exit(1); + } + invalid = TRUE; + goto validate; } if (r300->dirty_state & R300_NEW_BLEND) { diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index acb6192492..7711e8f569 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -32,13 +32,6 @@ static void r300_surface_setup(struct r300_context* r300, unsigned pixpitch = dest->stride / dest->tex.block.size; CS_LOCALS(r300); - /* Make sure our target BO is okay. */ - r300->winsys->add_buffer(r300->winsys, dest->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); - if (r300->winsys->validate(r300->winsys)) { - r300->context.flush(&r300->context, 0, NULL); - } - 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); @@ -106,6 +99,7 @@ static void r300_surface_fill(struct pipe_context* pipe, struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* tex = (struct r300_texture*)dest->texture; unsigned pixpitch = tex->stride / tex->tex.block.size; + boolean invalid = FALSE; CS_LOCALS(r300); a = (float)((color >> 24) & 0xff) / 255.0f; @@ -118,11 +112,25 @@ static void r300_surface_fill(struct pipe_context* pipe, /* Fallback? */ if (FALSE) { +fallback: debug_printf("r300: Falling back on surface clear..."); util_surface_fill(pipe, dest, x, y, w, h, color); return; } + /* Make sure our target BO is okay. */ +validate: + r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + r300->context.flush(&r300->context, 0, NULL); + if (invalid) { + goto fallback; + } + invalid = TRUE; + goto validate; + } + r300_surface_setup(r300, tex, x, y, w, h); /* Vertex shader setup */ @@ -216,6 +224,7 @@ static void r300_surface_copy(struct pipe_context* pipe, struct r300_texture* srctex = (struct r300_texture*)src->texture; struct r300_texture* desttex = (struct r300_texture*)dest->texture; unsigned pixpitch = srctex->stride / srctex->tex.block.size; + boolean invalid = FALSE; CS_LOCALS(r300); debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d)," @@ -225,21 +234,38 @@ static void r300_surface_copy(struct pipe_context* pipe, if ((srctex == desttex) && ((destx < srcx + w) || (srcx < destx + w)) && ((desty < srcy + h) || (srcy < desty + h))) { +fallback: debug_printf("r300: Falling back on surface_copy\n"); util_surface_copy(pipe, FALSE, dest, destx, desty, src, srcx, srcy, w, h); } - /* Add our source texture to the BO list before emitting anything. - * r300_surface_setup will flush if needed for us. */ + /* Add our target BOs to the list. */ +validate: r300->winsys->add_buffer(r300->winsys, srctex->buffer, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); + r300->winsys->add_buffer(r300->winsys, desttex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + r300->context.flush(&r300->context, 0, NULL); + if (invalid) { + goto fallback; + } + invalid = TRUE; + goto validate; + } r300_surface_setup(r300, desttex, destx, desty, w, h); + /* Setup the texture. */ r300_emit_sampler(r300, &r300_sampler_copy_state, 0); r300_emit_texture(r300, srctex, 0); - r300_flush_textures(r300); + + /* Flush and enable. */ + BEGIN_CS(4); + OUT_CS_REG(R300_TX_INVALTAGS, 0); + OUT_CS_REG(R300_TX_ENABLE, 0x1); + END_CS; /* Vertex shader setup */ if (caps->has_tcl) { @@ -263,7 +289,7 @@ static void r300_surface_copy(struct pipe_context* pipe, r300_emit_rs_block_state(r300, &r300_rs_block_copy_state); } - BEGIN_CS(28); + 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, @@ -287,7 +313,7 @@ static void r300_surface_copy(struct pipe_context* pipe, OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2); /* Vertex size. */ - OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8); + OUT_CS_REG(R300_VAP_VTX_SIZE, 0x4); /* Packet3 with our texcoords */ OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16); -- cgit v1.2.3 From b22b6f074381f3a0cfb9b6c3f45eaa533c1a0426 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 12:08:00 -0700 Subject: r300-gallium: Add missing R481 PCI ID. Per 74cb2aba on xf86-video-ati. --- src/gallium/drivers/r300/r300_chipset.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index 758f706c51..00fae8d26f 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -149,6 +149,7 @@ void r300_parse_chipset(struct r300_capabilities* caps) caps->num_vert_fpus = 6; break; + case 0x4B48: case 0x4B49: case 0x4B4A: case 0x4B4B: -- cgit v1.2.3 From 9e8de1b91136d056ee29e1a448196b5648ac2b3f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 12:22:24 -0700 Subject: r300-gallium: Make surface_copy actually load the texture in shader. --- src/gallium/drivers/r300/r300_reg.h | 1 + src/gallium/drivers/r300/r300_state_shader.h | 2 +- src/gallium/drivers/r300/r300_surface.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 660816e1da..920584a59e 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -3040,6 +3040,7 @@ enum { # define R500_INST_RGB_WMASK_R (1 << 11) # define R500_INST_RGB_WMASK_G (1 << 12) # define R500_INST_RGB_WMASK_B (1 << 13) +# define R500_INST_RGB_WMASK_RGB (7 << 11) # define R500_INST_ALPHA_WMASK (1 << 14) # define R500_INST_RGB_OMASK_R (1 << 15) # define R500_INST_RGB_OMASK_G (1 << 16) diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 06260e61fe..b6087404ce 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -181,7 +181,7 @@ static struct r500_fragment_shader r500_texture_fragment_shader = { .instruction_count = 2, .instructions[0].inst0 = R500_INST_TYPE_TEX | R500_INST_TEX_SEM_WAIT | - R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | + R500_INST_RGB_WMASK_RGB | R500_INST_ALPHA_WMASK | R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, .instructions[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD | R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED, diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index 894def07aa..9a4c39f58b 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -101,7 +101,7 @@ static struct r300_rs_block r300_rs_block_copy_state = { 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(6), + .inst_count = R300_RS_TX_OFFSET(0), }; static struct r300_rs_block r500_rs_block_copy_state = { @@ -111,7 +111,7 @@ static struct r300_rs_block r500_rs_block_copy_state = { 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(6), + .inst_count = R300_RS_TX_OFFSET(0), }; static struct r300_sampler_state r300_sampler_copy_state = { -- cgit v1.2.3 From 0ba7f762339cbc8be31fe98421b0c9b44c7402fa Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 13:21:17 -0700 Subject: radeon-gallium: Add surface_buffer_create callback. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index a15487352b..0d0fdc5bd8 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -93,6 +93,29 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, return &radeon_buffer->base; } +static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws, + unsigned width, + unsigned height, + enum pipe_format format, + unsigned usage, + unsigned *stride) +{ + struct pipe_format_block block; + unsigned nblocksx, nblocksy, size; + + pf_get_block(format, &block); + + nblocksx = pf_get_nblocksx(&block, width); + nblocksy = pf_get_nblocksy(&block, height); + + /* Radeons enjoy things in multiples of 32. */ + /* XXX this can be 32 when POT */ + *stride = (nblocksx * block.size + 63) & ~63; + size = *stride * nblocksy; + + return radeon_buffer_create(ws, 64, usage, size); +} + static void radeon_buffer_del(struct pipe_buffer *buffer) { struct radeon_pipe_buffer *radeon_buffer = @@ -180,10 +203,11 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer; radeon_ws->base.buffer_create = radeon_buffer_create; - radeon_ws->base.buffer_destroy = radeon_buffer_del; radeon_ws->base.user_buffer_create = radeon_buffer_user_create; + radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create; radeon_ws->base.buffer_map = radeon_buffer_map; radeon_ws->base.buffer_unmap = radeon_buffer_unmap; + radeon_ws->base.buffer_destroy = radeon_buffer_del; radeon_ws->base.fence_reference = radeon_fence_reference; radeon_ws->base.fence_signalled = radeon_fence_signalled; -- cgit v1.2.3 From 364a4a829341b3691b4d1e559d5cc3c178147b97 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 14:17:27 -0700 Subject: r300-gallium: fs: Remove cruft from way back when. --- src/gallium/drivers/r300/r300_state_shader.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index ed99c76c15..a56b507eef 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -22,24 +22,6 @@ #include "r300_state_shader.h" -static void r300_copy_passthrough_shader(struct r300_fragment_shader* fs) -{ - struct r300_fragment_shader* pt = &r300_passthrough_fragment_shader; - fs->shader.stack_size = pt->shader.stack_size; - fs->alu_instruction_count = pt->alu_instruction_count; - fs->tex_instruction_count = pt->tex_instruction_count; - fs->indirections = pt->indirections; - fs->instructions[0] = pt->instructions[0]; -} - -static void r500_copy_passthrough_shader(struct r500_fragment_shader* fs) -{ - struct r500_fragment_shader* pt = &r500_passthrough_fragment_shader; - fs->shader.stack_size = pt->shader.stack_size; - fs->instruction_count = pt->instruction_count; - fs->instructions[0] = pt->instructions[0]; -} - static void r300_fs_declare(struct r300_fs_asm* assembler, struct tgsi_full_declaration* decl) { -- cgit v1.2.3 From 4151c0ea91212ac5ec73fa6d1936df9254978672 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 14:38:22 -0700 Subject: r300-gallium: Raise constantbuf limits. Still not correct, but really I don't care. --- src/gallium/drivers/r300/r300_context.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 58f1fa0e2e..d1cf75032c 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -141,11 +141,11 @@ struct r300_viewport_state { struct r300_constant_buffer { /* Buffer of constants */ /* XXX first number should be raised */ - float constants[8][4]; + float constants[32][4]; /* Number of user-defined constants */ - int user_count; + unsigned user_count; /* Total number of constants */ - int count; + unsigned count; }; struct r3xx_fragment_shader { -- cgit v1.2.3 From d04c85d01bf37d480df8b9a21d9a79194d2e67f3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 14:55:03 -0700 Subject: r300-gallium: Another constantbuf shader recompile test. Less briefly... Shaders need to be recompiled if their constantbuf offsets have changed. However, since we only change them from shaders if immediates need to be emitted, we shouldn't bother if the shader doesn't use immediates. --- src/gallium/drivers/r300/r300_context.h | 8 ++++++++ src/gallium/drivers/r300/r300_state.c | 6 ++++-- src/gallium/drivers/r300/r300_state_shader.c | 1 + src/gallium/drivers/r300/r300_state_tcl.c | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index d1cf75032c..a9dd041e08 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -158,6 +158,10 @@ struct r3xx_fragment_shader { /* Pixel stack size */ int stack_size; + + /* Are there immediates in this shader? + * If not, we can heavily optimize recompilation. */ + boolean uses_imms; }; struct r300_fragment_shader { @@ -248,6 +252,10 @@ struct r300_vertex_shader { /* Has this shader been translated yet? */ boolean translated; + /* Are there immediates in this shader? + * If not, we can heavily optimize recompilation. */ + boolean uses_imms; + /* Number of used instructions */ int instruction_count; diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 4e65fbbabe..0461ffd681 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -151,10 +151,12 @@ static void /* If the number of constants have changed, invalidate the shader. */ if (r300->shader_constants[shader].user_count != i) { - if (shader == PIPE_SHADER_FRAGMENT && r300->fs) { + if (shader == PIPE_SHADER_FRAGMENT && r300->fs && + r300->fs->uses_imms) { r300->fs->translated = FALSE; r300_translate_fragment_shader(r300, r300->fs); - } else if (shader == PIPE_SHADER_VERTEX && r300->vs) { + } else if (shader == PIPE_SHADER_VERTEX && r300->vs && + r300->vs->uses_imms) { r300->vs->translated = FALSE; r300_translate_vertex_shader(r300, r300->vs); } diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index a56b507eef..f27d7233d8 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -652,6 +652,7 @@ void r300_translate_fragment_shader(struct r300_context* r300, assembler->tex_count + assembler->color_count); consts->count = consts->user_count + assembler->imm_count; + fs->uses_imms = assembler->imm_count; debug_printf("r300: fs: %d total constants, " "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index fdbcbf3db8..32e61bc1d7 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -386,6 +386,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, assembler->tex_count + assembler->color_count); consts->count = consts->user_count + assembler->imm_count; + vs->uses_imms = assembler->imm_count; debug_printf("r300: vs: %d total constants, " "%d from user and %d from immediates\n", consts->count, consts->user_count, assembler->imm_count); -- cgit v1.2.3 From d67fb5ea1d93db3f64720994017c312a04867eea Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 15:02:45 -0700 Subject: r300-gallium: Prevent assert when fogcoords are present. Seems like this file is the source of all bad logic. (Pun intended.) --- src/gallium/drivers/r300/r300_state_derived.c | 18 +++++++++++++----- src/gallium/drivers/r300/r300_state_shader.c | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index caa5f3b543..7ae339cf97 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -64,6 +64,7 @@ static void r300_vs_tab_routes(struct r300_context* r300, break; case TGSI_SEMANTIC_FOG: fog = TRUE; + /* Fall through */ case TGSI_SEMANTIC_GENERIC: texs++; break; @@ -103,6 +104,9 @@ static void r300_vs_tab_routes(struct r300_context* r300, } } + /* XXX magic */ + assert(texs <= 8); + /* Do the actual vertex_info setup. * * vertex_info has four uints of hardware-specific data in it. @@ -140,17 +144,21 @@ static void r300_vs_tab_routes(struct r300_context* r300, vinfo->hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i); } - for (i = 0; i < texs; i++) { + /* Init i right here, increment it if fog is enabled. + * This gets around a double-increment problem. */ + i = 0; + + if (fog) { + i++; draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, - draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i)); + draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0)); vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i); vinfo->hwfmt[3] |= (4 << (3 * i)); } - if (fog) { - i++; + for (i; i < texs; i++) { draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, - draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0)); + draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i)); vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i); vinfo->hwfmt[3] |= (4 << (3 * i)); } diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index f27d7233d8..d087771c3e 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -31,6 +31,7 @@ static void r300_fs_declare(struct r300_fs_asm* assembler, case TGSI_SEMANTIC_COLOR: assembler->color_count++; break; + case TGSI_SEMANTIC_FOG: case TGSI_SEMANTIC_GENERIC: assembler->tex_count++; break; -- cgit v1.2.3 From f1f0893eba6a3785d309f60ce4027980237fb8a6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 16:53:45 -0700 Subject: r300-gallium: r500-fs: Combine function. --- src/gallium/drivers/r300/r300_state_shader.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index d087771c3e..8a3e380eec 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -306,9 +306,12 @@ static INLINE void r300_emit_maths(struct r300_fragment_shader* fs, } /* Setup an ALU operation. */ -static INLINE void r500_emit_alu(struct r500_fragment_shader* fs, - struct r300_fs_asm* assembler, - struct tgsi_full_dst_register* dst) +static INLINE void r500_emit_maths(struct r500_fragment_shader* fs, + struct r300_fs_asm* assembler, + struct tgsi_full_src_register* src, + struct tgsi_full_dst_register* dst, + unsigned op, + unsigned count) { int i = fs->instruction_count; @@ -331,18 +334,6 @@ static INLINE void r500_emit_alu(struct r500_fragment_shader* fs, R500_ALPHA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister)); fs->instructions[i].inst5 = R500_ALU_RGBA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister)); -} - -static INLINE void r500_emit_maths(struct r500_fragment_shader* fs, - struct r300_fs_asm* assembler, - struct tgsi_full_src_register* src, - struct tgsi_full_dst_register* dst, - unsigned op, - unsigned count) -{ - int i = fs->instruction_count; - - r500_emit_alu(fs, assembler, dst); switch (count) { case 3: -- cgit v1.2.3 From cfd241e8a68bc04f0f82960eae9ff1ec01384b67 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 21:52:11 -0700 Subject: r300-gallium: r500-fs: LRP. Goddammit. This cannot be the "easy way." :C --- src/gallium/drivers/r300/r300_state_shader.c | 36 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 8a3e380eec..cf9eeb4201 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -355,8 +355,8 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs, R500_ALU_RGB_SEL_B_SRC1 | R500_SWIZ_RGB_B(r500_rgb_swiz(&src[1])); fs->instructions[i].inst4 |= - R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1])) | - R500_ALPHA_SEL_B_SRC1; + R500_ALPHA_SEL_B_SRC1 | + R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1])); case 1: case 0: default: @@ -368,8 +368,8 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs, R500_ALU_RGB_SEL_A_SRC0 | R500_SWIZ_RGB_A(r500_rgb_swiz(&src[0])); fs->instructions[i].inst4 |= - R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0])) | - R500_ALPHA_SEL_A_SRC0; + R500_ALPHA_SEL_A_SRC0 | + R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0])); break; } @@ -539,6 +539,34 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3); break; + /* The compound and hybrid insts. */ + case TGSI_OPCODE_LRP: + /* LRP DST A, B, C -> MAD TMP -A, C, C; MAD DST A, B, TMP */ + inst->FullSrcRegisters[3] = inst->FullSrcRegisters[1]; + inst->FullSrcRegisters[1] = inst->FullSrcRegisters[2]; + inst->FullSrcRegisters[0].SrcRegister.Negate = + !(inst->FullSrcRegisters[0].SrcRegister.Negate); + inst->FullDstRegisters[1] = inst->FullDstRegisters[0]; + inst->FullDstRegisters[0].DstRegister.Index = + assembler->temp_count; + inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY; + r500_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3); + inst->FullSrcRegisters[2].SrcRegister.Index = + assembler->temp_count; + inst->FullSrcRegisters[2].SrcRegister.File = TGSI_FILE_TEMPORARY; + inst->FullSrcRegisters[2].SrcRegister.SwizzleX = TGSI_SWIZZLE_X; + inst->FullSrcRegisters[2].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y; + inst->FullSrcRegisters[2].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z; + inst->FullSrcRegisters[2].SrcRegister.SwizzleW = TGSI_SWIZZLE_W; + inst->FullSrcRegisters[1] = inst->FullSrcRegisters[3]; + inst->FullSrcRegisters[0].SrcRegister.Negate = + !(inst->FullSrcRegisters[0].SrcRegister.Negate); + inst->FullDstRegisters[0] = inst->FullDstRegisters[1]; + r500_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3); + break; + /* The texture instruction set. */ case TGSI_OPCODE_KIL: case TGSI_OPCODE_TEX: -- cgit v1.2.3 From 3af0952bc9bade8d5a5c60349c045b28762f8815 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 23:22:16 -0700 Subject: r300-gallium: r500-fs: POW. I feel so unclean. --- src/gallium/drivers/r300/r300_state_shader.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index cf9eeb4201..cc7f6a7c4b 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -566,6 +566,32 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs, r500_emit_maths(fs, assembler, inst->FullSrcRegisters, &inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3); break; + case TGSI_OPCODE_POW: + /* POW DST A, B -> LG2 TMP A; MUL TMP TMP, B; EX2 DST TMP */ + inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW = + inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX; + inst->FullSrcRegisters[0].SrcRegister.SwizzleW = + inst->FullSrcRegisters[0].SrcRegister.SwizzleX; + inst->FullDstRegisters[1] = inst->FullDstRegisters[0]; + inst->FullDstRegisters[0].DstRegister.Index = + assembler->temp_count; + inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY; + r500_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], TGSI_OPCODE_LG2, 1); + inst->FullSrcRegisters[0].SrcRegister.Index = + assembler->temp_count; + inst->FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY; + inst->FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X; + inst->FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y; + inst->FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z; + inst->FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_W; + inst->FullSrcRegisters[2] = r500_constant_zero; + r500_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], TGSI_OPCODE_MUL, 3); + inst->FullDstRegisters[0] = inst->FullDstRegisters[1]; + r500_emit_maths(fs, assembler, inst->FullSrcRegisters, + &inst->FullDstRegisters[0], TGSI_OPCODE_EX2, 1); + break; /* The texture instruction set. */ case TGSI_OPCODE_KIL: @@ -595,7 +621,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs, static void r300_fs_finalize(struct r3xx_fragment_shader* fs, struct r300_fs_asm* assembler) { - fs->stack_size = assembler->temp_count + assembler->temp_offset; + fs->stack_size = assembler->temp_count + assembler->temp_offset + 1; } static void r500_fs_finalize(struct r500_fragment_shader* fs, -- cgit v1.2.3 From b4824520ecf453cd8de90e57e839cb11a698d9c0 Mon Sep 17 00:00:00 2001 From: Jonathan Adamczewski Date: Thu, 21 May 2009 08:18:03 -0600 Subject: cell: unroll inner loop of spu_render.c:cmd_render() It was taking approximately 50 cycles to extract the vertex indices, calculate the vertex_header pointers and call tri_draw() for each three vertices - . Unrolled, it takes less than 100 cycles to extract, unpack, calculate pointers and call tri_draw() eight times. It does have a nasty jump-tabled switch. I'm sure that there's a better way... Code size of spu_render.o gets larger due to the extra constants and work in the inner loop, there are extra stack saves and loads because there are more registers in use, and an assert. spu_tri.o gets a little smaller. --- src/gallium/drivers/cell/spu/spu_render.c | 79 +++++++++++++++++++++++++++---- src/gallium/drivers/cell/spu/spu_tri.c | 40 +++++++--------- src/gallium/drivers/cell/spu/spu_tri.h | 2 +- 3 files changed, 89 insertions(+), 32 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c index 7c225e2f27..5ffb7073ab 100644 --- a/src/gallium/drivers/cell/spu/spu_render.c +++ b/src/gallium/drivers/cell/spu/spu_render.c @@ -32,6 +32,7 @@ #include "spu_main.h" #include "spu_render.h" +#include "spu_shuffle.h" #include "spu_tri.h" #include "spu_tile.h" #include "cell/common.h" @@ -267,15 +268,75 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr) uint drawn = 0; - /* loop over tris */ - for (j = 0; j < render->num_indexes; j += 3) { - const float *v0, *v1, *v2; - - v0 = (const float *) (vertices + indexes[j+0] * vertex_size); - v1 = (const float *) (vertices + indexes[j+1] * vertex_size); - v2 = (const float *) (vertices + indexes[j+2] * vertex_size); - - drawn += tri_draw(v0, v1, v2, tx, ty); + const qword vertex_sizes = (qword)spu_splats(vertex_size); + const qword verticess = (qword)spu_splats((uint)vertices); + + ASSERT_ALIGN16(&indexes[0]); + + const uint num_indexes = render->num_indexes; + + /* loop over tris + * &indexes[0] will be 16 byte aligned. This loop is heavily unrolled + * avoiding variable rotates when extracting vertex indices. + */ + for (j = 0; j < num_indexes; j += 24) { + /* Load three vectors, containing 24 ushort indices */ + const qword* lower_qword = (qword*)&indexes[j]; + const qword indices0 = lower_qword[0]; + const qword indices1 = lower_qword[1]; + const qword indices2 = lower_qword[2]; + + /* stores three indices for each tri n in slots 0, 1 and 2 of vsn */ + /* Straightforward rotates for these */ + qword vs0 = indices0; + qword vs1 = si_shlqbyi(indices0, 6); + qword vs3 = si_shlqbyi(indices1, 2); + qword vs4 = si_shlqbyi(indices1, 8); + qword vs6 = si_shlqbyi(indices2, 4); + qword vs7 = si_shlqbyi(indices2, 10); + + /* For tri 2 and 5, the three indices are split across two machine + * words - rotate and combine */ + const qword tmp2a = si_shlqbyi(indices0, 12); + const qword tmp2b = si_rotqmbyi(indices1, 12|16); + qword vs2 = si_selb(tmp2a, tmp2b, si_fsmh(si_from_uint(0x20))); + + const qword tmp5a = si_shlqbyi(indices1, 14); + const qword tmp5b = si_rotqmbyi(indices2, 14|16); + qword vs5 = si_selb(tmp5a, tmp5b, si_fsmh(si_from_uint(0x60))); + + /* unpack indices from halfword slots to word slots */ + vs0 = si_shufb(vs0, vs0, SHUFB8(0,A,0,B,0,C,0,0)); + vs1 = si_shufb(vs1, vs1, SHUFB8(0,A,0,B,0,C,0,0)); + vs2 = si_shufb(vs2, vs2, SHUFB8(0,A,0,B,0,C,0,0)); + vs3 = si_shufb(vs3, vs3, SHUFB8(0,A,0,B,0,C,0,0)); + vs4 = si_shufb(vs4, vs4, SHUFB8(0,A,0,B,0,C,0,0)); + vs5 = si_shufb(vs5, vs5, SHUFB8(0,A,0,B,0,C,0,0)); + vs6 = si_shufb(vs6, vs6, SHUFB8(0,A,0,B,0,C,0,0)); + vs7 = si_shufb(vs7, vs7, SHUFB8(0,A,0,B,0,C,0,0)); + + /* Calculate address of vertex in vertices[] */ + vs0 = si_mpya(vs0, vertex_sizes, verticess); + vs1 = si_mpya(vs1, vertex_sizes, verticess); + vs2 = si_mpya(vs2, vertex_sizes, verticess); + vs3 = si_mpya(vs3, vertex_sizes, verticess); + vs4 = si_mpya(vs4, vertex_sizes, verticess); + vs5 = si_mpya(vs5, vertex_sizes, verticess); + vs6 = si_mpya(vs6, vertex_sizes, verticess); + vs7 = si_mpya(vs7, vertex_sizes, verticess); + + /* Select the appropriate call based on the number of vertices + * remaining */ + switch(num_indexes - j) { + default: drawn += tri_draw(vs7, tx, ty); + case 21: drawn += tri_draw(vs6, tx, ty); + case 18: drawn += tri_draw(vs5, tx, ty); + case 15: drawn += tri_draw(vs4, tx, ty); + case 12: drawn += tri_draw(vs3, tx, ty); + case 9: drawn += tri_draw(vs2, tx, ty); + case 6: drawn += tri_draw(vs1, tx, ty); + case 3: drawn += tri_draw(vs0, tx, ty); + } } //printf("SPU %u: drew %u of %u\n", spu.init.id, drawn, render->num_indexes/3); diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c index d727268475..d9f5a46672 100644 --- a/src/gallium/drivers/cell/spu/spu_tri.c +++ b/src/gallium/drivers/cell/spu/spu_tri.c @@ -440,9 +440,7 @@ print_vertex(const struct vertex_header *v) * \return FALSE if tri is totally outside tile, TRUE otherwise */ static boolean -setup_sort_vertices(const struct vertex_header *v0, - const struct vertex_header *v1, - const struct vertex_header *v2) +setup_sort_vertices(const qword vs) { float area, sign; @@ -459,23 +457,23 @@ setup_sort_vertices(const struct vertex_header *v0, { /* A table of shuffle patterns for putting vertex_header pointers into correct order. Quite magical. */ - const vec_uchar16 sort_order_patterns[] = { - SHUFFLE4(A,B,C,C), - SHUFFLE4(C,A,B,C), - SHUFFLE4(A,C,B,C), - SHUFFLE4(B,C,A,C), - SHUFFLE4(B,A,C,C), - SHUFFLE4(C,B,A,C) }; - - /* The vertex_header pointers, packed for easy shuffling later */ - const vec_uint4 vs = {(unsigned)v0, (unsigned)v1, (unsigned)v2}; + const qword sort_order_patterns[] = { + SHUFB4(A,B,C,C), + SHUFB4(C,A,B,C), + SHUFB4(A,C,B,C), + SHUFB4(B,C,A,C), + SHUFB4(B,A,C,C), + SHUFB4(C,B,A,C) }; /* Collate y values into two vectors for comparison. Using only one shuffle constant! ;) */ - const vec_float4 y_02_ = spu_shuffle(v0->data[0], v2->data[0], SHUFFLE4(0,B,b,C)); - const vec_float4 y_10_ = spu_shuffle(v1->data[0], v0->data[0], SHUFFLE4(0,B,b,C)); - const vec_float4 y_012 = spu_shuffle(y_02_, v1->data[0], SHUFFLE4(0,B,b,C)); - const vec_float4 y_120 = spu_shuffle(y_10_, v2->data[0], SHUFFLE4(0,B,b,C)); + const vector float f0 = ((const struct vertex_header*)si_to_ptr(vs))->data[0]; + const vector float f1 = ((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 4)))->data[0]; + const vector float f2 = ((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 8)))->data[0]; + const vec_float4 y_02_ = spu_shuffle(f0, f2, SHUFFLE4(0,B,b,C)); + const vec_float4 y_10_ = spu_shuffle(f1, f0, SHUFFLE4(0,B,b,C)); + const vec_float4 y_012 = spu_shuffle(y_02_, f1, SHUFFLE4(0,B,b,C)); + const vec_float4 y_120 = spu_shuffle(y_10_, f2, SHUFFLE4(0,B,b,C)); /* Perform comparison: {y0,y1,y2} > {y1,y2,y0} */ const vec_uint4 compare = spu_cmpgt(y_012, y_120); @@ -485,7 +483,7 @@ setup_sort_vertices(const struct vertex_header *v0, const unsigned int index = spu_extract(gather, 0) - 1; /* Load the appropriate pattern and construct the desired vector. */ - setup.vertex_headers = (qword)spu_shuffle(vs, vs, sort_order_patterns[index]); + setup.vertex_headers = si_shufb(vs, vs, sort_order_patterns[index]); /* Using the result of the comparison, set sign. Very magical. */ @@ -761,7 +759,7 @@ subtriangle(struct edge *eleft, struct edge *eright, unsigned lines) * The tile data should have already been fetched. */ boolean -tri_draw(const float *v0, const float *v1, const float *v2, +tri_draw(const qword vs, uint tx, uint ty) { setup.tx = tx; @@ -773,9 +771,7 @@ tri_draw(const float *v0, const float *v1, const float *v2, setup.cliprect_maxx = (tx + 1) * TILE_SIZE; setup.cliprect_maxy = (ty + 1) * TILE_SIZE; - if (!setup_sort_vertices((struct vertex_header *) v0, - (struct vertex_header *) v1, - (struct vertex_header *) v2)) { + if(!setup_sort_vertices(vs)) { return FALSE; /* totally clipped */ } diff --git a/src/gallium/drivers/cell/spu/spu_tri.h b/src/gallium/drivers/cell/spu/spu_tri.h index aa694dd7c9..82e3b19ad7 100644 --- a/src/gallium/drivers/cell/spu/spu_tri.h +++ b/src/gallium/drivers/cell/spu/spu_tri.h @@ -31,7 +31,7 @@ extern boolean -tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty); +tri_draw(const qword vs, uint tx, uint ty); #endif /* SPU_TRI_H */ -- cgit v1.2.3 From 2c007517b541ab470ad251365bd95c83002dfb16 Mon Sep 17 00:00:00 2001 From: Jonathan Adamczewski Date: Thu, 21 May 2009 08:19:00 -0600 Subject: cell: perform triangle cull a little earlier In spu_tri.c:setup_sort_vertices() triangles are culled after the vertices are sorted. This patch moves the check a little earlier and performs the actual check a little faster through intrinsics and a little trickery. Reduced code size and less work is done before a triangle is deemed OK to skip. --- src/gallium/drivers/cell/spu/spu_tri.c | 105 +++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 31 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c index d9f5a46672..58be001be4 100644 --- a/src/gallium/drivers/cell/spu/spu_tri.c +++ b/src/gallium/drivers/cell/spu/spu_tri.c @@ -133,7 +133,15 @@ struct setup_stage { uint tx, ty; /**< position of current tile (x, y) */ - int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy; + union { + struct { + int cliprect_minx; + int cliprect_miny; + int cliprect_maxx; + int cliprect_maxy; + }; + qword cliprect; + }; struct interp_coef coef[PIPE_MAX_SHADER_INPUTS]; @@ -432,6 +440,41 @@ print_vertex(const struct vertex_header *v) } #endif +/* Returns the minimum of each slot of two vec_float4s as qwords. + * i.e. return[n] = min(q0[n],q1[n]); + */ +static qword +minfq(qword q0, qword q1) +{ + const qword q0q1m = si_fcgt(q0, q1); + return si_selb(q0, q1, q0q1m); +} + +/* Returns the minimum of each slot of three vec_float4s as qwords. + * i.e. return[n] = min(q0[n],q1[n],q2[n]); + */ +static qword +min3fq(qword q0, qword q1, qword q2) +{ + return minfq(minfq(q0, q1), q2); +} + +/* Returns the maximum of each slot of two vec_float4s as qwords. + * i.e. return[n] = min(q0[n],q1[n],q2[n]); + */ +static qword +maxfq(qword q0, qword q1) { + const qword q0q1m = si_fcgt(q0, q1); + return si_selb(q1, q0, q0q1m); +} + +/* Returns the maximum of each slot of three vec_float4s as qwords. + * i.e. return[n] = min(q0[n],q1[n],q2[n]); + */ +static qword +max3fq(qword q0, qword q1, qword q2) { + return maxfq(maxfq(q0, q1), q2); +} /** * Sort vertices from top to bottom. @@ -453,8 +496,25 @@ setup_sort_vertices(const qword vs) } #endif - /* determine bottom to top order of vertices */ { + /* Load the float values for various processing... */ + const qword f0 = (qword)(((const struct vertex_header*)si_to_ptr(vs))->data[0]); + const qword f1 = (qword)(((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 4)))->data[0]); + const qword f2 = (qword)(((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 8)))->data[0]); + + /* Check if triangle is completely outside the tile bounds + * Find the min and max x and y positions of the three poits */ + const qword minf = min3fq(f0, f1, f2); + const qword maxf = max3fq(f0, f1, f2); + + /* Compare min and max against cliprect vals */ + const qword maxsmins = si_shufb(maxf, minf, SHUFB4(A,B,a,b)); + const qword outside = si_fcgt(maxsmins, si_csflt(setup.cliprect, 0)); + + /* Use a little magic to work out of the tri is visible or not */ + if(si_to_uint(si_xori(si_gb(outside), 0xc))) return FALSE; + + /* determine bottom to top order of vertices */ /* A table of shuffle patterns for putting vertex_header pointers into correct order. Quite magical. */ const qword sort_order_patterns[] = { @@ -467,43 +527,26 @@ setup_sort_vertices(const qword vs) /* Collate y values into two vectors for comparison. Using only one shuffle constant! ;) */ - const vector float f0 = ((const struct vertex_header*)si_to_ptr(vs))->data[0]; - const vector float f1 = ((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 4)))->data[0]; - const vector float f2 = ((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 8)))->data[0]; - const vec_float4 y_02_ = spu_shuffle(f0, f2, SHUFFLE4(0,B,b,C)); - const vec_float4 y_10_ = spu_shuffle(f1, f0, SHUFFLE4(0,B,b,C)); - const vec_float4 y_012 = spu_shuffle(y_02_, f1, SHUFFLE4(0,B,b,C)); - const vec_float4 y_120 = spu_shuffle(y_10_, f2, SHUFFLE4(0,B,b,C)); + const qword y_02_ = si_shufb(f0, f2, SHUFB4(0,B,b,C)); + const qword y_10_ = si_shufb(f1, f0, SHUFB4(0,B,b,C)); + const qword y_012 = si_shufb(y_02_, f1, SHUFB4(0,B,b,C)); + const qword y_120 = si_shufb(y_10_, f2, SHUFB4(0,B,b,C)); /* Perform comparison: {y0,y1,y2} > {y1,y2,y0} */ - const vec_uint4 compare = spu_cmpgt(y_012, y_120); + const qword compare = si_fcgt(y_012, y_120); /* Compress the result of the comparison into 4 bits */ - const vec_uint4 gather = spu_gather(compare); + const qword gather = si_gb(compare); /* Subtract one to attain the index into the LUT. Magical. */ - const unsigned int index = spu_extract(gather, 0) - 1; + const unsigned int index = si_to_uint(gather) - 1; /* Load the appropriate pattern and construct the desired vector. */ setup.vertex_headers = si_shufb(vs, vs, sort_order_patterns[index]); /* Using the result of the comparison, set sign. Very magical. */ - sign = ((si_to_uint(si_cntb((qword)gather)) == 2) ? 1.0f : -1.0f); + sign = ((si_to_uint(si_cntb(gather)) == 2) ? 1.0f : -1.0f); } - /* Check if triangle is completely outside the tile bounds */ - if (spu_extract(setup.vmin->data[0], 1) > setup.cliprect_maxy) - return FALSE; - if (spu_extract(setup.vmax->data[0], 1) < setup.cliprect_miny) - return FALSE; - if (spu_extract(setup.vmin->data[0], 0) < setup.cliprect_minx && - spu_extract(setup.vmid->data[0], 0) < setup.cliprect_minx && - spu_extract(setup.vmax->data[0], 0) < setup.cliprect_minx) - return FALSE; - if (spu_extract(setup.vmin->data[0], 0) > setup.cliprect_maxx && - spu_extract(setup.vmid->data[0], 0) > setup.cliprect_maxx && - spu_extract(setup.vmax->data[0], 0) > setup.cliprect_maxx) - return FALSE; - setup.ebot.ds = spu_sub(setup.vmid->data[0], setup.vmin->data[0]); setup.emaj.ds = spu_sub(setup.vmax->data[0], setup.vmin->data[0]); setup.etop.ds = spu_sub(setup.vmax->data[0], setup.vmid->data[0]); @@ -766,10 +809,10 @@ tri_draw(const qword vs, setup.ty = ty; /* set clipping bounds to tile bounds */ - setup.cliprect_minx = tx * TILE_SIZE; - setup.cliprect_miny = ty * TILE_SIZE; - setup.cliprect_maxx = (tx + 1) * TILE_SIZE; - setup.cliprect_maxy = (ty + 1) * TILE_SIZE; + const qword clipbase = (qword)((vec_uint4){tx, ty}); + const qword clipmin = si_mpyui(clipbase, TILE_SIZE); + const qword clipmax = si_ai(clipmin, TILE_SIZE); + setup.cliprect = si_shufb(clipmin, clipmax, SHUFB4(A,B,a,b)); if(!setup_sort_vertices(vs)) { return FALSE; /* totally clipped */ -- cgit v1.2.3 From 5d75124db480b37977c353511b4e228905b7cc95 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 May 2009 19:27:31 -0600 Subject: softpipe: fix flat shading provoking vertex for PIPE_PRIM_POLYGON Use the first vertex, not the last. --- src/gallium/drivers/softpipe/sp_context.h | 1 + src/gallium/drivers/softpipe/sp_draw_arrays.c | 1 + src/gallium/drivers/softpipe/sp_setup.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index b89a7292e5..2f90d538a5 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -107,6 +107,7 @@ struct softpipe_context { /** Which vertex shader output slot contains point size */ int psize_slot; + unsigned api_prim; /**< current prim type being drawn: PIPE_PRIM_x */ unsigned reduced_api_prim; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */ /** Derived from scissor and surface bounds: */ diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index f117096bf7..1460bc4b4b 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -129,6 +129,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe, struct draw_context *draw = sp->draw; unsigned i; + sp->api_prim = mode; sp->reduced_api_prim = reduced_prim[mode]; if (sp->dirty) diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index accc692b66..c4dd61e41e 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -512,7 +512,10 @@ static boolean setup_sort_vertices( struct setup_context *setup, const float (*v1)[4], const float (*v2)[4] ) { - setup->vprovoke = v2; + if (setup->softpipe->api_prim == PIPE_PRIM_POLYGON) + setup->vprovoke = v0; + else + setup->vprovoke = v2; /* determine bottom to top order of vertices */ { -- cgit v1.2.3 From 31deacb8d38e2090dc4ba3ee4f6587792860e8c9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 May 2009 19:30:07 -0600 Subject: softpipe: include sp_winsys.h to silence warning (unprototyped function) --- src/gallium/drivers/softpipe/sp_texture.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 9e19745889..7a533dad9f 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -42,6 +42,7 @@ #include "sp_texture.h" #include "sp_tile_cache.h" #include "sp_screen.h" +#include "sp_winsys.h" /* Simple, maximally packed layout. -- cgit v1.2.3 From b86067c61072ef0e6804e7cf0f19a7ea43fc6aec Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 May 2009 19:36:59 -0600 Subject: softpipe: comments --- src/gallium/drivers/softpipe/sp_setup.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index c4dd61e41e..4f0baa3fd4 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -504,6 +504,8 @@ static void print_vertex(const struct setup_context *setup, #endif /** + * Sort the vertices from top to bottom order, setting up the triangle + * edge fields (ebot, emaj, etop). * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise */ static boolean setup_sort_vertices( struct setup_context *setup, -- cgit v1.2.3 From 713b636a0e0356266b714548886b66864b830fff Mon Sep 17 00:00:00 2001 From: Mike Kaplinksiy Date: Thu, 28 May 2009 01:20:37 -0400 Subject: draw: Fix assertion failure at fetch_emit_prepare --- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 6b7d02a19b..e7fe6b3b76 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -130,6 +130,10 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, unsigned output_format; switch (vinfo->attrib[i].emit) { + case EMIT_4UB: + output_format = PIPE_FORMAT_R8G8B8A8_UNORM; + emit_sz = 4 * sizeof(unsigned char); + break; case EMIT_4F: output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; emit_sz = 4 * sizeof(float); @@ -153,6 +157,8 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, output_format = PIPE_FORMAT_R32_FLOAT; emit_sz = 1 * sizeof(float); break; + case EMIT_OMIT: + continue; default: assert(0); output_format = PIPE_FORMAT_NONE; -- cgit v1.2.3 From 65e3fb7b46cc9fc02ad12fe41e0c023c65ffe1e8 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 28 May 2009 10:25:44 +1000 Subject: nouveau: explicitly request mappable buffers for the moment --- src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c index 9e03a9f5db..2dca8cd3a9 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c @@ -74,6 +74,7 @@ nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment, nvbuf->base.size = size; flags = nouveau_flags_from_usage(ws, usage); + flags |= NOUVEAU_BO_MAP; if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) { FREE(nvbuf); return NULL; -- cgit v1.2.3 From 9417582f39788476e1039df3f1bdf681686fb7b4 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 12:21:27 +0200 Subject: nv50: fix some memory leaks in shader assembler --- src/gallium/drivers/nv50/nv50_program.c | 88 +++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 2d15868ae8..a33ec5997a 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -823,6 +823,11 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, emit_mov(pc, dst[2], zero); set_pred(pc, 3, 0, pc->p->exec_tail); } + + FREE(pos128); + FREE(neg128); + FREE(zero); + FREE(one); } static void @@ -885,7 +890,9 @@ 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 c; + unsigned sgn, c; + + sgn = tgsi_util_get_full_src_register_sign_mode(src, chan); c = tgsi_util_get_full_src_register_extswizzle(src, chan); switch (c) { @@ -915,16 +922,17 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src) break; case TGSI_EXTSWIZZLE_ZERO: r = alloc_immd(pc, 0.0); - break; + return r; case TGSI_EXTSWIZZLE_ONE: - r = alloc_immd(pc, 1.0); - break; + if (sgn == TGSI_UTIL_SIGN_TOGGLE || sgn == TGSI_UTIL_SIGN_SET) + return alloc_immd(pc, -1.0); + return alloc_immd(pc, 1.0); default: assert(0); break; } - switch (tgsi_util_get_full_src_register_sign_mode(src, chan)) { + switch (sgn) { case TGSI_UTIL_SIGN_KEEP: break; case TGSI_UTIL_SIGN_CLEAR: @@ -967,6 +975,10 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) dst[c] = tgsi_dst(pc, c, &inst->FullDstRegisters[0]); else dst[c] = NULL; + rdst[c] = NULL; + src[0][c] = NULL; + src[1][c] = NULL; + src[2][c] = NULL; } for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { @@ -1002,7 +1014,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_COS: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_precossin(pc, temp, src[0][0]); emit_flop(pc, 5, temp, temp); for (c = 0; c < 4; c++) { @@ -1012,7 +1024,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_DP3: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_mul(pc, temp, src[0][0], src[1][0]); emit_mad(pc, temp, src[0][1], src[1][1], temp); emit_mad(pc, temp, src[0][2], src[1][2], temp); @@ -1021,10 +1033,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) continue; emit_mov(pc, dst[c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_DP4: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_mul(pc, temp, src[0][0], src[1][0]); emit_mad(pc, temp, src[0][1], src[1][1], temp); emit_mad(pc, temp, src[0][2], src[1][2], temp); @@ -1034,10 +1045,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) continue; emit_mov(pc, dst[c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_DPH: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_mul(pc, temp, src[0][0], src[1][0]); emit_mad(pc, temp, src[0][1], src[1][1], temp); emit_mad(pc, temp, src[0][2], src[1][2], temp); @@ -1047,7 +1057,6 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) continue; emit_mov(pc, dst[c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_DST: { @@ -1064,7 +1073,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_EX2: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_preex2(pc, temp, src[0][0]); emit_flop(pc, 6, temp, temp); for (c = 0; c < 4; c++) { @@ -1072,7 +1081,6 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) continue; emit_mov(pc, dst[c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_FLR: for (c = 0; c < 4; c++) { @@ -1082,14 +1090,13 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_FRC: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); for (c = 0; c < 4; c++) { if (!(mask & (1 << c))) continue; emit_flr(pc, temp, src[0][c]); emit_sub(pc, dst[c], src[0][c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_KIL: emit_kil(pc, src[0][0]); @@ -1101,7 +1108,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) emit_lit(pc, &dst[0], mask, &src[0][0]); break; case TGSI_OPCODE_LG2: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_flop(pc, 3, temp, src[0][0]); for (c = 0; c < 4; c++) { if (!(mask & (1 << c))) @@ -1157,14 +1164,13 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_POW: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_pow(pc, temp, src[0][0], src[1][0]); for (c = 0; c < 4; c++) { if (!(mask & (1 << c))) continue; emit_mov(pc, dst[c], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_RCP: for (c = 0; c < 4; c++) { @@ -1181,7 +1187,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_SCS: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_precossin(pc, temp, src[0][0]); if (mask & (1 << 0)) emit_flop(pc, 5, dst[0], temp); @@ -1196,7 +1202,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_SIN: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); emit_precossin(pc, temp, src[0][0]); emit_flop(pc, 4, temp, temp); for (c = 0; c < 4; c++) { @@ -1246,7 +1252,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_XPD: - temp = alloc_temp(pc, NULL); + temp = temp_temp(pc); if (mask & (1 << 0)) { emit_mul(pc, temp, src[0][2], src[1][1]); emit_msb(pc, dst[0], src[0][1], src[1][2], temp); @@ -1259,7 +1265,6 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) emit_mul(pc, temp, src[0][1], src[1][0]); emit_msb(pc, dst[2], src[0][0], src[1][1], temp); } - free_temp(pc, temp); break; case TGSI_OPCODE_END: break; @@ -1288,6 +1293,15 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } } + for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { + for (c = 0; c < 4; c++) { + if (!src[i][c]) + continue; + if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD) + FREE(src[i][c]); + } + } + kill_temp_temp(pc); return TRUE; } @@ -1477,6 +1491,31 @@ out_err: return ret; } +static void +free_nv50_pc(struct nv50_pc *pc) +{ + unsigned i; + + if (pc->immd) + FREE(pc->immd); + if (pc->param) + FREE(pc->param); + if (pc->result) + FREE(pc->result); + if (pc->attr) + FREE(pc->attr); + if (pc->temp) + FREE(pc->temp); + + for (i = 0; i < NV50_SU_MAX_TEMP; i++) { + /* deallocate fragment program attributes */ + if (pc->r_temp[i] && pc->r_temp[i]->index == -1) + FREE(pc->r_temp[i]); + } + + FREE(pc); +} + static boolean nv50_program_tx(struct nv50_program *p) { @@ -1530,6 +1569,7 @@ out_err: tgsi_parse_free(&parse); out_cleanup: + free_nv50_pc(pc); return ret; } @@ -1637,13 +1677,11 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) #ifdef NV50_PROGRAM_DUMP NOUVEAU_ERR("-------\n"); - up = ptr = MALLOC(p->exec_size * 4); for (e = p->exec_head; e; e = e->next) { NOUVEAU_ERR("0x%08x\n", e->inst[0]); if (is_long(e)) NOUVEAU_ERR("0x%08x\n", e->inst[1]); } - #endif up = ptr = MALLOC(p->exec_size * 4); -- cgit v1.2.3 From 229992d2812581ffae24d69a5a983d2c8441f720 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 12:21:54 +0200 Subject: nv50: make LRP instruction nicer --- src/gallium/drivers/nv50/nv50_program.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index a33ec5997a..6aec9cc841 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -1117,15 +1117,12 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_LRP: + temp = temp_temp(pc); for (c = 0; c < 4; c++) { if (!(mask & (1 << c))) continue; - /*XXX: we can do better than this */ - temp = alloc_temp(pc, NULL); - emit_neg(pc, temp, src[0][c]); - emit_mad(pc, temp, temp, src[2][c], src[2][c]); - emit_mad(pc, dst[c], src[0][c], src[1][c], temp); - free_temp(pc, temp); + emit_sub(pc, temp, src[1][c], src[2][c]); + emit_mad(pc, dst[c], temp, src[0][c], src[2][c]); } break; case TGSI_OPCODE_MAD: -- cgit v1.2.3 From 4a7cf8f66ff5d7e15ae7f8f5542f27bc72c68709 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 12:22:30 +0200 Subject: nv50: set dst.z,w to 0,1 in SCS and XPD According to tgsi-instruction-set.txt, if they are written, z and w should be set to 0 and 1 respectively in SCS, and w to 1.0 in XPD. --- src/gallium/drivers/nv50/nv50_program.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 6aec9cc841..877ead39ce 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -438,6 +438,14 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) emit(pc, e); } +static INLINE void +emit_mov_immdval(struct nv50_pc *pc, struct nv50_reg *dst, float f) +{ + struct nv50_reg *imm = alloc_immd(pc, f); + emit_mov(pc, dst, imm); + FREE(imm); +} + static boolean check_swap_src_0_1(struct nv50_pc *pc, struct nv50_reg **s0, struct nv50_reg **s1) @@ -1190,6 +1198,10 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) emit_flop(pc, 5, dst[0], temp); if (mask & (1 << 1)) emit_flop(pc, 4, dst[1], temp); + if (mask & (1 << 2)) + emit_mov_immdval(pc, dst[2], 0.0); + if (mask & (1 << 3)) + emit_mov_immdval(pc, dst[3], 1.0); break; case TGSI_OPCODE_SGE: for (c = 0; c < 4; c++) { @@ -1262,6 +1274,8 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) emit_mul(pc, temp, src[0][1], src[1][0]); emit_msb(pc, dst[2], src[0][0], src[1][1], temp); } + if (mask & (1 << 3)) + emit_mov_immdval(pc, dst[3], 1.0); break; case TGSI_OPCODE_END: break; -- cgit v1.2.3 From aad31d69ce9e2278d93e514b97e1a92a25f89826 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 12:24:33 +0200 Subject: nv50: fix SIGN_SET case in tgsi_src --- src/gallium/drivers/nv50/nv50_program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 877ead39ce..2241801542 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -956,7 +956,7 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src) case TGSI_UTIL_SIGN_SET: temp = temp_temp(pc); emit_abs(pc, temp, r); - emit_neg(pc, temp, r); + emit_neg(pc, temp, temp); r = temp; break; default: -- cgit v1.2.3 From 7e7d3a87ec60f8e412d724c6586461501d420ec0 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 12:25:32 +0200 Subject: nv50: save some space in immediate buffer We could do even better (like just allocating 1 value in alloc_immd), but that's fine for now I guess. --- src/gallium/drivers/nv50/nv50_program.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 2241801542..40d2384c3e 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -250,7 +250,13 @@ alloc_immd(struct nv50_pc *pc, float f) struct nv50_reg *r = CALLOC_STRUCT(nv50_reg); unsigned hw; - hw = ctor_immd(pc, f, 0, 0, 0) * 4; + for (hw = 0; hw < pc->immd_nr * 4; hw++) + if (pc->immd_buf[hw] == f) + break; + + if (hw == pc->immd_nr * 4) + hw = ctor_immd(pc, f, -f, 0.5 * f, 0) * 4; + r->type = P_IMMD; r->hw = hw; r->index = -1; -- cgit v1.2.3 From bcecb8ff66d2c002ac1273c0a9e9b2b9f9d3d43e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 13:32:51 +0200 Subject: nv50: record last access to temp and attr regs We now inspect the TGSI instructions in tx_prep to determine where temps and FP attrs are last accessed. This will enable us to reclaim some temporaries early and we also use it to omit pre-loading FP attributes that aren't used. --- src/gallium/drivers/nv50/nv50_program.c | 127 ++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 40d2384c3e..c73ed08a55 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -85,6 +85,8 @@ struct nv50_reg { int hw; int neg; + + int acc; /* instruction where this reg is last read (first insn == 1) */ }; struct nv50_pc { @@ -108,6 +110,10 @@ struct nv50_pc { struct nv50_reg *temp_temp[16]; unsigned temp_temp_nr; + + /* current instruction and total number of insns */ + unsigned insn_cur; + unsigned insn_nr; }; static void @@ -1323,6 +1329,112 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) return TRUE; } +/* Adjust a bitmask that indicates what components of a source are used, + * we use this in tx_prep so we only load interpolants that are needed. + */ +static void +insn_adjust_mask(const struct tgsi_full_instruction *insn, unsigned *mask) +{ + const struct tgsi_instruction_ext_texture *tex; + + switch (insn->Instruction.Opcode) { + case TGSI_OPCODE_DP3: + *mask = 0x7; + break; + case TGSI_OPCODE_DP4: + case TGSI_OPCODE_DPH: + *mask = 0xF; + break; + case TGSI_OPCODE_LIT: + *mask = 0xB; + break; + case TGSI_OPCODE_RCP: + case TGSI_OPCODE_RSQ: + *mask = 0x1; + break; + case TGSI_OPCODE_TEX: + case TGSI_OPCODE_TXP: + assert(insn->Instruction.Extended); + tex = &insn->InstructionExtTexture; + + *mask = 0x7; + if (tex->Texture == TGSI_TEXTURE_1D) + *mask = 0x1; + else + if (tex->Texture == TGSI_TEXTURE_2D) + *mask = 0x3; + + if (insn->Instruction.Opcode == TGSI_OPCODE_TXP) + *mask |= 0x8; + break; + default: + break; + } +} + +static void +prep_inspect_insn(struct nv50_pc *pc, const union tgsi_full_token *tok, + unsigned *r_usage[2]) +{ + const struct tgsi_full_instruction *insn; + const struct tgsi_full_src_register *src; + const struct tgsi_dst_register *dst; + + unsigned i, c, k, n, mask, *acc_p; + + insn = &tok->FullInstruction; + dst = &insn->FullDstRegisters[0].DstRegister; + mask = dst->WriteMask; + + if (!r_usage[0]) + r_usage[0] = CALLOC(pc->temp_nr * 4, sizeof(unsigned)); + if (!r_usage[1]) + r_usage[1] = CALLOC(pc->attr_nr * 4, sizeof(unsigned)); + + if (dst->File == TGSI_FILE_TEMPORARY) { + for (c = 0; c < 4; c++) { + if (!(mask & (1 << c))) + continue; + r_usage[0][dst->Index * 4 + c] = pc->insn_nr; + } + } + + for (i = 0; i < insn->Instruction.NumSrcRegs; i++) { + src = &insn->FullSrcRegisters[i]; + + switch (src->SrcRegister.File) { + case TGSI_FILE_TEMPORARY: + acc_p = r_usage[0]; + break; + case TGSI_FILE_INPUT: + acc_p = r_usage[1]; + break; + default: + continue; + } + + insn_adjust_mask(insn, &mask); + + for (c = 0; c < 4; c++) { + if (!(mask & (1 << c))) + continue; + + k = tgsi_util_get_full_src_register_extswizzle(src, c); + switch (k) { + case TGSI_EXTSWIZZLE_X: + case TGSI_EXTSWIZZLE_Y: + case TGSI_EXTSWIZZLE_Z: + case TGSI_EXTSWIZZLE_W: + n = src->SrcRegister.Index * 4 + k; + acc_p[n] = pc->insn_nr; + break; + default: + break; + } + } + } +} + static boolean nv50_program_tx_prep(struct nv50_pc *pc) { @@ -1330,6 +1442,11 @@ nv50_program_tx_prep(struct nv50_pc *pc) boolean ret = FALSE; unsigned i, c; + /* track register access for temps and attrs */ + unsigned *r_usage[2]; + r_usage[0] = NULL; + r_usage[1] = NULL; + tgsi_parse_init(&p, pc->p->pipe.tokens); while (!tgsi_parse_end_of_tokens(&p)) { const union tgsi_full_token *tok = &p.FullToken; @@ -1382,6 +1499,8 @@ nv50_program_tx_prep(struct nv50_pc *pc) } break; case TGSI_TOKEN_TYPE_INSTRUCTION: + pc->insn_nr++; + prep_inspect_insn(pc, tok, r_usage); break; default: break; @@ -1398,6 +1517,7 @@ nv50_program_tx_prep(struct nv50_pc *pc) pc->temp[i*4+c].type = P_TEMP; pc->temp[i*4+c].hw = -1; pc->temp[i*4+c].index = i; + pc->temp[i*4+c].acc = r_usage[0][i*4+c]; } } } @@ -1427,6 +1547,7 @@ nv50_program_tx_prep(struct nv50_pc *pc) pc->attr[i*4+c].type = at->type; pc->attr[i*4+c].hw = at->hw; pc->attr[i*4+c].index = at->index; + pc->attr[i*4+c].acc = r_usage[1][i*4+c]; } else { pc->p->cfg.vp.attr[aid/32] |= (1 << (aid % 32)); @@ -1504,6 +1625,11 @@ nv50_program_tx_prep(struct nv50_pc *pc) ret = TRUE; out_err: + if (r_usage[0]) + FREE(r_usage[0]); + if (r_usage[1]) + FREE(r_usage[1]); + tgsi_parse_free(&p); return ret; } @@ -1558,6 +1684,7 @@ nv50_program_tx(struct nv50_program *p) switch (tok->Token.Type) { case TGSI_TOKEN_TYPE_INSTRUCTION: + ++pc->insn_cur; ret = nv50_program_tx_insn(pc, tok); if (ret == FALSE) goto out_err; -- cgit v1.2.3 From e88ec312df000ac335d9bba6b75d836dfa1a1043 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 13:38:03 +0200 Subject: nv50: inspect decl semantic and interpolation mode Record interpolation mode for attributes while parsing declarations, and also remember the indices of FP color inputs and FP depth output, which has to end up in the highest output register. --- src/gallium/drivers/nv50/nv50_program.c | 75 ++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index c73ed08a55..85e5432208 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -111,6 +111,8 @@ struct nv50_pc { struct nv50_reg *temp_temp[16]; unsigned temp_temp_nr; + unsigned interp_mode[32]; + /* current instruction and total number of insns */ unsigned insn_cur; unsigned insn_nr; @@ -366,6 +368,12 @@ set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) e->inst[1] |= (val >> 6) << 2; } + +#define INTERP_LINEAR 0 +#define INTERP_FLAT 1 +#define INTERP_PERSPECTIVE 2 +#define INTERP_CENTROID 4 + static void emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src, struct nv50_reg *iv) @@ -1441,12 +1449,19 @@ nv50_program_tx_prep(struct nv50_pc *pc) struct tgsi_parse_context p; boolean ret = FALSE; unsigned i, c; + unsigned fcol, bcol, fcrd, depr; + + /* count (centroid) perspective interpolations */ + unsigned centroid_loads = 0; + unsigned perspect_loads = 0; /* track register access for temps and attrs */ unsigned *r_usage[2]; r_usage[0] = NULL; r_usage[1] = NULL; + depr = fcol = bcol = fcrd = 0xffff; + tgsi_parse_init(&p, pc->p->pipe.tokens); while (!tgsi_parse_end_of_tokens(&p)) { const union tgsi_full_token *tok = &p.FullToken; @@ -1467,9 +1482,10 @@ nv50_program_tx_prep(struct nv50_pc *pc) case TGSI_TOKEN_TYPE_DECLARATION: { const struct tgsi_full_declaration *d; - unsigned last; + unsigned last, first, mode; d = &p.FullToken.FullDeclaration; + first = d->DeclarationRange.First; last = d->DeclarationRange.Last; switch (d->Declaration.File) { @@ -1480,10 +1496,67 @@ nv50_program_tx_prep(struct nv50_pc *pc) case TGSI_FILE_OUTPUT: if (pc->result_nr < (last + 1)) pc->result_nr = last + 1; + + if (!d->Declaration.Semantic) + break; + + switch (d->Semantic.SemanticName) { + case TGSI_SEMANTIC_POSITION: + depr = first; + break; + default: + break; + } + break; case TGSI_FILE_INPUT: + { if (pc->attr_nr < (last + 1)) pc->attr_nr = last + 1; + + if (pc->p->type != PIPE_SHADER_FRAGMENT) + break; + + switch (d->Declaration.Interpolate) { + case TGSI_INTERPOLATE_CONSTANT: + mode = INTERP_FLAT; + break; + case TGSI_INTERPOLATE_PERSPECTIVE: + mode = INTERP_PERSPECTIVE; + break; + default: + mode = INTERP_LINEAR; + break; + } + + if (d->Declaration.Semantic) { + switch (d->Semantic.SemanticName) { + case TGSI_SEMANTIC_POSITION: + fcrd = first; + break; + case TGSI_SEMANTIC_COLOR: + fcol = first; + mode = INTERP_PERSPECTIVE; + break; + case TGSI_SEMANTIC_BCOLOR: + bcol = first; + mode = INTERP_PERSPECTIVE; + break; + } + } + + if (d->Declaration.Centroid) { + mode |= INTERP_CENTROID; + if (mode & INTERP_PERSPECTIVE) + centroid_loads++; + } else + if (mode & INTERP_PERSPECTIVE) + perspect_loads++; + + assert(last < 32); + for (i = first; i <= last; i++) + pc->interp_mode[i] = mode; + } break; case TGSI_FILE_CONSTANT: if (pc->param_nr < (last + 1)) -- cgit v1.2.3 From dd9ded42b9ff75aa0bbabef30d385a9f77851dce Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 14:56:48 +0200 Subject: nv50: modified FP attribute loading VP outputs that should be loadable in the FP are mapped to interpolant indices by HPOS, COL0 etc.; of course HPOS is always written, so the highest byte of 1988 is a bitmask that selects which components of HPOS are used for interpolants, i.e. the FP inputs in COL0 start at index POPCNT(1988[24:28]). --- src/gallium/drivers/nv50/nv50_program.c | 187 ++++++++++++++++++++++++-------- src/gallium/drivers/nv50/nv50_program.h | 5 + 2 files changed, 147 insertions(+), 45 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 85e5432208..5d391f9b24 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -86,6 +86,7 @@ struct nv50_reg { int hw; int neg; + int rhw; /* result hw for FP outputs, or interpolant index */ int acc; /* instruction where this reg is last read (first insn == 1) */ }; @@ -112,6 +113,9 @@ struct nv50_pc { unsigned temp_temp_nr; unsigned interp_mode[32]; + /* perspective interpolation registers */ + struct nv50_reg *iv_p; + struct nv50_reg *iv_c; /* current instruction and total number of insns */ unsigned insn_cur; @@ -374,20 +378,29 @@ set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) #define INTERP_PERSPECTIVE 2 #define INTERP_CENTROID 4 +/* interpolant index has been stored in dst->rhw */ static void -emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, - struct nv50_reg *src, struct nv50_reg *iv) +emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *iv, + unsigned mode) { + assert(dst->rhw != -1); struct nv50_program_exec *e = exec(pc); e->inst[0] |= 0x80000000; set_dst(pc, dst, e); - alloc_reg(pc, src); - e->inst[0] |= (src->hw << 16); - if (iv) { - e->inst[0] |= (1 << 25); - alloc_reg(pc, iv); - e->inst[0] |= (iv->hw << 9); + e->inst[0] |= (dst->rhw << 16); + + if (mode & INTERP_FLAT) { + e->inst[0] |= (1 << 8); + } else { + if (mode & INTERP_PERSPECTIVE) { + e->inst[0] |= (1 << 25); + alloc_reg(pc, iv); + e->inst[0] |= (iv->hw << 9); + } + + if (mode & INTERP_CENTROID) + e->inst[0] |= (1 << 24); } emit(pc, e); @@ -1443,6 +1456,40 @@ prep_inspect_insn(struct nv50_pc *pc, const union tgsi_full_token *tok, } } +static unsigned +load_fp_attrib(struct nv50_pc *pc, int i, unsigned *acc, int *mid, + int *aid, int *p_oid) +{ + struct nv50_reg *iv; + int oid, c, n; + unsigned mask = 0; + + iv = (pc->interp_mode[i] & INTERP_CENTROID) ? pc->iv_c : pc->iv_p; + + for (c = 0, n = i * 4; c < 4; c++, n++) { + oid = (*p_oid)++; + pc->attr[n].type = P_TEMP; + pc->attr[n].index = i; + + if (pc->attr[n].acc == acc[n]) + continue; + mask |= (1 << c); + + pc->attr[n].acc = acc[n]; + pc->attr[n].rhw = pc->attr[n].hw = -1; + alloc_reg(pc, &pc->attr[n]); + + pc->attr[n].rhw = (*aid)++; + emit_interp(pc, &pc->attr[n], iv, pc->interp_mode[i]); + + pc->p->cfg.fp.map[(*mid) / 4] |= oid << (8 * ((*mid) % 4)); + (*mid)++; + pc->p->cfg.fp.regs[1] += 0x00010001; + } + + return mask; +} + static boolean nv50_program_tx_prep(struct nv50_pc *pc) { @@ -1462,6 +1509,11 @@ nv50_program_tx_prep(struct nv50_pc *pc) depr = fcol = bcol = fcrd = 0xffff; + if (pc->p->type == PIPE_SHADER_FRAGMENT) { + pc->p->cfg.fp.regs[0] = 0x01000404; + pc->p->cfg.fp.regs[1] = 0x00000400; + } + tgsi_parse_init(&p, pc->p->pipe.tokens); while (!tgsi_parse_end_of_tokens(&p)) { const union tgsi_full_token *tok = &p.FullToken; @@ -1503,6 +1555,8 @@ nv50_program_tx_prep(struct nv50_pc *pc) switch (d->Semantic.SemanticName) { case TGSI_SEMANTIC_POSITION: depr = first; + pc->p->cfg.fp.regs[2] |= 0x00000100; + pc->p->cfg.fp.regs[3] |= 0x00000011; break; default: break; @@ -1589,6 +1643,7 @@ nv50_program_tx_prep(struct nv50_pc *pc) for (c = 0; c < 4; c++) { pc->temp[i*4+c].type = P_TEMP; pc->temp[i*4+c].hw = -1; + pc->temp[i*4+c].rhw = -1; pc->temp[i*4+c].index = i; pc->temp[i*4+c].acc = r_usage[0][i*4+c]; } @@ -1596,51 +1651,87 @@ nv50_program_tx_prep(struct nv50_pc *pc) } if (pc->attr_nr) { - struct nv50_reg *iv = NULL; - int aid = 0; + int oid = 4, mid = 4, aid = 0; + /* oid = VP output id + * aid = FP attribute/interpolant id + * mid = VP output mapping field ID + */ pc->attr = CALLOC(pc->attr_nr * 4, sizeof(struct nv50_reg)); if (!pc->attr) goto out_err; if (pc->p->type == PIPE_SHADER_FRAGMENT) { - iv = alloc_temp(pc, NULL); - emit_interp(pc, iv, iv, NULL); - emit_flop(pc, 0, iv, iv); - aid++; - } + /* position should be loaded first */ + if (fcrd != 0xffff) { + unsigned mask; + mid = 0; + mask = load_fp_attrib(pc, fcrd, r_usage[1], + &mid, &aid, &oid); + oid = 0; + pc->p->cfg.fp.regs[1] |= (mask << 24); + pc->p->cfg.fp.map[0] = 0x04040404 * fcrd; + } + pc->p->cfg.fp.map[0] += 0x03020100; - for (i = 0; i < pc->attr_nr; i++) { - struct nv50_reg *a = &pc->attr[i*4]; + /* should do MAD fcrd.xy, fcrd, SOME_CONST, fcrd */ - for (c = 0; c < 4; c++) { - if (pc->p->type == PIPE_SHADER_FRAGMENT) { - struct nv50_reg *at = - alloc_temp(pc, NULL); - pc->attr[i*4+c].type = at->type; - pc->attr[i*4+c].hw = at->hw; - pc->attr[i*4+c].index = at->index; - pc->attr[i*4+c].acc = r_usage[1][i*4+c]; + if (perspect_loads) { + pc->iv_p = alloc_temp(pc, NULL); + + if (!(pc->p->cfg.fp.regs[1] & 0x08000000)) { + pc->p->cfg.fp.regs[1] |= 0x08000000; + pc->iv_p->rhw = aid++; + emit_interp(pc, pc->iv_p, NULL, + INTERP_LINEAR); + emit_flop(pc, 0, pc->iv_p, pc->iv_p); } else { - pc->p->cfg.vp.attr[aid/32] |= - (1 << (aid % 32)); - pc->attr[i*4+c].type = P_ATTR; - pc->attr[i*4+c].hw = aid++; - pc->attr[i*4+c].index = i; + pc->iv_p->rhw = aid - 1; + emit_flop(pc, 0, pc->iv_p, + &pc->attr[fcrd * 4 + 3]); } } - if (pc->p->type != PIPE_SHADER_FRAGMENT) - continue; + if (centroid_loads) { + pc->iv_c = alloc_temp(pc, NULL); + pc->iv_c->rhw = pc->iv_p ? aid - 1 : aid++; + emit_interp(pc, pc->iv_c, NULL, + INTERP_CENTROID); + emit_flop(pc, 0, pc->iv_c, pc->iv_c); + pc->p->cfg.fp.regs[1] |= 0x08000000; + } - emit_interp(pc, &a[0], &a[0], iv); - emit_interp(pc, &a[1], &a[1], iv); - emit_interp(pc, &a[2], &a[2], iv); - emit_interp(pc, &a[3], &a[3], iv); - } + for (c = 0; c < 4; c++) { + /* I don't know what these values do, but + * let's set them like the blob does: + */ + if (fcol != 0xffff && r_usage[1][fcol * 4 + c]) + pc->p->cfg.fp.regs[0] += 0x00010000; + if (bcol != 0xffff && r_usage[1][bcol * 4 + c]) + pc->p->cfg.fp.regs[0] += 0x00010000; + } + + for (i = 0; i < pc->attr_nr; i++) + load_fp_attrib(pc, i, r_usage[1], + &mid, &aid, &oid); - if (iv) - free_temp(pc, iv); + if (pc->iv_p) + free_temp(pc, pc->iv_p); + if (pc->iv_c) + free_temp(pc, pc->iv_c); + + pc->p->cfg.fp.high_map = (mid / 4); + pc->p->cfg.fp.high_map += ((mid % 4) ? 1 : 0); + } else { + /* vertex program */ + for (i = 0; i < pc->attr_nr * 4; i++) { + pc->p->cfg.vp.attr[aid / 32] |= + (1 << (aid % 32)); + pc->attr[i].type = P_ATTR; + pc->attr[i].hw = aid++; + pc->attr[i].index = i / 4; + } + } } if (pc->result_nr) { @@ -1983,6 +2074,7 @@ nv50_fragprog_validate(struct nv50_context *nv50) struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_program *p = nv50->fragprog; struct nouveau_stateobj *so; + unsigned i; if (!p->translated) { nv50_program_validate(nv50, p); @@ -2000,17 +2092,22 @@ nv50_fragprog_validate(struct nv50_context *nv50) so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); so_method(so, tesla, 0x1904, 4); - so_data (so, 0x00040404); /* p: 0x01000404 */ + so_data (so, p->cfg.fp.regs[0]); /* 0x01000404 / 0x00040404 */ so_data (so, 0x00000004); so_data (so, 0x00000000); so_data (so, 0x00000000); - so_method(so, tesla, 0x16bc, 3); /*XXX: fixme */ - so_data (so, 0x03020100); - so_data (so, 0x07060504); - so_data (so, 0x0b0a0908); + so_method(so, tesla, 0x16bc, p->cfg.fp.high_map); + for (i = 0; i < p->cfg.fp.high_map; i++) + so_data(so, p->cfg.fp.map[i]); so_method(so, tesla, 0x1988, 2); - so_data (so, 0x08080408); //0x08040404); /* p: 0x0f000401 */ + so_data (so, p->cfg.fp.regs[1]); /* 0x08040404 / 0x0f000401 */ so_data (so, p->cfg.high_temp); + so_method(so, tesla, 0x1298, 1); + so_data (so, p->cfg.high_result); + so_method(so, tesla, 0x19a8, 1); + so_data (so, p->cfg.fp.regs[2]); + so_method(so, tesla, 0x196c, 1); + so_data (so, p->cfg.fp.regs[3]); so_method(so, tesla, 0x1414, 1); so_data (so, 0); /* program start offset */ so_ref(so, &nv50->state.fragprog); diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h index 78deed6a38..b3240b36ef 100644 --- a/src/gallium/drivers/nv50/nv50_program.h +++ b/src/gallium/drivers/nv50/nv50_program.h @@ -39,6 +39,11 @@ struct nv50_program { struct { unsigned attr[2]; } vp; + struct { + unsigned regs[4]; + unsigned map[5]; + unsigned high_map; + } fp; } cfg; }; -- cgit v1.2.3 From f579a99cc608eaba6f617c11ab0aec7f3e9ef953 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:01:36 +0200 Subject: nv50: put FP outputs where they belong Depth output in fragment programs should end up in the first register after the color outputs. --- src/gallium/drivers/nv50/nv50_program.c | 41 +++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 5d391f9b24..80b7630113 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -125,7 +125,7 @@ struct nv50_pc { static void alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg) { - int i; + int i = 0; if (reg->type == P_RESULT) { if (pc->p->cfg.high_result < (reg->hw + 1)) @@ -143,7 +143,22 @@ alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg) return; } - for (i = 0; i < NV50_SU_MAX_TEMP; i++) { + if (reg->rhw != -1) { + /* try to allocate temporary with index rhw first */ + if (!(pc->r_temp[reg->rhw])) { + pc->r_temp[reg->rhw] = reg; + reg->hw = reg->rhw; + if (pc->p->cfg.high_temp < (reg->rhw + 1)) + pc->p->cfg.high_temp = reg->rhw + 1; + return; + } + /* make sure we don't get things like $r0 needs to go + * in $r1 and $r1 in $r0 + */ + i = pc->result_nr * 4; + } + + for (; i < NV50_SU_MAX_TEMP; i++) { if (!(pc->r_temp[i])) { pc->r_temp[i] = reg; reg->hw = i; @@ -171,6 +186,7 @@ alloc_temp(struct nv50_pc *pc, struct nv50_reg *dst) r->type = P_TEMP; r->index = -1; r->hw = i; + r->rhw = -1; pc->r_temp[i] = r; return r; } @@ -1746,12 +1762,20 @@ nv50_program_tx_prep(struct nv50_pc *pc) if (pc->p->type == PIPE_SHADER_FRAGMENT) { pc->result[i*4+c].type = P_TEMP; pc->result[i*4+c].hw = -1; + pc->result[i*4+c].rhw = (i == depr) ? + -1 : rid++; } else { pc->result[i*4+c].type = P_RESULT; pc->result[i*4+c].hw = rid++; } pc->result[i*4+c].index = i; } + + if (pc->p->type == PIPE_SHADER_FRAGMENT && + depr != 0xffff) { + pc->result[depr * 4 + 2].rhw = + (pc->result_nr - 1) * 4; + } } } @@ -1828,6 +1852,7 @@ nv50_program_tx(struct nv50_program *p) { struct tgsi_parse_context parse; struct nv50_pc *pc; + unsigned k; boolean ret; pc = CALLOC_STRUCT(nv50_pc); @@ -1862,8 +1887,16 @@ nv50_program_tx(struct nv50_program *p) struct nv50_reg out; out.type = P_TEMP; - for (out.hw = 0; out.hw < pc->result_nr * 4; out.hw++) - emit_mov(pc, &out, &pc->result[out.hw]); + for (k = 0; k < pc->result_nr * 4; k++) { + if (pc->result[k].rhw == -1) + continue; + if (pc->result[k].hw != pc->result[k].rhw) { + out.hw = pc->result[k].rhw; + emit_mov(pc, &out, &pc->result[k]); + } + if (pc->p->cfg.high_result < (pc->result[k].rhw + 1)) + pc->p->cfg.high_result = pc->result[k].rhw + 1; + } } assert(is_long(pc->p->exec_tail) && !is_immd(pc->p->exec_head)); -- cgit v1.2.3 From dac709d0cf3258ad8e131964e513c2eabe1d554e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:04:53 +0200 Subject: nv50: don't overwrite sources before they're used This would have happened in p.e. ADD TEMP[0], TEMP[0].xyxy, TEMP[1] or RCP/RSQ TEMP[i], TEMP[i]. --- src/gallium/drivers/nv50/nv50_program.c | 95 ++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 80b7630113..fa13133922 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -196,6 +196,22 @@ alloc_temp(struct nv50_pc *pc, struct nv50_reg *dst) return NULL; } +/* Assign the hw of the discarded temporary register src + * to the tgsi register dst and free src. + */ +static void +assimilate_temp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) +{ + assert(src->index == -1 && src->hw != -1); + + if (dst->hw != -1) + pc->r_temp[dst->hw] = NULL; + pc->r_temp[src->hw] = dst; + dst->hw = src->hw; + + FREE(src); +} + static void free_temp(struct nv50_pc *pc, struct nv50_reg *r) { @@ -852,17 +868,8 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, struct nv50_reg *pos128 = alloc_immd(pc, 127.999999); struct nv50_reg *tmp[4]; - if (mask & (1 << 0)) - emit_mov(pc, dst[0], one); - - if (mask & (1 << 3)) - emit_mov(pc, dst[3], one); - if (mask & (3 << 1)) { - if (mask & (1 << 1)) - tmp[0] = dst[1]; - else - tmp[0] = temp_temp(pc); + tmp[0] = alloc_temp(pc, NULL); emit_minmax(pc, 4, tmp[0], src[0], zero); } @@ -881,6 +888,19 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, set_pred(pc, 3, 0, pc->p->exec_tail); } + if (mask & (1 << 1)) + assimilate_temp(pc, dst[1], tmp[0]); + else + if (mask & (1 << 2)) + free_temp(pc, tmp[0]); + + /* do this last, in case src[i,j] == dst[0,3] */ + if (mask & (1 << 0)) + emit_mov(pc, dst[0], one); + + if (mask & (1 << 3)) + emit_mov(pc, dst[3], one); + FREE(pos128); FREE(neg128); FREE(zero); @@ -1016,12 +1036,40 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src) return r; } +/* returns TRUE if instruction can overwrite sources before they're read */ +static boolean +direct2dest_op(const struct tgsi_full_instruction *insn) +{ + if (insn->Instruction.Saturate) + return FALSE; + + switch (insn->Instruction.Opcode) { + case TGSI_OPCODE_COS: + case TGSI_OPCODE_DP3: + case TGSI_OPCODE_DP4: + case TGSI_OPCODE_DPH: + case TGSI_OPCODE_KIL: + case TGSI_OPCODE_LIT: + case TGSI_OPCODE_POW: + case TGSI_OPCODE_RCP: + case TGSI_OPCODE_RSQ: + case TGSI_OPCODE_SCS: + case TGSI_OPCODE_SIN: + case TGSI_OPCODE_TEX: + case TGSI_OPCODE_TXP: + return FALSE; + default: + return TRUE; + } +} + static boolean nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) { const struct tgsi_full_instruction *inst = &tok->FullInstruction; struct nv50_reg *rdst[4], *dst[4], *src[3][4], *temp; unsigned mask, sat, unit; + boolean assimilate = FALSE; int i, c; mask = inst->FullDstRegisters[0].DstRegister.WriteMask; @@ -1053,6 +1101,25 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) rdst[c] = dst[c]; dst[c] = temp_temp(pc); } + } else + if (direct2dest_op(inst)) { + for (c = 0; c < 4; c++) { + if (!dst[c] || dst[c]->type != P_TEMP) + continue; + + for (i = c + 1; i < 4; i++) { + if (dst[c] == src[0][i] || + dst[c] == src[1][i] || + dst[c] == src[2][i]) + break; + } + if (i == 4) + continue; + + assimilate = TRUE; + rdst[c] = dst[c]; + dst[c] = alloc_temp(pc, NULL); + } } switch (inst->Instruction.Opcode) { @@ -1227,14 +1294,14 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_RCP: - for (c = 0; c < 4; c++) { + for (c = 3; c >= 0; c--) { if (!(mask & (1 << c))) continue; emit_flop(pc, 0, dst[c], src[0][0]); } break; case TGSI_OPCODE_RSQ: - for (c = 0; c < 4; c++) { + for (c = 3; c >= 0; c--) { if (!(mask & (1 << c))) continue; emit_flop(pc, 2, dst[c], src[0][0]); @@ -1351,6 +1418,10 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) set_src_0(pc, dst[c], e); emit(pc, e); } + } else if (assimilate) { + for (c = 0; c < 4; c++) + if (rdst[c]) + assimilate_temp(pc, rdst[c], dst[c]); } for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { -- cgit v1.2.3 From de651a228f9bbe5ab0e3b749b3dfda9aa5497097 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:05:55 +0200 Subject: nv50: enable KIL in register 19a8 --- src/gallium/drivers/nv50/nv50_program.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index fa13133922..c420b8be1c 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -1227,6 +1227,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) emit_kil(pc, src[0][1]); emit_kil(pc, src[0][2]); emit_kil(pc, src[0][3]); + pc->p->cfg.fp.regs[2] |= 0x00100000; break; case TGSI_OPCODE_LIT: emit_lit(pc, &dst[0], mask, &src[0][0]); -- cgit v1.2.3 From 44b3bfaa7599add72d76b3802ddea05b5b5c6316 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:10:01 +0200 Subject: nv50: make sure half-long insns are paired I chose to just convert unpaired 32 bit length instructions after parsing all instructions, although it might be possible to determine beforehand whether there would be any lone ones, and then even do some swapping to bring them together ... --- src/gallium/drivers/nv50/nv50_program.c | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index c420b8be1c..78ffc7f7ce 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -945,6 +945,54 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src) emit(pc, e); } +static void +convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e) +{ + unsigned q = 0, m = ~0; + + assert(!is_long(e)); + + switch (e->inst[0] >> 28) { + case 0x1: + /* MOV */ + q = 0x0403c000; + m = 0xffff7fff; + break; + case 0x8: + /* INTERP */ + m = ~0x02000000; + if (e->inst[0] & 0x02000000) + q = 0x00020000; + break; + case 0x9: + /* RCP */ + break; + case 0xB: + /* ADD */ + m = ~(127 << 16); + q = ((e->inst[0] & (~m)) >> 2); + break; + case 0xC: + /* MUL */ + m = ~0x00008000; + q = ((e->inst[0] & (~m)) << 12); + break; + case 0xE: + /* MAD (if src2 == dst) */ + q = ((e->inst[0] & 0x1fc) << 12); + break; + default: + assert(0); + break; + } + + set_long(pc, e); + pc->p->exec_size++; + + e->inst[0] &= m; + e->inst[1] |= q; +} + static struct nv50_reg * tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst) { @@ -1971,6 +2019,30 @@ nv50_program_tx(struct nv50_program *p) } } + /* look for single half instructions and make them long */ + struct nv50_program_exec *e, *e_prev; + + for (k = 0, e = pc->p->exec_head, e_prev = NULL; e; e = e->next) { + if (!is_long(e)) + k++; + + if (!e->next || is_long(e->next)) { + if (k & 1) + convert_to_long(pc, e); + k = 0; + } + + if (e->next) + e_prev = e; + } + + if (!is_long(pc->p->exec_tail)) { + /* this may occur if moving FP results */ + assert(e_prev && !is_long(e_prev)); + convert_to_long(pc, e_prev); + convert_to_long(pc, pc->p->exec_tail); + } + assert(is_long(pc->p->exec_tail) && !is_immd(pc->p->exec_head)); pc->p->exec_tail->inst[1] |= 0x00000001; -- cgit v1.2.3 From d015cba88f1ef217f6ef9d116ba6abb32e043baa Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:10:56 +0200 Subject: nv50: enable half insns for MOV and MUL --- src/gallium/drivers/nv50/nv50_program.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 78ffc7f7ce..05b63be60a 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -120,6 +120,8 @@ struct nv50_pc { /* current instruction and total number of insns */ unsigned insn_cur; unsigned insn_nr; + + boolean allow32; }; static void @@ -491,14 +493,13 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) e->inst[0] |= (src->hw << 9); } - /* We really should support "half" instructions here at some point, - * but I don't feel confident enough about them yet. - */ - set_long(pc, e); if (is_long(e) && !is_immd(e)) { e->inst[1] |= 0x04000000; /* 32-bit */ - e->inst[1] |= 0x0003c000; /* "subsubop" 0xf == mov */ - } + e->inst[1] |= 0x0000c000; /* "subsubop" 0x3 */ + if (!(e->inst[1] & 0x20000000)) + e->inst[1] |= 0x00030000; /* "subsubop" 0xf */ + } else + e->inst[0] |= 0x00008000; emit(pc, e); } @@ -614,7 +615,6 @@ emit_mul(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, struct nv50_program_exec *e = exec(pc); e->inst[0] |= 0xc0000000; - set_long(pc, e); check_swap_src_0_1(pc, &src0, &src1); set_dst(pc, dst, e); @@ -1989,6 +1989,11 @@ nv50_program_tx(struct nv50_program *p) while (!tgsi_parse_end_of_tokens(&parse)) { const union tgsi_full_token *tok = &parse.FullToken; + /* don't allow half insn/immd on first and last instruction */ + pc->allow32 = TRUE; + if (pc->insn_cur == 0 || pc->insn_cur + 2 == pc->insn_nr) + pc->allow32 = FALSE; + tgsi_parse_token(&parse); switch (tok->Token.Type) { -- cgit v1.2.3 From 708c711f8361ea82c1217e2614914ae047bc5bdf Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:12:04 +0200 Subject: nv50: allow immediates for MOV, ADD and MUL Immediates are inlined now where possible, so we need to set pc->allow32 to FALSE in LIT where we have the conditional MOV, since immediates swallow the predicate bits. --- src/gallium/drivers/nv50/nv50_program.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 05b63be60a..30aa358860 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -393,7 +393,8 @@ set_dst(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_program_exec *e) static INLINE void set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) { - unsigned val = fui(pc->immd_buf[imm->hw]); /* XXX */ + assert(imm->hw >= pc->param_nr * 4); + unsigned val = fui(pc->immd_buf[imm->hw - pc->param_nr * 4]); set_long(pc, e); /*XXX: can't be predicated - bits overlap.. catch cases where both @@ -472,12 +473,11 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) set_dst(pc, dst, e); - if (0 && dst->type != P_RESULT && src->type == P_IMMD) { + if (pc->allow32 && dst->type != P_RESULT && 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 */ - e->inst[0] |= 0x00008000; } else if (src->type == P_IMMD || src->type == P_CONST) { set_long(pc, e); @@ -616,10 +616,16 @@ emit_mul(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, e->inst[0] |= 0xc0000000; + if (!pc->allow32) + set_long(pc, e); + check_swap_src_0_1(pc, &src0, &src1); set_dst(pc, dst, e); set_src_0(pc, src0, e); - set_src_1(pc, src1, e); + if (src1->type == P_IMMD && !is_long(e)) + set_immd(pc, src1, e); + else + set_src_1(pc, src1, e); emit(pc, e); } @@ -632,11 +638,17 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst, e->inst[0] |= 0xb0000000; + if (!pc->allow32) + set_long(pc, e); + check_swap_src_0_1(pc, &src0, &src1); set_dst(pc, dst, e); set_src_0(pc, src0, e); - if (is_long(e)) + if (is_long(e) || src1->type == P_CONST || src1->type == P_ATTR) set_src_2(pc, src1, e); + else + if (src1->type == P_IMMD) + set_immd(pc, src1, e); else set_src_1(pc, src1, e); @@ -867,6 +879,9 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, struct nv50_reg *neg128 = alloc_immd(pc, -127.999999); struct nv50_reg *pos128 = alloc_immd(pc, 127.999999); struct nv50_reg *tmp[4]; + boolean allow32 = pc->allow32; + + pc->allow32 = FALSE; if (mask & (3 << 1)) { tmp[0] = alloc_temp(pc, NULL); @@ -894,6 +909,8 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, if (mask & (1 << 2)) free_temp(pc, tmp[0]); + pc->allow32 = allow32; + /* do this last, in case src[i,j] == dst[0,3] */ if (mask & (1 << 0)) emit_mov(pc, dst[0], one); -- cgit v1.2.3 From 7ab96f4f733437de693b9578c3649b56069e6f24 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:15:20 +0200 Subject: nv50: release hw TEMPs early Since we know when we don't use a TEMP or FP ATTR register anymore, we can release their hw resources early. --- src/gallium/drivers/nv50/nv50_program.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 30aa358860..15d7ab0da5 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -214,6 +214,22 @@ assimilate_temp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) FREE(src); } +/* release the hardware resource held by r */ +static void +release_hw(struct nv50_pc *pc, struct nv50_reg *r) +{ + assert(r->type == P_TEMP); + if (r->hw == -1) + return; + + assert(pc->r_temp[r->hw] == r); + pc->r_temp[r->hw] = NULL; + + r->acc = 0; + if (r->index == -1) + FREE(r); +} + static void free_temp(struct nv50_pc *pc, struct nv50_reg *r) { @@ -1496,6 +1512,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) continue; if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD) FREE(src[i][c]); + else + if (src[i][c]->acc == pc->insn_cur) + release_hw(pc, src[i][c]); } } -- cgit v1.2.3 From f9268ccd7f2ef2476db48f0aaca739bfb4ee9eab Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 15:17:03 +0200 Subject: nv50: don't look for unfreed temps in free_nv50_pc Since we stopped using alloc_temp to get hw indices for FP attrs there shouldn't be any non-deallocated temps left. --- src/gallium/drivers/nv50/nv50_program.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 15d7ab0da5..ea519e0c03 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -1981,8 +1981,6 @@ out_err: static void free_nv50_pc(struct nv50_pc *pc) { - unsigned i; - if (pc->immd) FREE(pc->immd); if (pc->param) @@ -1994,12 +1992,6 @@ free_nv50_pc(struct nv50_pc *pc) if (pc->temp) FREE(pc->temp); - for (i = 0; i < NV50_SU_MAX_TEMP; i++) { - /* deallocate fragment program attributes */ - if (pc->r_temp[i] && pc->r_temp[i]->index == -1) - FREE(pc->r_temp[i]); - } - FREE(pc); } -- cgit v1.2.3 From 94ba165dffa4d364a1335d3cd7c15558bf35fe3e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 16:13:24 +0200 Subject: nv50: use multiple constant buffers Use different buffers for immds, FP params, and VP params. One has to map constant buffer indices in shader code to buffers defined via CB_DEF. In principle, we could use more buffers so we'd have to change the shader code less frequently. --- src/gallium/drivers/nv50/nv50_program.c | 86 +++++++++++++++++++-------------- src/gallium/drivers/nv50/nv50_program.h | 4 +- src/gallium/drivers/nv50/nv50_screen.c | 56 ++++++++++++++++++--- src/gallium/drivers/nv50/nv50_screen.h | 7 ++- 4 files changed, 105 insertions(+), 48 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index ea519e0c03..6c07fbfe0c 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -409,8 +409,7 @@ set_dst(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_program_exec *e) static INLINE void set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) { - assert(imm->hw >= pc->param_nr * 4); - unsigned val = fui(pc->immd_buf[imm->hw - pc->param_nr * 4]); + unsigned val = fui(pc->immd_buf[imm->hw]); set_long(pc, e); /*XXX: can't be predicated - bits overlap.. catch cases where both @@ -462,22 +461,12 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s, struct nv50_program_exec *e) { set_long(pc, e); -#if 1 - e->inst[1] |= (1 << 22); -#else - if (src->type == P_IMMD) { - e->inst[1] |= (NV50_CB_PMISC << 22); - } else { - if (pc->p->type == PIPE_SHADER_VERTEX) - e->inst[1] |= (NV50_CB_PVP << 22); - else - e->inst[1] |= (NV50_CB_PFP << 22); - } -#endif e->param.index = src->hw; e->param.shift = s; e->param.mask = m << (s % 32); + + e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22); } static void @@ -1952,7 +1941,7 @@ nv50_program_tx_prep(struct nv50_pc *pc) } if (pc->immd_nr) { - int rid = pc->param_nr * 4; + int rid = 0; pc->immd = CALLOC(pc->immd_nr * 4, sizeof(struct nv50_reg)); if (!pc->immd) @@ -2101,7 +2090,7 @@ nv50_program_validate(struct nv50_context *nv50, struct nv50_program *p) static void nv50_program_upload_data(struct nv50_context *nv50, float *map, - unsigned start, unsigned count) + unsigned start, unsigned count, unsigned cbuf) { struct nouveau_channel *chan = nv50->screen->nvws->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -2110,7 +2099,7 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map, unsigned nr = count > 2047 ? 2047 : count; BEGIN_RING(chan, tesla, 0x00000f00, 1); - OUT_RING (chan, (NV50_CB_PMISC << 0) | (start << 8)); + OUT_RING (chan, (cbuf << 0) | (start << 8)); BEGIN_RING(chan, tesla, 0x40000f04, nr); OUT_RINGp (chan, map, nr); @@ -2125,35 +2114,50 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) { struct nouveau_winsys *nvws = nv50->screen->nvws; struct pipe_winsys *ws = nv50->pipe.winsys; - unsigned nr = p->param_nr + p->immd_nr; - if (!p->data && nr) { - struct nouveau_resource *heap = nv50->screen->vp_data_heap; + if (!p->data[0] && p->immd_nr) { + struct nouveau_resource *heap = nv50->screen->immd_heap[0]; + + if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) { + while (heap->next && heap->size < p->immd_nr) { + struct nv50_program *evict = heap->next->priv; + nvws->res_free(&evict->data[0]); + } + + if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) + assert(0); + } + + /* immediates only need to be uploaded again when freed */ + nv50_program_upload_data(nv50, p->immd, p->data[0]->start, + p->immd_nr, NV50_CB_PMISC); + } - if (nvws->res_alloc(heap, nr, p, &p->data)) { - while (heap->next && heap->size < nr) { + if (!p->data[1] && p->param_nr) { + struct nouveau_resource *heap = + nv50->screen->parm_heap[p->type]; + + if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) { + while (heap->next && heap->size < p->param_nr) { struct nv50_program *evict = heap->next->priv; - nvws->res_free(&evict->data); + nvws->res_free(&evict->data[1]); } - if (nvws->res_alloc(heap, nr, p, &p->data)) + if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) assert(0); } } if (p->param_nr) { + unsigned cbuf = NV50_CB_PVP; float *map = ws->buffer_map(ws, nv50->constbuf[p->type], PIPE_BUFFER_USAGE_CPU_READ); - nv50_program_upload_data(nv50, map, p->data->start, - p->param_nr); + if (p->type == PIPE_SHADER_FRAGMENT) + cbuf = NV50_CB_PFP; + nv50_program_upload_data(nv50, map, p->data[1]->start, + p->param_nr, cbuf); ws->buffer_unmap(ws, nv50->constbuf[p->type]); } - - if (p->immd_nr) { - nv50_program_upload_data(nv50, p->immd, - p->data->start + p->param_nr, - p->immd_nr); - } } static void @@ -2173,20 +2177,27 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) upload = TRUE; } - if (p->data && p->data->start != p->data_start) { + if ((p->data[0] && p->data[0]->start != p->data_start[0]) || + (p->data[1] && p->data[1]->start != p->data_start[1])) { for (e = p->exec_head; e; e = e->next) { - unsigned ei, ci; + unsigned ei, ci, bs; if (e->param.index < 0) continue; + bs = (e->inst[1] >> 22) & 0x07; + assert(bs < 2); ei = e->param.shift >> 5; - ci = e->param.index + p->data->start; + ci = e->param.index + p->data[bs]->start; e->inst[ei] &= ~e->param.mask; e->inst[ei] |= (ci << e->param.shift); } - p->data_start = p->data->start; + if (p->data[0]) + p->data_start[0] = p->data[0]->start; + if (p->data[1]) + p->data_start[1] = p->data[1]->start; + upload = TRUE; } @@ -2341,7 +2352,8 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) if (p->buffer) pipe_buffer_reference(&p->buffer, NULL); - nv50->screen->nvws->res_free(&p->data); + nv50->screen->nvws->res_free(&p->data[0]); + nv50->screen->nvws->res_free(&p->data[1]); p->translated = 0; } diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h index b3240b36ef..c650ecfc81 100644 --- a/src/gallium/drivers/nv50/nv50_program.h +++ b/src/gallium/drivers/nv50/nv50_program.h @@ -24,8 +24,8 @@ struct nv50_program { struct nv50_program_exec *exec_head; struct nv50_program_exec *exec_tail; unsigned exec_size; - struct nouveau_resource *data; - unsigned data_start; + struct nouveau_resource *data[2]; + unsigned data_start[2]; struct pipe_buffer *buffer; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 2980564594..a7981a3615 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -290,20 +290,62 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->tesla, 0x16b8, 1); so_data (so, 8); - /* Shared constant buffer */ - screen->constbuf = screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); - if (nvws->res_init(&screen->vp_data_heap, 0, 128)) { - NOUVEAU_ERR("Error initialising constant buffer\n"); + /* constant buffers for immediates and VP/FP parameters */ + screen->constbuf_misc[0] = + screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); + + screen->constbuf_parm[0] = + screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); + + screen->constbuf_parm[1] = + screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); + + if (nvws->res_init(&screen->immd_heap[0], 0, 128) || + nvws->res_init(&screen->parm_heap[0], 0, 128) || + nvws->res_init(&screen->parm_heap[1], 0, 128)) + { + NOUVEAU_ERR("Error initialising constant buffers.\n"); nv50_screen_destroy(&screen->pipe); return NULL; } + /* + // map constant buffers: + // B = buffer ID (maybe more than 1 byte) + // N = CB index used in shader instruction + // P = program type (0 = VP, 2 = GP, 3 = FP) + so_method(so, screen->tesla, 0x1694, 1); + so_data (so, 0x000BBNP1); + */ + + so_method(so, screen->tesla, 0x1280, 3); + so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM | + 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_method(so, screen->tesla, 0x1694, 1); + so_data (so, 0x00000001 | (NV50_CB_PMISC << 12)); + so_method(so, screen->tesla, 0x1694, 1); + so_data (so, 0x00000031 | (NV50_CB_PMISC << 12)); + + so_method(so, screen->tesla, 0x1280, 3); + so_reloc (so, screen->constbuf_parm[0], 0, NOUVEAU_BO_VRAM | + NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, screen->constbuf_parm[0], 0, NOUVEAU_BO_VRAM | + NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); + so_data (so, (NV50_CB_PVP << 16) | 0x00000800); + so_method(so, screen->tesla, 0x1694, 1); + so_data (so, 0x00000101 | (NV50_CB_PVP << 12)); + so_method(so, screen->tesla, 0x1280, 3); - so_reloc (so, screen->constbuf, 0, NOUVEAU_BO_VRAM | + so_reloc (so, screen->constbuf_parm[1], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf, 0, NOUVEAU_BO_VRAM | + so_reloc (so, screen->constbuf_parm[1], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PMISC << 16) | 0x00001000); + so_data (so, (NV50_CB_PFP << 16) | 0x00000800); + so_method(so, screen->tesla, 0x1694, 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 diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index db567aaac8..31b8ef29c9 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -15,8 +15,11 @@ struct nv50_screen { struct nouveau_grobj *m2mf; struct nouveau_notifier *sync; - struct pipe_buffer *constbuf; - struct nouveau_resource *vp_data_heap; + struct pipe_buffer *constbuf_misc[1]; + struct pipe_buffer *constbuf_parm[2]; + + struct nouveau_resource *immd_heap[1]; + struct nouveau_resource *parm_heap[2]; struct pipe_buffer *tic; struct pipe_buffer *tsc; -- cgit v1.2.3 From 3accd7ebe971624bed5624f73ed3522c9de4c193 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 16:14:06 +0200 Subject: nv50: fix TXP For TXP we need to divide texture coords by their w component, or use the coords' 1/w in the perspective interpolation instruction. This also tries to support 1D, 3D and CUBE textures, and lets the instruction only load the components that are used. --- src/gallium/drivers/nv50/nv50_program.c | 135 ++++++++++++++++++++++++++------ 1 file changed, 112 insertions(+), 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 6c07fbfe0c..e038031f57 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -967,6 +967,113 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src) emit(pc, e); } +static void +emit_tex(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, + struct nv50_reg **src, unsigned unit, unsigned type, boolean proj) +{ + struct nv50_reg *temp, *t[4]; + struct nv50_program_exec *e; + + unsigned c, mode, dim; + + switch (type) { + case TGSI_TEXTURE_1D: + dim = 1; + break; + case TGSI_TEXTURE_UNKNOWN: + case TGSI_TEXTURE_2D: + case TGSI_TEXTURE_SHADOW1D: /* XXX: x, z */ + case TGSI_TEXTURE_RECT: + dim = 2; + break; + case TGSI_TEXTURE_3D: + case TGSI_TEXTURE_CUBE: + case TGSI_TEXTURE_SHADOW2D: + case TGSI_TEXTURE_SHADOWRECT: /* XXX */ + dim = 3; + break; + default: + assert(0); + break; + } + + alloc_temp4(pc, t, 0); + + if (proj) { + if (src[0]->type == P_TEMP && src[0]->rhw != -1) { + mode = pc->interp_mode[src[0]->index]; + + t[3]->rhw = src[3]->rhw; + emit_interp(pc, t[3], NULL, (mode & INTERP_CENTROID)); + emit_flop(pc, 0, t[3], t[3]); + + for (c = 0; c < dim; c++) { + t[c]->rhw = src[c]->rhw; + emit_interp(pc, t[c], t[3], + (mode | INTERP_PERSPECTIVE)); + } + } else { + emit_flop(pc, 0, t[3], src[3]); + for (c = 0; c < dim; c++) + emit_mul(pc, t[c], src[c], t[3]); + + /* XXX: for some reason the blob sometimes uses MAD: + * emit_mad(pc, t[c], src[0][c], t[3], t[3]) + * pc->p->exec_tail->inst[1] |= 0x080fc000; + */ + } + } else { + if (type == TGSI_TEXTURE_CUBE) { + temp = temp_temp(pc); + emit_minmax(pc, 4, temp, src[0], src[1]); + emit_minmax(pc, 4, temp, temp, src[2]); + emit_flop(pc, 0, temp, temp); + for (c = 0; c < 3; c++) + emit_mul(pc, t[c], src[c], temp); + } else { + for (c = 0; c < dim; c++) + emit_mov(pc, t[c], src[c]); + } + } + + e = exec(pc); + set_long(pc, e); + e->inst[0] |= 0xf0000000; + e->inst[1] |= 0x00000004; + set_dst(pc, t[0], e); + e->inst[0] |= (unit << 9); + + if (dim == 2) + e->inst[0] |= 0x00400000; + else + if (dim == 3) + e->inst[0] |= 0x00800000; + + e->inst[0] |= (mask & 0x3) << 25; + e->inst[1] |= (mask & 0xc) << 12; + + emit(pc, e); + +#if 1 + if (mask & 1) emit_mov(pc, dst[0], t[0]); + if (mask & 2) emit_mov(pc, dst[1], t[1]); + if (mask & 4) emit_mov(pc, dst[2], t[2]); + if (mask & 8) emit_mov(pc, dst[3], t[3]); + + free_temp4(pc, t); +#else + /* XXX: if p.e. MUL is used directly after TEX, it would still use + * the texture coordinates, not the fetched values: latency ? */ + + for (c = 0; c < 4; c++) { + if (mask & (1 << c)) + assimilate_temp(pc, dst[c], t[c]); + else + free_temp(pc, t[c]); + } +#endif +} + static void convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e) { @@ -1422,30 +1529,12 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) } break; case TGSI_OPCODE_TEX: + emit_tex(pc, dst, mask, src[0], unit, + inst->InstructionExtTexture.Texture, FALSE); + break; case TGSI_OPCODE_TXP: - { - struct nv50_reg *t[4]; - struct nv50_program_exec *e; - - alloc_temp4(pc, t, 0); - emit_mov(pc, t[0], src[0][0]); - emit_mov(pc, t[1], src[0][1]); - - e = exec(pc); - e->inst[0] = 0xf6400000; - e->inst[0] |= (unit << 9); - set_long(pc, e); - e->inst[1] |= 0x0000c004; - set_dst(pc, t[0], e); - emit(pc, e); - - if (mask & (1 << 0)) emit_mov(pc, dst[0], t[0]); - if (mask & (1 << 1)) emit_mov(pc, dst[1], t[1]); - if (mask & (1 << 2)) emit_mov(pc, dst[2], t[2]); - if (mask & (1 << 3)) emit_mov(pc, dst[3], t[3]); - - free_temp4(pc, t); - } + emit_tex(pc, dst, mask, src[0], unit, + inst->InstructionExtTexture.Texture, TRUE); break; case TGSI_OPCODE_XPD: temp = temp_temp(pc); -- cgit v1.2.3 From 87eea6e2b2df57bddb7155df794f02143e1ece40 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 May 2009 16:14:37 +0200 Subject: nv50: introduce emit_cvt and use it This makes some code cleaner, and we can now easily do CEIL and TRUNC. --- src/gallium/drivers/nv50/nv50_program.c | 88 ++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 40 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index e038031f57..89051069bc 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -783,6 +783,48 @@ emit_precossin(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) emit(pc, e); } +#define CVTOP_RN 0x01 +#define CVTOP_FLOOR 0x03 +#define CVTOP_CEIL 0x05 +#define CVTOP_TRUNC 0x07 +#define CVTOP_SAT 0x08 +#define CVTOP_ABS 0x10 + +#define CVT_F32_F32 0xc4 +#define CVT_F32_S32 0x44 +#define CVT_F32_U32 0x64 +#define CVT_S32_F32 0x8c +#define CVT_S32_S32 0x0c +#define CVT_F32_F32_ROP 0xcc + +static void +emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src, + int wp, unsigned cop, unsigned fmt) +{ + struct nv50_program_exec *e; + + e = exec(pc); + set_long(pc, e); + + e->inst[0] |= 0xa0000000; + e->inst[1] |= 0x00004000; + e->inst[1] |= (cop << 16); + e->inst[1] |= (fmt << 24); + set_src_0(pc, src, e); + + if (wp >= 0) + set_pred_wr(pc, 1, wp, e); + + if (dst) + set_dst(pc, dst, e); + else { + e->inst[0] |= 0x000001fc; + e->inst[1] |= 0x00000008; + } + + emit(pc, e); +} + static void emit_set(struct nv50_pc *pc, unsigned c_op, struct nv50_reg *dst, struct nv50_reg *src0, struct nv50_reg *src1) @@ -826,22 +868,10 @@ emit_set(struct nv50_pc *pc, unsigned c_op, struct nv50_reg *dst, free_temp(pc, dst); } -static void +static INLINE void emit_flr(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) { - struct nv50_program_exec *e = exec(pc); - - e->inst[0] = 0xa0000000; /* cvt */ - set_long(pc, e); - e->inst[1] |= (6 << 29); /* cvt */ - e->inst[1] |= 0x08000000; /* integer mode */ - e->inst[1] |= 0x04000000; /* 32 bit */ - e->inst[1] |= ((0x1 << 3)) << 14; /* .rn */ - 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_FLOOR, CVT_F32_F32_ROP); } static void @@ -858,21 +888,10 @@ emit_pow(struct nv50_pc *pc, struct nv50_reg *dst, free_temp(pc, temp); } -static void +static INLINE void emit_abs(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) { - struct nv50_program_exec *e = exec(pc); - - e->inst[0] = 0xa0000000; /* cvt */ - set_long(pc, e); - e->inst[1] |= (6 << 29); /* cvt */ - e->inst[1] |= 0x04000000; /* 32 bit */ - e->inst[1] |= (1 << 14); /* src .f32 */ - e->inst[1] |= ((1 << 6) << 14); /* .abs */ - set_dst(pc, dst, e); - set_src_0(pc, src, e); - - emit(pc, e); + emit_cvt(pc, dst, src, -1, CVTOP_ABS, CVT_F32_F32); } static void @@ -1562,21 +1581,10 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) if (sat) { for (c = 0; c < 4; c++) { - struct nv50_program_exec *e; - if (!(mask & (1 << c))) continue; - e = exec(pc); - - e->inst[0] = 0xa0000000; /* cvt */ - set_long(pc, e); - e->inst[1] |= (6 << 29); /* cvt */ - e->inst[1] |= 0x04000000; /* 32 bit */ - e->inst[1] |= (1 << 14); /* src .f32 */ - e->inst[1] |= ((1 << 5) << 14); /* .sat */ - set_dst(pc, rdst[c], e); - set_src_0(pc, dst[c], e); - emit(pc, e); + emit_cvt(pc, rdst[c], dst[c], -1, CVTOP_SAT, + CVT_F32_F32); } } else if (assimilate) { for (c = 0; c < 4; c++) -- cgit v1.2.3 From c11c107f7d8f289f0cb83968c265fb78a274024a Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 28 May 2009 00:17:14 +0200 Subject: nv50: negate sources directly where supported --- src/gallium/drivers/nv50/nv50_program.c | 110 ++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 42 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 89051069bc..aada285f2c 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -409,7 +409,8 @@ set_dst(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_program_exec *e) static INLINE void set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) { - unsigned val = fui(pc->immd_buf[imm->hw]); + float f = pc->immd_buf[imm->hw]; + unsigned val = fui(imm->neg ? -f : f); set_long(pc, e); /*XXX: can't be predicated - bits overlap.. catch cases where both @@ -627,10 +628,19 @@ emit_mul(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, check_swap_src_0_1(pc, &src0, &src1); set_dst(pc, dst, e); set_src_0(pc, src0, e); - if (src1->type == P_IMMD && !is_long(e)) + if (src1->type == P_IMMD && !is_long(e)) { + if (src0->neg) + e->inst[0] |= 0x00008000; set_immd(pc, src1, e); - else + } else { set_src_1(pc, src1, e); + if (src0->neg ^ src1->neg) { + if (is_long(e)) + e->inst[1] |= 0x08000000; + else + e->inst[0] |= 0x00008000; + } + } emit(pc, e); } @@ -643,13 +653,16 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst, e->inst[0] |= 0xb0000000; - if (!pc->allow32) + check_swap_src_0_1(pc, &src0, &src1); + + if (!pc->allow32 || src0->neg || src1->neg) { set_long(pc, e); + e->inst[1] |= (src0->neg << 26) | (src1->neg << 27); + } - check_swap_src_0_1(pc, &src0, &src1); set_dst(pc, dst, e); set_src_0(pc, src0, e); - if (is_long(e) || src1->type == P_CONST || src1->type == P_ATTR) + if (src1->type == P_CONST || src1->type == P_ATTR || is_long(e)) set_src_2(pc, src1, e); else if (src1->type == P_IMMD) @@ -678,25 +691,13 @@ emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst, emit(pc, e); } -static void +static INLINE void emit_sub(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, struct nv50_reg *src1) { - struct nv50_program_exec *e = exec(pc); - - e->inst[0] |= 0xb0000000; - - set_long(pc, e); - if (check_swap_src_0_1(pc, &src0, &src1)) - e->inst[1] |= 0x04000000; - else - e->inst[1] |= 0x08000000; - - set_dst(pc, dst, e); - set_src_0(pc, src0, e); - set_src_2(pc, src1, e); - - emit(pc, e); + src1->neg ^= 1; + emit_add(pc, dst, src0, src1); + src1->neg ^= 1; } static void @@ -713,26 +714,21 @@ emit_mad(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, set_src_1(pc, src1, e); set_src_2(pc, src2, e); + if (src0->neg ^ src1->neg) + e->inst[1] |= 0x04000000; + if (src2->neg) + e->inst[1] |= 0x08000000; + emit(pc, e); } -static void +static INLINE void emit_msb(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0, struct nv50_reg *src1, struct nv50_reg *src2) { - struct nv50_program_exec *e = exec(pc); - - e->inst[0] |= 0xe0000000; - set_long(pc, e); - e->inst[1] |= 0x08000000; /* src0 * src1 - src2 */ - - check_swap_src_0_1(pc, &src0, &src1); - set_dst(pc, dst, e); - set_src_0(pc, src0, e); - set_src_1(pc, src1, e); - set_src_2(pc, src2, e); - - emit(pc, e); + src2->neg ^= 1; + emit_mad(pc, dst, src0, src1, src2); + src2->neg ^= 1; } static void @@ -976,6 +972,8 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src) 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); /* This is probably KILP */ @@ -1141,6 +1139,25 @@ convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e) e->inst[1] |= q; } +static boolean +negate_supported(const struct tgsi_full_instruction *insn, int i) +{ + switch (insn->Instruction.Opcode) { + case TGSI_OPCODE_DP3: + case TGSI_OPCODE_DP4: + case TGSI_OPCODE_MUL: + case TGSI_OPCODE_KIL: + case TGSI_OPCODE_ADD: + case TGSI_OPCODE_SUB: + case TGSI_OPCODE_MAD: + return TRUE; + case TGSI_OPCODE_POW: + return (i == 1) ? TRUE : FALSE; + default: + return FALSE; + } +} + static struct nv50_reg * tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst) { @@ -1159,7 +1176,8 @@ tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst) } static struct nv50_reg * -tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src) +tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src, + boolean neg) { struct nv50_reg *r = NULL; struct nv50_reg *temp; @@ -1214,14 +1232,21 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src) r = temp; break; case TGSI_UTIL_SIGN_TOGGLE: - temp = temp_temp(pc); - emit_neg(pc, temp, r); - r = temp; + if (neg) + r->neg = 1; + else { + temp = temp_temp(pc); + emit_neg(pc, temp, r); + r = temp; + } break; case TGSI_UTIL_SIGN_SET: temp = temp_temp(pc); emit_abs(pc, temp, r); - emit_neg(pc, temp, temp); + if (neg) + temp->neg = 1; + else + emit_neg(pc, temp, temp); r = temp; break; default: @@ -1289,7 +1314,8 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok) unit = fs->SrcRegister.Index; for (c = 0; c < 4; c++) - src[i][c] = tgsi_src(pc, c, fs); + src[i][c] = tgsi_src(pc, c, fs, + negate_supported(inst, i)); } if (sat) { -- cgit v1.2.3 From 534f1e8f022ea7408c2ad49013e8f2446aa16364 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 28 May 2009 15:47:54 +1000 Subject: nv50: some mipmapping fixes --- src/gallium/drivers/nv50/nv50_state.c | 9 +++++++- src/gallium/drivers/nv50/nv50_surface.c | 2 +- src/gallium/drivers/nv50/nv50_tex.c | 6 +++--- src/gallium/drivers/nv50/nv50_transfer.c | 36 +++++++++++++++++--------------- 4 files changed, 31 insertions(+), 22 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index ba852194cd..9d41ef55b0 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -137,8 +137,9 @@ nv50_sampler_state_create(struct pipe_context *pipe, const struct pipe_sampler_state *cso) { unsigned *tsc = CALLOC(8, sizeof(unsigned)); + float limit; - tsc[0] = (0x00024000 | + tsc[0] = (0x00026000 | (wrap_mode(cso->wrap_s) << 0) | (wrap_mode(cso->wrap_t) << 3) | (wrap_mode(cso->wrap_r) << 6)); @@ -202,6 +203,12 @@ nv50_sampler_state_create(struct pipe_context *pipe, tsc[0] |= (nvgl_comparison_op(cso->compare_func) & 0x7); } + limit = CLAMP(cso->lod_bias, -16.0, 15.0); + tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 11; + + tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) | + ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8); + return (void *)tsc; } diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 0cc5168144..c0f0efe158 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -57,7 +57,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) struct nouveau_bo *bo; int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); - + bo = screen->nvws->get_bo(nv50_miptree(ps->texture)->buffer); if (!bo) return 1; diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 223c8a3a45..775e9f30ef 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -122,10 +122,10 @@ nv50_tex_construct(struct nouveau_stateobj *so, struct nv50_miptree *mt) so_data (so, 0xd0005000); so_data (so, 0x00300000); so_data (so, mt->base.width[0]); - so_data (so, (mt->base.depth[0] << 16) | mt->base.height[0]); + so_data (so, (mt->base.last_level << 28) | + (mt->base.depth[0] << 16) | mt->base.height[0]); so_data (so, 0x03000000); - so_reloc(so, mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH | - NOUVEAU_BO_RD, 0, 0); + so_data (so, mt->base.last_level << 4); return 0; } diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 747195b4f6..28e7edd144 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -7,7 +7,7 @@ struct nv50_transfer { struct pipe_transfer base; struct pipe_buffer *buffer; - struct nv50_miptree_level *level; + unsigned level_offset; int level_pitch; int level_width; int level_height; @@ -17,8 +17,9 @@ struct nv50_transfer { static void nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, - int src_pitch, int sx, int sy, int sw, int sh, - struct pipe_buffer *dst, int dst_pitch, int dx, int dy, + unsigned src_offset, int src_pitch, int sx, int sy, + int sw, int sh, struct pipe_buffer *dst, + unsigned dst_offset, int dst_pitch, int dx, int dy, int dw, int dh, int cpp, int width, int height, unsigned src_reloc, unsigned dst_reloc) { @@ -28,7 +29,6 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, struct nouveau_grobj *m2mf = screen->m2mf; struct nouveau_bo *src_bo = nvws->get_bo(src); struct nouveau_bo *dst_bo = nvws->get_bo(dst); - unsigned src_offset = 0, dst_offset = 0; src_reloc |= NOUVEAU_BO_RD; dst_reloc |= NOUVEAU_BO_WR; @@ -40,7 +40,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, OUT_RING (chan, 1); BEGIN_RING(chan, m2mf, 0x0314, 1); OUT_RING (chan, src_pitch); - src_offset = (sy * src_pitch) + (sx * cpp); + src_offset += (sy * src_pitch) + (sx * cpp); } else { BEGIN_RING(chan, m2mf, 0x0200, 6); OUT_RING (chan, 0); @@ -56,7 +56,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, OUT_RING (chan, 1); BEGIN_RING(chan, m2mf, 0x0318, 1); OUT_RING (chan, dst_pitch); - dst_offset = (dy * dst_pitch) + (dx * cpp); + dst_offset += (dy * dst_pitch) + (dx * cpp); } else { BEGIN_RING(chan, m2mf, 0x021c, 6); OUT_RING (chan, 0); @@ -133,10 +133,10 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, tx->base.stride = (w * pt->block.size); tx->base.usage = usage; - tx->level = lvl; tx->level_pitch = lvl->pitch; tx->level_width = mt->base.width[level]; tx->level_height = mt->base.height[level]; + tx->level_offset = lvl->image_offset[image]; tx->level_x = x; tx->level_y = y; tx->buffer = @@ -144,9 +144,10 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, w * tx->base.block.size * h); if (usage != PIPE_TRANSFER_WRITE) { - nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_pitch, - x, y, tx->level_width, tx->level_height, - tx->buffer, tx->base.stride, 0, 0, + nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_offset, + tx->level_pitch, x, y, tx->level_width, + tx->level_height, tx->buffer, 0, + tx->base.stride, 0, 0, tx->base.width, tx->base.height, tx->base.block.size, w, h, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART, @@ -164,14 +165,15 @@ nv50_transfer_del(struct pipe_transfer *ptx) if (ptx->usage != PIPE_TRANSFER_READ) { struct pipe_screen *pscreen = ptx->texture->screen; - nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride, + nv50_transfer_rect_m2mf(pscreen, tx->buffer, 0, tx->base.stride, 0, 0, tx->base.width, tx->base.height, - mt->buffer, tx->level_pitch, - tx->level_x, tx->level_y, - tx->level_width, tx->level_height, - tx->base.block.size, tx->base.width, - tx->base.height, NOUVEAU_BO_GART, - NOUVEAU_BO_VRAM | NOUVEAU_BO_GART); + mt->buffer, tx->level_offset, + tx->level_pitch, tx->level_x, + tx->level_y, tx->level_width, + tx->level_height, tx->base.block.size, + tx->base.width, tx->base.height, + NOUVEAU_BO_GART, NOUVEAU_BO_VRAM | + NOUVEAU_BO_GART); } pipe_buffer_reference(&tx->buffer, NULL); -- cgit v1.2.3 From b70fcd620d69850c6e19213d84ae4584e77ab689 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 May 2009 07:46:34 -0700 Subject: r300-gallium, radeon-gallium: Make add_buffer indicate when a flush is needed. On a side note, why is RADEON_MAX_BOS 24? Should ask airlied about that. --- src/gallium/drivers/r300/r300_emit.c | 28 +++++++++++++++++------- src/gallium/drivers/r300/r300_surface.c | 21 +++++++++++++----- src/gallium/drivers/r300/r300_winsys.h | 8 +++---- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 16 +++++++++----- 4 files changed, 50 insertions(+), 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 5e4b179505..caeb73a8ed 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -467,27 +467,39 @@ validate: for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture; assert(tex && tex->buffer && "cbuf is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } /* ...depth buffer... */ if (r300->framebuffer_state.zsbuf) { tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture; assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } /* ...textures... */ for (i = 0; i < r300->texture_count; i++) { tex = r300->textures[i]; assert(tex && tex->buffer && "texture is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); + 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); + goto validate; + } } /* ...and vertex buffer. */ if (r300->vbo) { - r300->winsys->add_buffer(r300->winsys, r300->vbo, - RADEON_GEM_DOMAIN_GTT, 0); + if (!r300->winsys->add_buffer(r300->winsys, r300->vbo, + RADEON_GEM_DOMAIN_GTT, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } else { debug_printf("No VBO while emitting dirty state!\n"); } diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 7711e8f569..c9e2dff14e 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -120,8 +120,11 @@ fallback: /* Make sure our target BO is okay. */ validate: - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + 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) { @@ -242,10 +245,16 @@ fallback: /* Add our target BOs to the list. */ validate: - r300->winsys->add_buffer(r300->winsys, srctex->buffer, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); - r300->winsys->add_buffer(r300->winsys, desttex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + 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) { diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index a5ced8041c..d2893c3b9d 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -52,10 +52,10 @@ struct r300_winsys { uint32_t vram_size; /* Add a pipe_buffer to the list of buffer objects to validate. */ - void (*add_buffer)(struct r300_winsys* winsys, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd); + boolean (*add_buffer)(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd); /* Revalidate all currently setup pipe_buffers. * Returns TRUE if a flush is required. */ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 995bf6aa22..63aa3179ac 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,10 +22,10 @@ #include "radeon_r300.h" -static void radeon_r300_add_buffer(struct r300_winsys* winsys, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd) +static boolean radeon_r300_add_buffer(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd) { int i; struct radeon_winsys_priv* priv = @@ -35,7 +35,6 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, /* Check to see if this BO is already in line for validation; * find a slot for it otherwise. */ - assert(priv->bo_count <= RADEON_MAX_BOS); for (i = 0; i < priv->bo_count; i++) { if (sc[i].bo == bo) { sc[i].read_domains |= rd; @@ -44,10 +43,17 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, } } + if (priv->bo_count >= RADEON_MAX_BOS) { + /* Dohoho. Not falling for that one again. Request a flush. */ + return FALSE; + } + sc[priv->bo_count].bo = bo; sc[priv->bo_count].read_domains = rd; sc[priv->bo_count].write_domain = wd; priv->bo_count++; + + return TRUE; } static boolean radeon_r300_validate(struct r300_winsys* winsys) -- cgit v1.2.3 From 425c39058b54ebbde4130e4eebb1c302005ba6ac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 May 2009 00:55:54 -0600 Subject: softpipe: increase max 2D/cube texture size to 4K x 4K --- src/gallium/drivers/softpipe/sp_screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index a32fd3a1ba..4ead6c928c 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -82,11 +82,11 @@ softpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 12; /* max 2Kx2K */ + return 13; /* max 2Kx2K */ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: return 8; /* max 128x128x128 */ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 12; /* max 2Kx2K */ + return 13; /* max 2Kx2K */ default: return 0; } -- cgit v1.2.3 From fa0ca31586f2523ac65dbf9c1fdca99dfbca7456 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 May 2009 08:22:21 -0600 Subject: softpipe: update comments for max texture size --- src/gallium/drivers/softpipe/sp_screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 4ead6c928c..ce6d8ebd12 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -82,11 +82,11 @@ softpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 13; /* max 2Kx2K */ + return 13; /* max 4Kx4K */ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: return 8; /* max 128x128x128 */ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 13; /* max 2Kx2K */ + return 13; /* max 4Kx4K */ default: return 0; } -- cgit v1.2.3 From a59575d8fbe8b0ca053cc8366ce7a42bc660158a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 30 May 2009 20:07:18 -0600 Subject: softpipe: fix incorrect provoking vertex color for PIPE_PRIM_POLYGON This fixes the incorrect colors seen when rendering flat-shaded polygons. Note that clipped polygons were correct, but unclipped polygons were wrong. See the glean/clipFlat test for regression testing. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index eef6e5806c..329c92b8da 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -378,7 +378,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, get_vert(vertex_buffer, 0, stride), @@ -386,6 +385,7 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) get_vert(vertex_buffer, i-0, stride)); } break; + case PIPE_PRIM_QUADS: for (i = 3; i < nr; i += 4) { setup_tri( setup_ctx, @@ -412,6 +412,20 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) get_vert(vertex_buffer, i-0, stride)); } break; + + case PIPE_PRIM_POLYGON: + /* Almost same as tri fan but the _first_ vertex specifies the flat + * shading color. Note that the first polygon vertex is passed as + * the last triangle vertex here. + */ + for (i = 2; i < nr; i += 1) { + setup_tri( setup_ctx, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, 0, stride)); + } + break; + default: assert(0); } -- cgit v1.2.3 From 6c3cefdda6c98d5f0df874c7f1d8c5421cc8468b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 30 May 2009 20:09:19 -0600 Subject: Revert "softpipe: fix flat shading provoking vertex for PIPE_PRIM_POLYGON" This reverts commit 5d75124db480b37977c353511b4e228905b7cc95. This fixed unclipped polygons, but broke clipped polygons. A better fix from the mesa 7.5 branch will be merged next... --- src/gallium/drivers/softpipe/sp_context.h | 1 - src/gallium/drivers/softpipe/sp_draw_arrays.c | 1 - src/gallium/drivers/softpipe/sp_setup.c | 5 +---- 3 files changed, 1 insertion(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 2f90d538a5..b89a7292e5 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -107,7 +107,6 @@ struct softpipe_context { /** Which vertex shader output slot contains point size */ int psize_slot; - unsigned api_prim; /**< current prim type being drawn: PIPE_PRIM_x */ unsigned reduced_api_prim; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */ /** Derived from scissor and surface bounds: */ diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 1460bc4b4b..f117096bf7 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -129,7 +129,6 @@ softpipe_draw_range_elements(struct pipe_context *pipe, struct draw_context *draw = sp->draw; unsigned i; - sp->api_prim = mode; sp->reduced_api_prim = reduced_prim[mode]; if (sp->dirty) diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 4f0baa3fd4..c6844a2649 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -514,10 +514,7 @@ static boolean setup_sort_vertices( struct setup_context *setup, const float (*v1)[4], const float (*v2)[4] ) { - if (setup->softpipe->api_prim == PIPE_PRIM_POLYGON) - setup->vprovoke = v0; - else - setup->vprovoke = v2; + setup->vprovoke = v2; /* determine bottom to top order of vertices */ { -- cgit v1.2.3 From 1124f786c1a839036cc1b17f9398eead9f16b1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 30 May 2009 14:33:11 -0700 Subject: wgl: Remove unused field. --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 - src/gallium/state_trackers/wgl/shared/stw_context.h | 1 - 2 files changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index dd97e48b14..09dba61603 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -128,7 +128,6 @@ stw_create_layer_context( goto no_ctx; ctx->hdc = hdc; - ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL ); /* Create visual based on flags */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index e276737e85..92df7e6136 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -38,7 +38,6 @@ struct stw_context struct st_context *st; UINT_PTR hglrc; HDC hdc; - DWORD color_bits; const struct stw_pixelformat_info *pfi; }; -- cgit v1.2.3 From 76f2bacb07b1b55a50018a1ccee42943d5e8a477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 30 May 2009 18:00:18 -0700 Subject: wgl: Rename function. --- src/gallium/state_trackers/wgl/shared/stw_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index eef848988c..ada2511581 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -57,7 +57,7 @@ struct stw_device *stw_dev = NULL; * stw_winsys::flush_front_buffer. */ static void -st_flush_frontbuffer(struct pipe_screen *screen, +stw_flush_frontbuffer(struct pipe_screen *screen, struct pipe_surface *surface, void *context_private ) { @@ -111,7 +111,7 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->screen = screen; #endif - stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer; + stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer; pipe_mutex_init( stw_dev->mutex ); -- cgit v1.2.3 From be7c56be06183239008b168181aa6f1c78591579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 30 May 2009 19:51:33 -0700 Subject: wgl: Fix debugging output. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 36 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 62af765211..347f40aa06 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -54,7 +54,15 @@ DrvCreateLayerContext( HDC hdc, INT iLayerPlane ) { - return stw_create_layer_context( hdc, iLayerPlane ); + DHGLRC r; + + r = stw_create_layer_context( hdc, iLayerPlane ); + + if (DBG) + debug_printf( "%s( %p, %i ) = %u\n", + __FUNCTION__, hdc, iLayerPlane, r ); + + return r; } DHGLRC APIENTRY @@ -68,7 +76,15 @@ BOOL APIENTRY DrvDeleteContext( DHGLRC dhglrc ) { - return stw_delete_context( dhglrc ); + BOOL r; + + r = stw_delete_context( dhglrc ); + + if (DBG) + debug_printf( "%s( %u ) = %u\n", + __FUNCTION__, dhglrc, r ); + + return r; } BOOL APIENTRY @@ -126,7 +142,7 @@ DrvGetProcAddress( r = stw_get_proc_address( lpszProc ); if (DBG) - debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r ); + debug_printf( "%s( \"%s\" ) = %p\n", __FUNCTION__, lpszProc, r ); return r; } @@ -515,14 +531,16 @@ DrvSetContext( DHGLRC dhglrc, PFN_SETPROCTABLE pfnSetProcTable ) { - if (DBG) - debug_printf( "%s( 0x%p, %u, 0x%p )\n", - __FUNCTION__, hdc, dhglrc, pfnSetProcTable ); - + PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt; + if (!stw_make_current( hdc, dhglrc )) - return NULL; + r = NULL; - return (GLCLTPROCTABLE *)&cpt; + if (DBG) + debug_printf( "%s( 0x%p, %u, 0x%p ) = %p\n", + __FUNCTION__, hdc, dhglrc, pfnSetProcTable, r ); + + return r; } int APIENTRY -- cgit v1.2.3 From fe69b6bdc7bbde2cefec856ff338788d7be20f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 30 May 2009 19:58:50 -0700 Subject: wgl: Use the right pixel format. There is no current pixel format. Each HDC has its pixelformat which is kept by gdi and set/get via the SetPixelFormat/GetPixelFormat functions. Now the HDC's pixelformat is kept in the stw_framebuffer, which is created during the SetPixelFormat. --- .../state_trackers/wgl/shared/stw_context.c | 176 ++++++---------- .../state_trackers/wgl/shared/stw_context.h | 3 +- src/gallium/state_trackers/wgl/shared/stw_device.c | 2 + .../state_trackers/wgl/shared/stw_framebuffer.c | 223 +++++++++++++++++---- .../state_trackers/wgl/shared/stw_framebuffer.h | 26 ++- .../state_trackers/wgl/shared/stw_pixelformat.c | 65 +++--- .../state_trackers/wgl/shared/stw_pixelformat.h | 5 + src/gallium/state_trackers/wgl/shared/stw_tls.c | 2 - src/gallium/state_trackers/wgl/shared/stw_tls.h | 1 - 9 files changed, 301 insertions(+), 202 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 09dba61603..662b5fbcd2 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -90,7 +90,7 @@ stw_share_lists( ctx2 = stw_lookup_context_locked( hglrc2 ); if (ctx1 && ctx2 && - ctx1->pfi == ctx2->pfi) { + ctx1->iPixelFormat == ctx2->iPixelFormat) { ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx); } @@ -104,51 +104,32 @@ stw_create_layer_context( HDC hdc, int iLayerPlane ) { - uint pfi; - const struct stw_pixelformat_info *pf = NULL; + int iPixelFormat; + const struct stw_pixelformat_info *pfi; + GLvisual visual; struct stw_context *ctx = NULL; - GLvisual *visual = NULL; struct pipe_screen *screen = NULL; struct pipe_context *pipe = NULL; - + if(!stw_dev) return 0; if (iLayerPlane != 0) return 0; - pfi = stw_pixelformat_get( hdc ); - if (pfi == 0) + iPixelFormat = GetPixelFormat(hdc); + if(!iPixelFormat) return 0; - - pf = stw_pixelformat_get_info( pfi - 1 ); - + + pfi = stw_pixelformat_get_info( iPixelFormat - 1 ); + stw_pixelformat_visual(&visual, pfi); + ctx = CALLOC_STRUCT( stw_context ); if (ctx == NULL) goto no_ctx; ctx->hdc = hdc; - - /* Create visual based on flags - */ - visual = _mesa_create_visual( - (pf->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE, - (pf->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE, - (pf->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE, - pf->pfd.cRedBits, - pf->pfd.cGreenBits, - pf->pfd.cBlueBits, - pf->pfd.cAlphaBits, - (pf->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pf->pfd.cColorBits : 0, - pf->pfd.cDepthBits, - pf->pfd.cStencilBits, - pf->pfd.cAccumRedBits, - pf->pfd.cAccumGreenBits, - pf->pfd.cAccumBlueBits, - pf->pfd.cAccumAlphaBits, - pf->numSamples ); - if (visual == NULL) - goto no_visual; + ctx->iPixelFormat = iPixelFormat; screen = stw_dev->screen; @@ -168,15 +149,15 @@ stw_create_layer_context( pipe = trace_context_create(stw_dev->screen, pipe); #endif + /* pass to stw_flush_frontbuffer as context_private */ assert(!pipe->priv); pipe->priv = hdc; - ctx->st = st_create_context( pipe, visual, NULL ); + ctx->st = st_create_context( pipe, &visual, NULL ); if (ctx->st == NULL) goto no_st_ctx; ctx->st->ctx->DriverCtx = ctx; - ctx->pfi = pf; pipe_mutex_lock( stw_dev->mutex ); ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx); @@ -192,9 +173,7 @@ no_hglrc: no_st_ctx: pipe->destroy( pipe ); no_pipe: - _mesa_destroy_visual( visual ); -no_visual: - FREE( ctx ); + FREE(ctx); no_ctx: return 0; } @@ -217,20 +196,11 @@ stw_delete_context( if (ctx) { GLcontext *glctx = ctx->st->ctx; GET_CURRENT_CONTEXT( glcurctx ); - struct stw_framebuffer *fb; - /* Unbind current if deleting current context. - */ + /* Unbind current if deleting current context. */ if (glcurctx == glctx) st_make_current( NULL, NULL, NULL ); - fb = stw_framebuffer_from_hdc( ctx->hdc ); - if (fb) - stw_framebuffer_destroy( fb ); - - if (WindowFromDC( ctx->hdc ) != NULL) - ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc ); - st_destroy_context(ctx->st); FREE(ctx); @@ -274,34 +244,6 @@ stw_release_context( return TRUE; } -/* Find the width and height of the window named by hdc. - */ -static void -stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight ) -{ - GLuint width, height; - HWND hwnd; - - hwnd = WindowFromDC( hdc ); - if (hwnd) { - RECT rect; - GetClientRect( hwnd, &rect ); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - } - else { - width = GetDeviceCaps( hdc, HORZRES ); - height = GetDeviceCaps( hdc, VERTRES ); - } - - if(width < 1) - width = 1; - if(height < 1) - height = 1; - - *pwidth = width; - *pheight = height; -} UINT_PTR stw_get_current_context( void ) @@ -345,64 +287,68 @@ stw_make_current( struct stw_context *ctx; GET_CURRENT_CONTEXT( glcurctx ); struct stw_framebuffer *fb; - GLuint width = 0; - GLuint height = 0; - struct stw_context *curctx = NULL; if (!stw_dev) - return FALSE; - - pipe_mutex_lock( stw_dev->mutex ); - ctx = stw_lookup_context_locked( hglrc ); - pipe_mutex_unlock( stw_dev->mutex ); + goto fail; if (glcurctx != NULL) { + struct stw_context *curctx; curctx = (struct stw_context *) glcurctx->DriverCtx; - if (curctx != ctx) + if (curctx->hglrc != hglrc) st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + /* Return if already current. */ + if (curctx->hglrc == hglrc && curctx->hdc == hdc) + return TRUE; } if (hdc == NULL || hglrc == 0) { - st_make_current( NULL, NULL, NULL ); - return TRUE; + return st_make_current( NULL, NULL, NULL ); } - /* Return if already current. - */ - if (glcurctx != NULL) { - if (curctx != NULL && curctx == ctx && ctx->hdc == hdc) - return TRUE; - } - - fb = stw_framebuffer_from_hdc( hdc ); - - if (hdc != NULL) - stw_get_window_size( hdc, &width, &height ); + pipe_mutex_lock( stw_dev->mutex ); - /* Lazy creation of stw_framebuffers. - */ - if (fb == NULL && ctx != NULL && hdc != NULL) { - GLvisual *visual = &ctx->st->ctx->Visual; + ctx = stw_lookup_context_locked( hglrc ); + if(!ctx) + goto fail; - fb = stw_framebuffer_create( hdc, visual, ctx->pfi, width, height ); - if (fb == NULL) - return FALSE; + fb = stw_framebuffer_from_hdc_locked( hdc ); + if(!fb) { + /* Applications should call SetPixelFormat before creating a context, + * but not all do, and the opengl32 runtime seems to use a default pixel + * format in some cases, so we must create a framebuffer for those here + */ + int iPixelFormat = GetPixelFormat(hdc); + if(iPixelFormat) + fb = stw_framebuffer_create_locked( hdc, iPixelFormat ); + if(!fb) + goto fail; } + + pipe_mutex_unlock( stw_dev->mutex ); - if (ctx && fb) { - pipe_mutex_lock( fb->mutex ); - st_make_current( ctx->st, fb->stfb, fb->stfb ); - st_resize_framebuffer( fb->stfb, width, height ); - pipe_mutex_unlock( fb->mutex ); + if(fb->iPixelFormat != ctx->iPixelFormat) + goto fail; - ctx->hdc = hdc; - ctx->st->pipe->priv = hdc; - } - else { - /* Detach */ - st_make_current( NULL, NULL, NULL ); - } + /* Lazy allocation of the frame buffer */ + if(!stw_framebuffer_allocate(fb)) + goto fail; + /* Bind the new framebuffer */ + ctx->hdc = hdc; + + /* pass to stw_flush_frontbuffer as context_private */ + ctx->st->pipe->priv = hdc; + + if(!st_make_current( ctx->st, fb->stfb, fb->stfb )) + goto fail; + + stw_framebuffer_resize(fb); + return TRUE; + +fail: + st_make_current( NULL, NULL, NULL ); + return FALSE; } diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index 92df7e6136..166471de5e 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -31,14 +31,13 @@ #include struct st_context; -struct stw_pixelformat_info; struct stw_context { struct st_context *st; UINT_PTR hglrc; + int iPixelFormat; HDC hdc; - const struct stw_pixelformat_info *pfi; }; #endif /* STW_CONTEXT_H */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index ada2511581..1a6b29807d 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -173,6 +173,8 @@ stw_cleanup(void) } pipe_mutex_unlock( stw_dev->mutex ); + stw_framebuffer_cleanup(); + pipe_mutex_destroy( stw_dev->mutex ); stw_dev->screen->destroy(stw_dev->screen); diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index f66f429542..45ac3477e8 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -94,32 +94,16 @@ stw_call_window_proc( } -/* Create a new framebuffer object which will correspond to the given HDC. +/** + * Create a new framebuffer object which will correspond to the given HDC. */ struct stw_framebuffer * -stw_framebuffer_create( +stw_framebuffer_create_locked( HDC hdc, - GLvisual *visual, - const struct stw_pixelformat_info *pfi, - GLuint width, - GLuint height ) + int iPixelFormat ) { - enum pipe_format colorFormat, depthFormat, stencilFormat; struct stw_framebuffer *fb; - - colorFormat = pfi->color_format; - - assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS ); - - if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z )) - depthFormat = pfi->depth_stencil_format; - else - depthFormat = PIPE_FORMAT_NONE; - - if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S )) - stencilFormat = pfi->depth_stencil_format; - else - stencilFormat = PIPE_FORMAT_NONE; + const struct stw_pixelformat_info *pfi; fb = CALLOC_STRUCT( stw_framebuffer ); if (fb == NULL) @@ -127,31 +111,102 @@ stw_framebuffer_create( fb->hDC = hdc; fb->hWnd = WindowFromDC( hdc ); + fb->iPixelFormat = iPixelFormat; - pipe_mutex_init( fb->mutex ); + fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 ); - fb->stfb = st_create_framebuffer( - visual, - colorFormat, - depthFormat, - stencilFormat, - width, - height, - (void *) fb ); - if(!fb->stfb) { - FREE(fb); - return NULL; - } + stw_pixelformat_visual(&fb->visual, pfi); + + pipe_mutex_init( fb->mutex ); - pipe_mutex_lock( stw_dev->mutex ); fb->next = stw_dev->fb_head; stw_dev->fb_head = fb; - pipe_mutex_unlock( stw_dev->mutex ); return fb; } + +static void +stw_framebuffer_get_size( struct stw_framebuffer *fb, GLuint *pwidth, GLuint *pheight ) +{ + GLuint width, height; + + if (fb->hWnd) { + RECT rect; + GetClientRect( fb->hWnd, &rect ); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + } + else { + width = GetDeviceCaps( fb->hDC, HORZRES ); + height = GetDeviceCaps( fb->hDC, VERTRES ); + } + + if(width < 1) + width = 1; + if(height < 1) + height = 1; + + *pwidth = width; + *pheight = height; +} + + +BOOL +stw_framebuffer_allocate( + struct stw_framebuffer *fb) +{ + pipe_mutex_lock( fb->mutex ); + + if(!fb->stfb) { + const struct stw_pixelformat_info *pfi = fb->pfi; + enum pipe_format colorFormat, depthFormat, stencilFormat; + GLuint width, height; + + colorFormat = pfi->color_format; + + assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS ); + + if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z )) + depthFormat = pfi->depth_stencil_format; + else + depthFormat = PIPE_FORMAT_NONE; + + if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S )) + stencilFormat = pfi->depth_stencil_format; + else + stencilFormat = PIPE_FORMAT_NONE; + + stw_framebuffer_get_size(fb, &width, &height); + + fb->stfb = st_create_framebuffer( + &fb->visual, + colorFormat, + depthFormat, + stencilFormat, + width, + height, + (void *) fb ); + } + + pipe_mutex_unlock( fb->mutex ); + + return fb->stfb ? TRUE : FALSE; +} + + void +stw_framebuffer_resize( + struct stw_framebuffer *fb) +{ + GLuint width, height; + assert(fb->stfb); + stw_framebuffer_get_size(fb, &width, &height); + st_resize_framebuffer(fb->stfb, width, height); +} + + +static INLINE void stw_framebuffer_destroy( struct stw_framebuffer *fb ) { @@ -176,25 +231,117 @@ stw_framebuffer_destroy( FREE( fb ); } + +void +stw_framebuffer_cleanup( void ) +{ + struct stw_framebuffer *fb; + struct stw_framebuffer *next; + + pipe_mutex_lock( stw_dev->mutex ); + + fb = stw_dev->fb_head; + while (fb) { + next = fb->next; + stw_framebuffer_destroy(fb); + fb = next; + } + stw_dev->fb_head = NULL; + + pipe_mutex_unlock( stw_dev->mutex ); +} + + /** * Given an hdc, return the corresponding stw_framebuffer. */ struct stw_framebuffer * -stw_framebuffer_from_hdc( +stw_framebuffer_from_hdc_locked( HDC hdc ) { struct stw_framebuffer *fb; - pipe_mutex_lock( stw_dev->mutex ); for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next) if (fb->hDC == hdc) break; + + return fb; +} + + +/** + * Given an hdc, return the corresponding stw_framebuffer. + */ +struct stw_framebuffer * +stw_framebuffer_from_hdc( + HDC hdc ) +{ + struct stw_framebuffer *fb; + + pipe_mutex_lock( stw_dev->mutex ); + fb = stw_framebuffer_from_hdc_locked(hdc); pipe_mutex_unlock( stw_dev->mutex ); return fb; } +BOOL +stw_pixelformat_set( + HDC hdc, + int iPixelFormat ) +{ + uint count; + uint index; + struct stw_framebuffer *fb; + + index = (uint) iPixelFormat - 1; + count = stw_pixelformat_get_extended_count(); + if (index >= count) + return FALSE; + + pipe_mutex_lock( stw_dev->mutex ); + + fb = stw_framebuffer_from_hdc_locked(hdc); + if(fb) { + /* SetPixelFormat must be called only once */ + pipe_mutex_unlock( stw_dev->mutex ); + return FALSE; + } + + fb = stw_framebuffer_create_locked(hdc, iPixelFormat); + if(!fb) { + pipe_mutex_unlock( stw_dev->mutex ); + return FALSE; + } + + pipe_mutex_unlock( stw_dev->mutex ); + + /* Some applications mistakenly use the undocumented wglSetPixelFormat + * function instead of SetPixelFormat, so we call SetPixelFormat here to + * avoid opengl32.dll's wglCreateContext to fail */ + if (GetPixelFormat(hdc) == 0) { + SetPixelFormat(hdc, iPixelFormat, NULL); + } + + return TRUE; +} + + +int +stw_pixelformat_get( + HDC hdc ) +{ + struct stw_framebuffer *fb; + + fb = stw_framebuffer_from_hdc(hdc); + if(!fb) + return 0; + + return fb->iPixelFormat; +} + + BOOL stw_swap_buffers( HDC hdc ) diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h index f5b48db048..e7fa51c3a8 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h @@ -44,6 +44,10 @@ struct stw_framebuffer HDC hDC; HWND hWnd; + int iPixelFormat; + const struct stw_pixelformat_info *pfi; + GLvisual visual; + pipe_mutex mutex; struct st_framebuffer *stfb; @@ -52,17 +56,25 @@ struct stw_framebuffer }; struct stw_framebuffer * -stw_framebuffer_create( +stw_framebuffer_create_locked( HDC hdc, - GLvisual *visual, - const struct stw_pixelformat_info *pfi, - GLuint width, - GLuint height ); + int iPixelFormat ); -void -stw_framebuffer_destroy( +BOOL +stw_framebuffer_allocate( struct stw_framebuffer *fb ); +void +stw_framebuffer_resize( + struct stw_framebuffer *fb); + +void +stw_framebuffer_cleanup(void); + +struct stw_framebuffer * +stw_framebuffer_from_hdc_locked( + HDC hdc ); + struct stw_framebuffer * stw_framebuffer_from_hdc( HDC hdc ); diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index b81d2b59a4..c296744838 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -25,12 +25,14 @@ * **************************************************************************/ +#include "main/mtypes.h" +#include "main/context.h" + #include "pipe/p_format.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" #include "util/u_debug.h" -#include "util/u_memory.h" #include "stw_device.h" #include "stw_pixelformat.h" @@ -261,6 +263,31 @@ stw_pixelformat_get_info( uint index ) } +void +stw_pixelformat_visual(GLvisual *visual, + const struct stw_pixelformat_info *pfi ) +{ + memset(visual, 0, sizeof *visual); + _mesa_initialize_visual( + visual, + (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE, + (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE, + (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE, + pfi->pfd.cRedBits, + pfi->pfd.cGreenBits, + pfi->pfd.cBlueBits, + pfi->pfd.cAlphaBits, + (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0, + pfi->pfd.cDepthBits, + pfi->pfd.cStencilBits, + pfi->pfd.cAccumRedBits, + pfi->pfd.cAccumGreenBits, + pfi->pfd.cAccumBlueBits, + pfi->pfd.cAccumAlphaBits, + pfi->numSamples ); +} + + int stw_pixelformat_describe( HDC hdc, @@ -341,39 +368,3 @@ int stw_pixelformat_choose( HDC hdc, return bestindex + 1; } - - -int -stw_pixelformat_get( - HDC hdc ) -{ - return stw_tls_get_data()->currentPixelFormat; -} - - -BOOL -stw_pixelformat_set( - HDC hdc, - int iPixelFormat ) -{ - uint count; - uint index; - - (void) hdc; - - index = (uint) iPixelFormat - 1; - count = stw_pixelformat_get_extended_count(); - if (index >= count) - return FALSE; - - stw_tls_get_data()->currentPixelFormat = iPixelFormat; - - /* Some applications mistakenly use the undocumented wglSetPixelFormat - * function instead of SetPixelFormat, so we call SetPixelFormat here to - * avoid opengl32.dll's wglCreateContext to fail */ - if (GetPixelFormat(hdc) == 0) { - SetPixelFormat(hdc, iPixelFormat, NULL); - } - - return TRUE; -} diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h index 34522ebef3..bec429231b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h @@ -30,6 +30,8 @@ #include +#include "main/mtypes.h" + #include "pipe/p_compiler.h" #include "pipe/p_format.h" @@ -56,5 +58,8 @@ stw_pixelformat_get_extended_count( void ); const struct stw_pixelformat_info * stw_pixelformat_get_info( uint index ); +void +stw_pixelformat_visual(GLvisual *visual, + const struct stw_pixelformat_info *pfi ); #endif /* STW_PIXELFORMAT_H */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c index 95863ca9cf..0c18a52352 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.c +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.c @@ -53,8 +53,6 @@ stw_tls_data_create() if (!data) return NULL; - data->currentPixelFormat = 0; - return data; } diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h index 6cfb0899f2..6af8be70c9 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_tls.h +++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h @@ -32,7 +32,6 @@ struct stw_tls_data { - uint currentPixelFormat; HHOOK hCallWndProcHook; }; -- cgit v1.2.3 From 0ea519f931a14e4dff6ef391803baba8bec84160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 31 May 2009 11:10:22 -0700 Subject: wgl: Ensure we only create framebuffers for HDC associated with a window. --- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 45ac3477e8..030a155f54 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -102,15 +102,21 @@ stw_framebuffer_create_locked( HDC hdc, int iPixelFormat ) { + HWND hWnd; struct stw_framebuffer *fb; const struct stw_pixelformat_info *pfi; + /* We only support drawing to a window. */ + hWnd = WindowFromDC( hdc ); + if(!hWnd) + return NULL; + fb = CALLOC_STRUCT( stw_framebuffer ); if (fb == NULL) return NULL; fb->hDC = hdc; - fb->hWnd = WindowFromDC( hdc ); + fb->hWnd = hWnd; fb->iPixelFormat = iPixelFormat; fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 ); -- cgit v1.2.3 From ea3ee4791eb8b9eefdd40b6ce9bbfc2dc86542bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 31 May 2009 17:16:26 -0700 Subject: wgl: Cleanup framebuffer destruction logic. --- src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 030a155f54..768cef3db6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -213,23 +213,18 @@ stw_framebuffer_resize( static INLINE void -stw_framebuffer_destroy( +stw_framebuffer_destroy_locked( struct stw_framebuffer *fb ) { struct stw_framebuffer **link; - pipe_mutex_lock( stw_dev->mutex ); - link = &stw_dev->fb_head; - while (link && *link != fb) + while (*link != fb) link = &(*link)->next; assert(*link); - if (link) - *link = fb->next; + *link = fb->next; fb->next = NULL; - pipe_mutex_unlock( stw_dev->mutex ); - st_unreference_framebuffer(fb->stfb); pipe_mutex_destroy( fb->mutex ); @@ -249,7 +244,7 @@ stw_framebuffer_cleanup( void ) fb = stw_dev->fb_head; while (fb) { next = fb->next; - stw_framebuffer_destroy(fb); + stw_framebuffer_destroy_locked(fb); fb = next; } stw_dev->fb_head = NULL; -- cgit v1.2.3 From aee1a6f70413235c0c4c2c2adfca97d5128a155e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 22 Mar 2009 04:22:33 +0100 Subject: util: Add simple network functions --- src/gallium/auxiliary/util/Makefile | 1 + src/gallium/auxiliary/util/SConscript | 1 + src/gallium/auxiliary/util/u_network.c | 188 +++++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_network.h | 24 +++++ 4 files changed, 214 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_network.c create mode 100644 src/gallium/auxiliary/util/u_network.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index 2995aba1b9..6a8eb73e84 100644 --- a/src/gallium/auxiliary/util/Makefile +++ b/src/gallium/auxiliary/util/Makefile @@ -16,6 +16,7 @@ C_SOURCES = \ u_hash.c \ u_keymap.c \ u_linear.c \ + u_network.c \ u_math.c \ u_mm.c \ u_rect.c \ diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript index d3ac7f747f..fb142eebca 100644 --- a/src/gallium/auxiliary/util/SConscript +++ b/src/gallium/auxiliary/util/SConscript @@ -17,6 +17,7 @@ util = env.ConvenienceLibrary( 'u_hash.c', 'u_hash_table.c', 'u_keymap.c', + 'u_network.c', 'u_math.c', 'u_mm.c', 'u_rect.c', diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c new file mode 100644 index 0000000000..465d50255e --- /dev/null +++ b/src/gallium/auxiliary/util/u_network.c @@ -0,0 +1,188 @@ + +#include "pipe/p_compiler.h" +#include "util/u_network.h" +#include "util/u_debug.h" + +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# include +# include +#elif defined(PIPE_OS_LINUX) +# include +# include +# include +# include +# include +#else +# warning "No socket implementation" +#endif + +boolean +u_socket_init() +{ +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) + WORD wVersionRequested; + WSADATA wsaData; + int err; + + /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ + wVersionRequested = MAKEWORD(1, 1); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + debug_printf("WSAStartup failed with error: %d\n", err); + return FALSE; + } + return TRUE; +#elif defined(PIPE_HAVE_SOCKETS) + return TRUE; +#else + return FALSE; +#endif +} + +void +u_socket_stop() +{ +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) + WSACleanup(); +#endif +} + +void +u_socket_close(int s) +{ + if (s < 0) + return; + +#if defined(PIPE_OS_LINUX) + shutdown(s, SHUT_RDWR); + close(s); +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) + shutdown(s, SD_BOTH); + closesocket(s); +#else + assert(0); +#endif +} + +int u_socket_accept(int s) +{ +#if defined(PIPE_HAVE_SOCKETS) + return accept(s, NULL, NULL); +#else + return -1; +#endif +} + +int +u_socket_send(int s, void *data, size_t size) +{ +#if defined(PIPE_HAVE_SOCKETS) + return send(s, data, size, 0); +#else + return -1; +#endif +} + +int +u_socket_peek(int s, void *data, size_t size) +{ +#if defined(PIPE_HAVE_SOCKETS) + return recv(s, data, size, MSG_PEEK); +#else + return -1; +#endif +} + +int +u_socket_recv(int s, void *data, size_t size) +{ +#if defined(PIPE_HAVE_SOCKETS) + return recv(s, data, size, 0); +#else + return -1; +#endif +} + +int +u_socket_connect(const char *hostname, uint16_t port) +{ +#if defined(PIPE_HAVE_SOCKETS) + int s; + struct sockaddr_in sa; + struct hostent *host = NULL; + + memset(&sa, 0, sizeof(struct sockaddr_in)); + host = gethostbyname(hostname); + if (!host) + return -1; + + memcpy((char *)&sa.sin_addr,host->h_addr,host->h_length); + sa.sin_family= host->h_addrtype; + sa.sin_port = htons(port); + + s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP); + if (s < 0) + return -1; + + if (connect(s, (struct sockaddr *)&sa, sizeof(sa))) { + u_socket_close(s); + return -1; + } + + return s; +#else + assert(0); + return -1; +#endif +} + +int +u_socket_listen_on_port(uint16_t portnum) +{ +#if defined(PIPE_HAVE_SOCKETS) + int s; + struct sockaddr_in sa; + memset(&sa, 0, sizeof(struct sockaddr_in)); + + sa.sin_family = AF_INET; + sa.sin_port = htons(portnum); + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s < 0) + return -1; + + if (bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) { + u_socket_close(s); + return -1; + } + + listen(s, 0); + + return s; +#else + assert(0); + return -1; +#endif +} + +void +u_socket_block(int s, boolean block) +{ +#if defined(PIPE_OS_LINUX) + int old = fcntl(s, F_GETFL, 0); + if (old == -1) + return; + + /* TODO obey block */ + if (block) + fcntl(s, F_SETFL, old & ~O_NONBLOCK); + else + fcntl(s, F_SETFL, old | O_NONBLOCK); +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) + u_long iMode = block ? 0 : 1; + ioctlsocket(s, FIONBIO, &iMode); +#else + assert(0); +#endif +} diff --git a/src/gallium/auxiliary/util/u_network.h b/src/gallium/auxiliary/util/u_network.h new file mode 100644 index 0000000000..14d3884427 --- /dev/null +++ b/src/gallium/auxiliary/util/u_network.h @@ -0,0 +1,24 @@ + +#ifndef _U_NETWORK_H_ +#define _U_NETWORK_H_ + +#include "pipe/p_compiler.h" + +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# define PIPE_HAVE_SOCKETS +#elif defined(PIPE_OS_LINUX) +# define PIPE_HAVE_SOCKETS +#endif + +boolean u_socket_init(void); +void u_socket_stop(void); +void u_socket_close(int s); +int u_socket_listen_on_port(uint16_t portnum); +int u_socket_accept(int s); +int u_socket_connect(const char *host, uint16_t port); +int u_socket_send(int s, void *data, size_t size); +int u_socket_peek(int s, void *data, size_t size); +int u_socket_recv(int s, void *data, size_t size); +void u_socket_block(int s, boolean block); + +#endif -- cgit v1.2.3 From dfa4ebcbcc9c7e9e7562f73a4ddc367756623e5e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 May 2009 01:07:05 +0200 Subject: rbug: Add Gallium Remote Debugger Protocol code This is the (de)marshalling and connection managment code --- src/gallium/SConscript | 1 + src/gallium/auxiliary/rbug/Makefile | 14 + src/gallium/auxiliary/rbug/README | 21 + src/gallium/auxiliary/rbug/SConscript | 14 + src/gallium/auxiliary/rbug/rbug.h | 33 ++ src/gallium/auxiliary/rbug/rbug_connection.c | 167 +++++++ src/gallium/auxiliary/rbug/rbug_connection.h | 45 ++ src/gallium/auxiliary/rbug/rbug_context.c | 442 +++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_context.h | 128 ++++++ src/gallium/auxiliary/rbug/rbug_core.c | 359 +++++++++++++++ src/gallium/auxiliary/rbug/rbug_core.h | 101 +++++ src/gallium/auxiliary/rbug/rbug_demarshal.c | 85 ++++ src/gallium/auxiliary/rbug/rbug_internal.h | 100 +++++ src/gallium/auxiliary/rbug/rbug_proto.h | 90 ++++ src/gallium/auxiliary/rbug/rbug_shader.c | 468 ++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_shader.h | 144 ++++++ src/gallium/auxiliary/rbug/rbug_texture.c | 631 +++++++++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_texture.h | 207 +++++++++ 18 files changed, 3050 insertions(+) create mode 100644 src/gallium/auxiliary/rbug/Makefile create mode 100644 src/gallium/auxiliary/rbug/README create mode 100644 src/gallium/auxiliary/rbug/SConscript create mode 100644 src/gallium/auxiliary/rbug/rbug.h create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.c create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.h create mode 100644 src/gallium/auxiliary/rbug/rbug_context.c create mode 100644 src/gallium/auxiliary/rbug/rbug_context.h create mode 100644 src/gallium/auxiliary/rbug/rbug_core.c create mode 100644 src/gallium/auxiliary/rbug/rbug_core.h create mode 100644 src/gallium/auxiliary/rbug/rbug_demarshal.c create mode 100644 src/gallium/auxiliary/rbug/rbug_internal.h create mode 100644 src/gallium/auxiliary/rbug/rbug_proto.h create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.c create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.h create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.c create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.h (limited to 'src/gallium') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index b6ceaf3edf..32b7c2980a 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -22,6 +22,7 @@ SConscript([ 'auxiliary/draw/SConscript', 'auxiliary/pipebuffer/SConscript', 'auxiliary/indices/SConscript', + 'auxiliary/rbug/SConscript', ]) for driver in env['drivers']: diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile new file mode 100644 index 0000000000..cd12e8468f --- /dev/null +++ b/src/gallium/auxiliary/rbug/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = rbug + +C_SOURCES = \ + rbug_connection.c \ + rbug_core.c \ + rbug_texture.c \ + rbug_context.c \ + rbug_shader.c \ + rbug_demarshal.c + +include ../../Makefile.template diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README new file mode 100644 index 0000000000..33d76371de --- /dev/null +++ b/src/gallium/auxiliary/rbug/README @@ -0,0 +1,21 @@ + GALLIUM REMOTE DEBUGGING COMMON CODE + += About = + +This directory contains the common code for the Gallium 3D remote debugging +driver and clients. The code is two parts the connection managment code and +the (de)marsheller. + +The code currently uses tcp and ip4v for connections. + +Information about driver integration can be found in: + +src/gallium/drivers/trace/README + +for information about applications look in: + +progs/rbug/README + + +-- +Jakob Bornecrantz diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript new file mode 100644 index 0000000000..4a9afb45d3 --- /dev/null +++ b/src/gallium/auxiliary/rbug/SConscript @@ -0,0 +1,14 @@ +Import('*') + +rbug = env.ConvenienceLibrary( + target = 'rbug', + source = [ + 'rbug_core.c', + 'rbug_shader.c', + 'rbug_context.c', + 'rbug_texture.c', + 'rbug_demarshal.c', + 'rbug_connection.c', + ]) + +auxiliaries.insert(0, rbug) diff --git a/src/gallium/auxiliary/rbug/rbug.h b/src/gallium/auxiliary/rbug/rbug.h new file mode 100644 index 0000000000..259bfc6c79 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug.h @@ -0,0 +1,33 @@ +/* + * 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 + * 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 + * VMWARE 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 all for users the remote debugger protocol code. + */ + +#include "rbug/rbug_core.h" +#include "rbug/rbug_shader.h" +#include "rbug/rbug_context.h" +#include "rbug/rbug_texture.h" +#include "rbug/rbug_connection.h" diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c new file mode 100644 index 0000000000..52acb700af --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_connection.c @@ -0,0 +1,167 @@ +/* + * 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 + * 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 + * VMWARE 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 "rbug/rbug.h" +#include "rbug/rbug_internal.h" + +#include "util/u_network.h" + +struct rbug_connection +{ + int socket; + uint32_t send_serial; + uint32_t recv_serial; + enum rbug_opcode opcode; +}; + +/** + * Create a rbug connection from a socket created with u_socket. + * + * Result: + * A new allocated connection using socket as communication path + */ +struct rbug_connection * +rbug_from_socket(int socket) +{ + struct rbug_connection *c = CALLOC_STRUCT(rbug_connection); + c->socket = socket; + return c; +} + +/** + * Free a connection, also closes socket. + */ +void +rbug_disconnect(struct rbug_connection *c) +{ + u_socket_close(c->socket); + FREE(c); +} + +/** + * Waits for a message to be fully received. + * Also returns the serial for the message, serial is not touched for replys. + * + * Result: + * demarshaled message on success, NULL on connection error + */ +struct rbug_header * +rbug_get_message(struct rbug_connection *c, uint32_t *serial) +{ + struct rbug_proto_header header; + struct rbug_header *out; + struct rbug_proto_header *data; + size_t length = 0; + size_t read = 0; + int ret; + + + ret = u_socket_peek(c->socket, &header, sizeof(header)); + if (ret <= 0) { + return NULL; + } + + length = (size_t)header.length * 4; + data = MALLOC(length); + if (!data) { + return NULL; + } + + do { + uint8_t *ptr = ((uint8_t*)data) + read; + ret = u_socket_recv(c->socket, ptr, length - read); + + if (ret <= 0) { + FREE(data); + return NULL; + } + + read += ret; + } while(read < length); + + out = rbug_demarshal(data); + if (!out) + FREE(data); + else if (serial) + *serial = c->recv_serial++; + else + c->recv_serial++; + + return out; +} + +/** + * Frees a message and associated data. + */ +void +rbug_free_header(struct rbug_header *header) +{ + if (!header) + return; + + FREE(header->__message); + FREE(header); +} + +/** + * Internal function used by rbug_send_* functions. + * + * Start sending a message. + */ +int +rbug_connection_send_start(struct rbug_connection *c, enum rbug_opcode opcode, uint32_t length) +{ + c->opcode = opcode; + return 0; +} + +/** + * Internal function used by rbug_send_* functions. + * + * Write data to the socket. + */ +int +rbug_connection_write(struct rbug_connection *c, void *to, uint32_t size) +{ + int ret = u_socket_send(c->socket, to, size); + return ret; +} + +/** + * Internal function used by rbug_send_* functions. + * + * Finish writeing data to the socket. + * Ups the send_serial and sets the serial argument if supplied. + */ +int rbug_connection_send_finish(struct rbug_connection *c, uint32_t *serial) +{ + if (c->opcode < 0) + return 0; + else if (serial) + *serial = c->send_serial++; + else + c->send_serial++; + + return 0; +} diff --git a/src/gallium/auxiliary/rbug/rbug_connection.h b/src/gallium/auxiliary/rbug/rbug_connection.h new file mode 100644 index 0000000000..1f2c9ff347 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_connection.h @@ -0,0 +1,45 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file contains the function defentions for connection see c file for + * more comments covering function use. + */ + +#ifndef _RBUG_CONNECTION_H_ +#define _RBUG_CONNECTION_H_ + +#include "rbug/rbug_proto.h" + +struct rbug_connection * rbug_from_socket(int socket); + +void rbug_disconnect(struct rbug_connection *c); + +struct rbug_header * rbug_get_message(struct rbug_connection *c, uint32_t *serial); + +void rbug_free_header(struct rbug_header *header); + +struct rbug_header * rbug_demarshal(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c new file mode 100644 index 0000000000..b4fad5300d --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -0,0 +1,442 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_context.h" + +int rbug_send_context_list(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_info(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_block_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_BLOCK_DRAW)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_BLOCK_DRAW, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_unblock_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_UNBLOCK_DRAW, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_context_t *contexts, + uint32_t contexts_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, contexts); /* contexts */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_info_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_t blocked, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, cbufs); /* cbufs */ + LEN(8); /* zdbuf */ + LEN(1); /* blocked */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + WRITE(8, rbug_texture_t, zdbuf); /* zdbuf */ + WRITE(1, uint8_t, blocked); /* blocked */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_block_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_BLOCK_DRAW) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_unblock_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_context_t, contexts); /* contexts */ + + return ret; +} + +struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + READ(8, rbug_texture_t, zdbuf); /* zdbuf */ + READ(1, uint8_t, blocked); /* blocked */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h new file mode 100644 index 0000000000..bcd2a826a7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -0,0 +1,128 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_CONTEXT_H_ +#define _RBUG_PROTO_CONTEXT_H_ + +#include "rbug/rbug_proto.h" +#include "rbug/rbug_texture.h" + +typedef uint64_t rbug_context_t; + +struct rbug_proto_context_list +{ + struct rbug_header header; +}; + +struct rbug_proto_context_info +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_block_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_unblock_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_context_t *contexts; + uint32_t contexts_len; +}; + +struct rbug_proto_context_info_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_texture_t *cbufs; + uint32_t cbufs_len; + rbug_texture_t zdbuf; + uint8_t blocked; +}; + +int rbug_send_context_list(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_context_info(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_block_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_unblock_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_context_t *contexts, + uint32_t contexts_len, + uint32_t *__serial); + +int rbug_send_context_info_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_t blocked, + uint32_t *__serial); + +struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header); + +struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header); + +struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header); + +struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header); + +struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_core.c b/src/gallium/auxiliary/rbug/rbug_core.c new file mode 100644 index 0000000000..876ae5a0ce --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_core.c @@ -0,0 +1,359 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_core.h" + +int rbug_send_noop(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_NOOP)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_NOOP, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_ping(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_PING)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_PING, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_error(struct rbug_connection *__con, + uint32_t error, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* error */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, error); /* error */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_ERROR, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_ping_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_PING_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_PING_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_error_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t error, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* error */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, error); /* error */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_ERROR_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_noop *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_NOOP) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_ping *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_PING) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_error *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_ERROR) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, error); /* error */ + + return ret; +} + +struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_ping_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_PING_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + + return ret; +} + +struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_error_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_ERROR_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, error); /* error */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_core.h b/src/gallium/auxiliary/rbug/rbug_core.h new file mode 100644 index 0000000000..d63a8c8076 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_core.h @@ -0,0 +1,101 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_CORE_H_ +#define _RBUG_PROTO_CORE_H_ + +#include "rbug/rbug_proto.h" + +struct rbug_proto_noop +{ + struct rbug_header header; +}; + +struct rbug_proto_ping +{ + struct rbug_header header; +}; + +struct rbug_proto_error +{ + struct rbug_header header; + uint32_t error; +}; + +struct rbug_proto_ping_reply +{ + struct rbug_header header; + uint32_t serial; +}; + +struct rbug_proto_error_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t error; +}; + +int rbug_send_noop(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_ping(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_error(struct rbug_connection *__con, + uint32_t error, + uint32_t *__serial); + +int rbug_send_ping_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *__serial); + +int rbug_send_error_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t error, + uint32_t *__serial); + +struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header); + +struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header); + +struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header); + +struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header); + +struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c new file mode 100644 index 0000000000..e3c0954f9e --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -0,0 +1,85 @@ +/* + * 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 + * 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 + * VMWARE 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 "rbug.h" + +/** + * Small function that looks at the proto_header and selects the correct + * demarshal functions and return the result. + */ +struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) +{ + switch(header->opcode) { + case RBUG_OP_NOOP: + return (struct rbug_header *)rbug_demarshal_noop(header); + case RBUG_OP_PING: + return (struct rbug_header *)rbug_demarshal_ping(header); + case RBUG_OP_ERROR: + return (struct rbug_header *)rbug_demarshal_error(header); + case RBUG_OP_PING_REPLY: + return (struct rbug_header *)rbug_demarshal_ping_reply(header); + case RBUG_OP_ERROR_REPLY: + return (struct rbug_header *)rbug_demarshal_error_reply(header); + case RBUG_OP_TEXTURE_LIST: + return (struct rbug_header *)rbug_demarshal_texture_list(header); + case RBUG_OP_TEXTURE_INFO: + return (struct rbug_header *)rbug_demarshal_texture_info(header); + case RBUG_OP_TEXTURE_WRITE: + return (struct rbug_header *)rbug_demarshal_texture_write(header); + case RBUG_OP_TEXTURE_READ: + return (struct rbug_header *)rbug_demarshal_texture_read(header); + case RBUG_OP_TEXTURE_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_list_reply(header); + case RBUG_OP_TEXTURE_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_info_reply(header); + case RBUG_OP_TEXTURE_READ_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_read_reply(header); + case RBUG_OP_CONTEXT_LIST: + return (struct rbug_header *)rbug_demarshal_context_list(header); + case RBUG_OP_CONTEXT_INFO: + return (struct rbug_header *)rbug_demarshal_context_info(header); + case RBUG_OP_CONTEXT_BLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_block_draw(header); + case RBUG_OP_CONTEXT_UNBLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_unblock_draw(header); + case RBUG_OP_CONTEXT_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_context_list_reply(header); + case RBUG_OP_CONTEXT_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_context_info_reply(header); + case RBUG_OP_SHADER_LIST: + return (struct rbug_header *)rbug_demarshal_shader_list(header); + case RBUG_OP_SHADER_INFO: + return (struct rbug_header *)rbug_demarshal_shader_info(header); + case RBUG_OP_SHADER_DISABLE: + return (struct rbug_header *)rbug_demarshal_shader_disable(header); + case RBUG_OP_SHADER_REPLACE: + return (struct rbug_header *)rbug_demarshal_shader_replace(header); + case RBUG_OP_SHADER_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_shader_list_reply(header); + case RBUG_OP_SHADER_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_shader_info_reply(header); + default: + return NULL; + } +} diff --git a/src/gallium/auxiliary/rbug/rbug_internal.h b/src/gallium/auxiliary/rbug/rbug_internal.h new file mode 100644 index 0000000000..4aba1a810f --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_internal.h @@ -0,0 +1,100 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file is internal to the rbug protocol code, and contains asorted + * features needed by the code. + */ + +#ifndef _RBUG_INTERNAL_H_ +#define _RBUG_INTERNAL_H_ + +#include "rbug/rbug_proto.h" + +#include "util/u_memory.h" +#include "util/u_debug.h" +#include + +int rbug_connection_send_start(struct rbug_connection *con, enum rbug_opcode opcode, uint32_t length); +int rbug_connection_write(struct rbug_connection *con, void *data, uint32_t size); +int rbug_connection_send_finish(struct rbug_connection *con, uint32_t *c); + +/** + * Only works with multiples of 2 + */ +#define PAD(from, to) \ +do { \ + from = (from + to - 1) & ~(to - 1); \ +} while(0) + +#define LEN(size) \ +do { \ + PAD(__len, size); \ + __len += size; \ +} while(0) + +#define LEN_ARRAY(size, name) \ +do { \ + LEN(4); \ + PAD(__len, size); \ + __len += size * name##_len; \ +} while(0) + +#define WRITE(size, type, name) \ +do { \ + PAD(__pos, size); \ + *((type *)(&__data[__pos])) = name; \ + __pos += size; \ +} while(0) + +#define WRITE_ARRAY(size, type, name) \ +do { \ + WRITE(4, uint32_t, name##_len); \ + PAD(__pos, size); \ + memcpy(&__data[__pos], name, size * name##_len); \ + __pos += size * name##_len; \ +} while(0) + +#define READ(size, type, name) \ +do { \ + PAD(pos, size); \ + pos += size; \ + if (pos > len) \ + break; \ + ret->name = *((type *)(&data[pos - size])); \ +} while(0) + +#define READ_ARRAY(size, type, name) \ +do { \ + READ(4, uint32_t, name##_len); \ + if (pos > len) \ + break; \ + PAD(pos, size); \ + pos += size * ret->name##_len; \ + if (pos > len) \ + break; \ + ret->name = (type *)&data[pos - size * ret->name##_len]; \ +} while(0) + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h new file mode 100644 index 0000000000..8fa1836771 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -0,0 +1,90 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds common definitions of the gallium remote debugging protocol. + */ + +#ifndef _RBUG_PROTO_H_ +#define _RBUG_PROTO_H_ + +#include "pipe/p_compiler.h" + +/** + * Uniqe indentifier for each command. + * + * Replys are designated by negative. + */ +enum rbug_opcode +{ + RBUG_OP_NOOP = 0, + RBUG_OP_PING = 1, + RBUG_OP_ERROR = 2, + RBUG_OP_PING_REPLY = -1, + RBUG_OP_ERROR_REPLY = -2, + RBUG_OP_TEXTURE_LIST = 256, + RBUG_OP_TEXTURE_INFO = 257, + RBUG_OP_TEXTURE_WRITE = 258, + RBUG_OP_TEXTURE_READ = 259, + RBUG_OP_TEXTURE_LIST_REPLY = -256, + RBUG_OP_TEXTURE_INFO_REPLY = -257, + RBUG_OP_TEXTURE_READ_REPLY = -259, + RBUG_OP_CONTEXT_LIST = 512, + RBUG_OP_CONTEXT_INFO = 513, + RBUG_OP_CONTEXT_BLOCK_DRAW = 514, + RBUG_OP_CONTEXT_UNBLOCK_DRAW = 515, + RBUG_OP_CONTEXT_LIST_REPLY = -512, + RBUG_OP_CONTEXT_INFO_REPLY = -513, + RBUG_OP_SHADER_LIST = 768, + RBUG_OP_SHADER_INFO = 769, + RBUG_OP_SHADER_DISABLE = 770, + RBUG_OP_SHADER_REPLACE = 771, + RBUG_OP_SHADER_LIST_REPLY = -768, + RBUG_OP_SHADER_INFO_REPLY = -769, +}; + +/** + * Header for demarshaled message. + */ +struct rbug_header +{ + enum rbug_opcode opcode; + void *__message; +}; + +/** + * Header for a message in wire format. + */ +struct rbug_proto_header +{ + int32_t opcode; + uint32_t length; +}; + +/** + * Forward declare connection here, as this file is included by all users. + */ +struct rbug_connection; + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c new file mode 100644 index 0000000000..fccd2f55ef --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_shader.c @@ -0,0 +1,468 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_shader.h" + +int rbug_send_shader_list(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_info(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_disable(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint8_t disable, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + LEN(1); /* disable */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_DISABLE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + WRITE(1, uint8_t, disable); /* disable */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_DISABLE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_replace(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *tokens, + uint32_t tokens_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + LEN_ARRAY(4, tokens); /* tokens */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_REPLACE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + WRITE_ARRAY(4, uint32_t, tokens); /* tokens */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_REPLACE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_shader_t *shaders, + uint32_t shaders_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, shaders); /* shaders */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_shader_t, shaders); /* shaders */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *original, + uint32_t original_len, + uint32_t *replaced, + uint32_t replaced_len, + uint8_t disabled, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(4, original); /* original */ + LEN_ARRAY(4, replaced); /* replaced */ + LEN(1); /* disabled */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(4, uint32_t, original); /* original */ + WRITE_ARRAY(4, uint32_t, replaced); /* replaced */ + WRITE(1, uint8_t, disabled); /* disabled */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + + return ret; +} + +struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_disable *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_DISABLE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + READ(1, uint8_t, disable); /* disable */ + + return ret; +} + +struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_replace *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_REPLACE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + READ_ARRAY(4, uint32_t, tokens); /* tokens */ + + return ret; +} + +struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_shader_t, shaders); /* shaders */ + + return ret; +} + +struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(4, uint32_t, original); /* original */ + READ_ARRAY(4, uint32_t, replaced); /* replaced */ + READ(1, uint8_t, disabled); /* disabled */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h new file mode 100644 index 0000000000..fe1b9ac0f7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_shader.h @@ -0,0 +1,144 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_SHADER_H_ +#define _RBUG_PROTO_SHADER_H_ + +#include "rbug/rbug_proto.h" +#include "rbug/rbug_context.h" + +typedef uint64_t rbug_shader_t; + +struct rbug_proto_shader_list +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_shader_info +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; +}; + +struct rbug_proto_shader_disable +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; + uint8_t disable; +}; + +struct rbug_proto_shader_replace +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; + uint32_t *tokens; + uint32_t tokens_len; +}; + +struct rbug_proto_shader_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_shader_t *shaders; + uint32_t shaders_len; +}; + +struct rbug_proto_shader_info_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t *original; + uint32_t original_len; + uint32_t *replaced; + uint32_t replaced_len; + uint8_t disabled; +}; + +int rbug_send_shader_list(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_shader_info(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *__serial); + +int rbug_send_shader_disable(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint8_t disable, + uint32_t *__serial); + +int rbug_send_shader_replace(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *tokens, + uint32_t tokens_len, + uint32_t *__serial); + +int rbug_send_shader_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_shader_t *shaders, + uint32_t shaders_len, + uint32_t *__serial); + +int rbug_send_shader_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *original, + uint32_t original_len, + uint32_t *replaced, + uint32_t replaced_len, + uint8_t disabled, + uint32_t *__serial); + +struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header); + +struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header); + +struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header); + +struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header); + +struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_texture.c b/src/gallium/auxiliary/rbug/rbug_texture.c new file mode 100644 index 0000000000..5a918fe6bc --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_texture.c @@ -0,0 +1,631 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_texture.h" + +int rbug_send_texture_list(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_info(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_write(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + LEN(4); /* face */ + LEN(4); /* level */ + LEN(4); /* zslice */ + LEN(4); /* x */ + LEN(4); /* y */ + LEN(4); /* w */ + LEN(4); /* h */ + LEN_ARRAY(1, data); /* data */ + LEN(4); /* stride */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_WRITE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + WRITE(4, uint32_t, face); /* face */ + WRITE(4, uint32_t, level); /* level */ + WRITE(4, uint32_t, zslice); /* zslice */ + WRITE(4, uint32_t, x); /* x */ + WRITE(4, uint32_t, y); /* y */ + WRITE(4, uint32_t, w); /* w */ + WRITE(4, uint32_t, h); /* h */ + WRITE_ARRAY(1, uint8_t, data); /* data */ + WRITE(4, uint32_t, stride); /* stride */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_WRITE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_read(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + LEN(4); /* face */ + LEN(4); /* level */ + LEN(4); /* zslice */ + LEN(4); /* x */ + LEN(4); /* y */ + LEN(4); /* w */ + LEN(4); /* h */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + WRITE(4, uint32_t, face); /* face */ + WRITE(4, uint32_t, level); /* level */ + WRITE(4, uint32_t, zslice); /* zslice */ + WRITE(4, uint32_t, x); /* x */ + WRITE(4, uint32_t, y); /* y */ + WRITE(4, uint32_t, w); /* w */ + WRITE(4, uint32_t, h); /* h */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *textures, + uint32_t textures_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, textures); /* textures */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_texture_t, textures); /* textures */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t target, + uint32_t format, + uint32_t *width, + uint32_t width_len, + uint32_t *height, + uint32_t height_len, + uint32_t *depth, + uint32_t depth_len, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint32_t last_level, + uint32_t nr_samples, + uint32_t tex_usage, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* target */ + LEN(4); /* format */ + LEN_ARRAY(4, width); /* width */ + LEN_ARRAY(4, height); /* height */ + LEN_ARRAY(4, depth); /* depth */ + LEN(4); /* blockw */ + LEN(4); /* blockh */ + LEN(4); /* blocksize */ + LEN(4); /* last_level */ + LEN(4); /* nr_samples */ + LEN(4); /* tex_usage */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, target); /* target */ + WRITE(4, uint32_t, format); /* format */ + WRITE_ARRAY(4, uint32_t, width); /* width */ + WRITE_ARRAY(4, uint32_t, height); /* height */ + WRITE_ARRAY(4, uint32_t, depth); /* depth */ + WRITE(4, uint32_t, blockw); /* blockw */ + WRITE(4, uint32_t, blockh); /* blockh */ + WRITE(4, uint32_t, blocksize); /* blocksize */ + WRITE(4, uint32_t, last_level); /* last_level */ + WRITE(4, uint32_t, nr_samples); /* nr_samples */ + WRITE(4, uint32_t, tex_usage); /* tex_usage */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_read_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t format, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* format */ + LEN(4); /* blockw */ + LEN(4); /* blockh */ + LEN(4); /* blocksize */ + LEN_ARRAY(1, data); /* data */ + LEN(4); /* stride */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, format); /* format */ + WRITE(4, uint32_t, blockw); /* blockw */ + WRITE(4, uint32_t, blockh); /* blockh */ + WRITE(4, uint32_t, blocksize); /* blocksize */ + WRITE_ARRAY(1, uint8_t, data); /* data */ + WRITE(4, uint32_t, stride); /* stride */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + + return ret; +} + +struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_write *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_WRITE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + READ(4, uint32_t, face); /* face */ + READ(4, uint32_t, level); /* level */ + READ(4, uint32_t, zslice); /* zslice */ + READ(4, uint32_t, x); /* x */ + READ(4, uint32_t, y); /* y */ + READ(4, uint32_t, w); /* w */ + READ(4, uint32_t, h); /* h */ + READ_ARRAY(1, uint8_t, data); /* data */ + READ(4, uint32_t, stride); /* stride */ + + return ret; +} + +struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_read *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + READ(4, uint32_t, face); /* face */ + READ(4, uint32_t, level); /* level */ + READ(4, uint32_t, zslice); /* zslice */ + READ(4, uint32_t, x); /* x */ + READ(4, uint32_t, y); /* y */ + READ(4, uint32_t, w); /* w */ + READ(4, uint32_t, h); /* h */ + + return ret; +} + +struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_texture_t, textures); /* textures */ + + return ret; +} + +struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, target); /* target */ + READ(4, uint32_t, format); /* format */ + READ_ARRAY(4, uint32_t, width); /* width */ + READ_ARRAY(4, uint32_t, height); /* height */ + READ_ARRAY(4, uint32_t, depth); /* depth */ + READ(4, uint32_t, blockw); /* blockw */ + READ(4, uint32_t, blockh); /* blockh */ + READ(4, uint32_t, blocksize); /* blocksize */ + READ(4, uint32_t, last_level); /* last_level */ + READ(4, uint32_t, nr_samples); /* nr_samples */ + READ(4, uint32_t, tex_usage); /* tex_usage */ + + return ret; +} + +struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_read_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, format); /* format */ + READ(4, uint32_t, blockw); /* blockw */ + READ(4, uint32_t, blockh); /* blockh */ + READ(4, uint32_t, blocksize); /* blocksize */ + READ_ARRAY(1, uint8_t, data); /* data */ + READ(4, uint32_t, stride); /* stride */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h new file mode 100644 index 0000000000..2bcc3566f3 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_texture.h @@ -0,0 +1,207 @@ +/* + * 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 + * 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 + * VMWARE 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_TEXTURE_H_ +#define _RBUG_PROTO_TEXTURE_H_ + +#include "rbug/rbug_proto.h" + +typedef uint64_t rbug_texture_t; + +struct rbug_proto_texture_list +{ + struct rbug_header header; +}; + +struct rbug_proto_texture_info +{ + struct rbug_header header; + rbug_texture_t texture; +}; + +struct rbug_proto_texture_write +{ + struct rbug_header header; + rbug_texture_t texture; + uint32_t face; + uint32_t level; + uint32_t zslice; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; + uint8_t *data; + uint32_t data_len; + uint32_t stride; +}; + +struct rbug_proto_texture_read +{ + struct rbug_header header; + rbug_texture_t texture; + uint32_t face; + uint32_t level; + uint32_t zslice; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; +}; + +struct rbug_proto_texture_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_texture_t *textures; + uint32_t textures_len; +}; + +struct rbug_proto_texture_info_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t target; + uint32_t format; + uint32_t *width; + uint32_t width_len; + uint32_t *height; + uint32_t height_len; + uint32_t *depth; + uint32_t depth_len; + uint32_t blockw; + uint32_t blockh; + uint32_t blocksize; + uint32_t last_level; + uint32_t nr_samples; + uint32_t tex_usage; +}; + +struct rbug_proto_texture_read_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t format; + uint32_t blockw; + uint32_t blockh; + uint32_t blocksize; + uint8_t *data; + uint32_t data_len; + uint32_t stride; +}; + +int rbug_send_texture_list(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_texture_info(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t *__serial); + +int rbug_send_texture_write(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial); + +int rbug_send_texture_read(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t *__serial); + +int rbug_send_texture_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *textures, + uint32_t textures_len, + uint32_t *__serial); + +int rbug_send_texture_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t target, + uint32_t format, + uint32_t *width, + uint32_t width_len, + uint32_t *height, + uint32_t height_len, + uint32_t *depth, + uint32_t depth_len, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint32_t last_level, + uint32_t nr_samples, + uint32_t tex_usage, + uint32_t *__serial); + +int rbug_send_texture_read_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t format, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial); + +struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header); + +struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header); + +struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header); + +struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header); + +struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header); + +struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header); + +#endif -- cgit v1.2.3 From 01fa34cb98d9ea6008c7108b6112348e278864f4 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 1 Jun 2009 11:19:55 +0100 Subject: trace/rbug: Add rbug integration for remote debugging --- src/gallium/drivers/trace/Makefile | 1 + src/gallium/drivers/trace/README | 18 +- src/gallium/drivers/trace/SConscript | 1 + src/gallium/drivers/trace/tr_rbug.c | 636 ++++++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_screen.c | 14 +- src/gallium/drivers/trace/tr_screen.h | 21 +- 6 files changed, 685 insertions(+), 6 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_rbug.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index ecb69fb996..4aeb8e3d7e 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -10,6 +10,7 @@ C_SOURCES = \ tr_dump_state.c \ tr_screen.c \ tr_state.c \ + tr_rbug.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index 73dce20372..1000c31e49 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -3,7 +3,8 @@ = About = -This directory contains a Gallium3D pipe driver which traces all incoming calls. +This directory contains a Gallium3D debugger pipe driver. +It can traces all incoming calls and/or provide remote debugging functionality. = Build Instructions = @@ -23,7 +24,9 @@ ensure the right libGL.so is being picked by doing ldd progs/trivial/tri -and then try running +== Traceing == + +For traceing then do export XMESA_TRACE=y GALLIUM_TRACE=tri.trace progs/trivial/tri @@ -32,6 +35,16 @@ which should create a tri.trace file, which is an XML file. You can view copying trace.xsl to the same directory, and opening with a XSLT capable browser such as Firefox or Internet Explorer. +== Remote debugging == + +For remote debugging + + export XMESA_TRACE=y + GALLIUM_RBUG=true progs/trivial/tri + +which should open gallium remote debugging session. While the program is running +you can launch the small remote debugging application from progs/rbug. More +information is in that directory. = Integrating = @@ -62,3 +75,4 @@ trace_screen with real_screen when creating them. -- Jose Fonseca +Jakob Bornecrantz diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 9b5af0d86f..e635fed77d 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -11,6 +11,7 @@ trace = env.ConvenienceLibrary( 'tr_dump_state.c', 'tr_screen.c', 'tr_state.c', + 'tr_rbug.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c new file mode 100644 index 0000000000..1b26f60da4 --- /dev/null +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -0,0 +1,636 @@ +/************************************************************************** + * + * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "util/u_string.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" +#include "util/u_network.h" + +#include "tgsi/tgsi_parse.h" + +#include "tr_dump.h" +#include "tr_state.h" +#include "tr_buffer.h" +#include "tr_texture.h" + +#include "rbug/rbug.h" + +#include + +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# define sleep Sleep +#elif defined(PIPE_OS_LINUX) +void usleep(int); +# define sleep usleep +#else +# warning "No socket implementation" +#endif + +#define U642VOID(x) ((void *)(unsigned long)(x)) +#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) + +struct trace_rbug +{ + struct trace_screen *tr_scr; + struct rbug_connection *con; + pipe_thread thread; + boolean running; +}; + +PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug); + + +/********************************************************** + * Helper functions + */ + + +static struct trace_context * +trace_rbug_get_context_locked(struct trace_screen *tr_scr, rbug_context_t ctx) +{ + struct trace_context *tr_ctx = NULL; + struct tr_list *ptr; + + foreach(ptr, &tr_scr->contexts) { + tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); + if (ctx == VOID2U64(tr_ctx)) + break; + tr_ctx = NULL; + } + + return tr_ctx; +} + +static struct trace_shader * +trace_rbug_get_shader_locked(struct trace_context *tr_ctx, rbug_shader_t shdr) +{ + struct trace_shader *tr_shdr = NULL; + struct tr_list *ptr; + + foreach(ptr, &tr_ctx->shaders) { + tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); + if (shdr == VOID2U64(tr_shdr)) + break; + tr_shdr = NULL; + } + + return tr_shdr; +} + +static void * +trace_shader_create_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + struct tgsi_token *tokens) +{ + void *state = NULL; + struct pipe_shader_state pss = { 0 }; + pss.tokens = tokens; + + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + state = pipe->create_fs_state(pipe, &pss); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + state = pipe->create_vs_state(pipe, &pss); + } else + assert(0); + + return state; +} + +static void +trace_shader_bind_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + void *state) +{ + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + pipe->bind_fs_state(pipe, state); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + pipe->bind_vs_state(pipe, state); + } else + assert(0); +} + +static void +trace_shader_delete_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + void *state) +{ + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + pipe->delete_fs_state(pipe, state); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + pipe->delete_vs_state(pipe, state); + } else + assert(0); +} + +/************************************************ + * Request handler functions + */ + + +static int +trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex = NULL; + struct tr_list *ptr; + rbug_texture_t *texs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t)); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + texs[i++] = VOID2U64(tr_tex); + } + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); + FREE(texs); + + return 0; +} + +static int +trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex; + struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; + struct tr_list *ptr; + struct pipe_texture *t; + + pipe_mutex_lock(tr_scr->list_mutex); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + if (gpti->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + t = tr_tex->texture; + rbug_send_texture_info_reply(tr_rbug->con, serial, + t->target, t->format, + t->width, t->last_level + 1, + t->height, t->last_level + 1, + t->depth, t->last_level + 1, + t->block.width, t->block.height, t->block.size, + t->last_level, + t->nr_samples, + t->tex_usage, + NULL); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex; + struct tr_list *ptr; + + struct pipe_screen *screen = tr_scr->screen; + struct pipe_texture *tex; + struct pipe_transfer *t; + + void *map; + + pipe_mutex_lock(tr_scr->list_mutex); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + if (gptr->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + tex = tr_tex->texture; + t = screen->get_tex_transfer(tr_scr->screen, tex, + gptr->face, gptr->level, gptr->zslice, + PIPE_TRANSFER_READ, + gptr->x, gptr->y, gptr->w, gptr->h); + + map = screen->transfer_map(screen, t); + + rbug_send_texture_read_reply(tr_rbug->con, serial, + t->format, + t->block.width, t->block.height, t->block.size, + (uint8_t*)map, t->stride * t->nblocksy, + t->stride, + NULL); + + screen->transfer_unmap(screen, t); + screen->tex_transfer_destroy(t); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct tr_list *ptr; + struct trace_context *tr_ctx = NULL; + rbug_context_t *ctxs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + ctxs = MALLOC(tr_scr->num_contexts * sizeof(rbug_context_t)); + foreach(ptr, &tr_scr->contexts) { + tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); + ctxs[i++] = VOID2U64(tr_ctx); + } + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); + FREE(ctxs); + + return 0; +} + +static int +trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + struct tr_list *ptr; + rbug_shader_t *shdrs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, list->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + shdrs = MALLOC(tr_ctx->num_shaders * sizeof(rbug_shader_t)); + foreach(ptr, &tr_ctx->shaders) { + tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); + shdrs[i++] = VOID2U64(tr_shdr); + } + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); + FREE(shdrs); + + return 0; +} + +static int +trace_rbug_shader_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + unsigned original_len; + unsigned replaced_len; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, info->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* just in case */ + assert(sizeof(struct tgsi_token) == 4); + + original_len = tgsi_num_tokens(tr_shdr->tokens); + if (tr_shdr->replaced_tokens) + replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens); + else + replaced_len = 0; + + rbug_send_shader_info_reply(tr_rbug->con, serial, + (uint32_t*)tr_shdr->tokens, original_len, + (uint32_t*)tr_shdr->replaced_tokens, replaced_len, + tr_shdr->disabled, + NULL); + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_shader_disable(struct trace_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, dis->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, dis->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + tr_shdr->disabled = dis->disable; + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_shader_replace(struct trace_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + struct pipe_context *pipe = NULL; + void *state; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, rep->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, rep->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + trace_dump_call_lock(); + + pipe = tr_ctx->pipe; + + /* remove old replaced shader */ + if (tr_shdr->replaced) { + if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) + trace_shader_bind_locked(pipe, tr_shdr, tr_shdr->state); + + FREE(tr_shdr->replaced_tokens); + trace_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced); + tr_shdr->replaced = NULL; + tr_shdr->replaced_tokens = NULL; + } + + /* empty inputs means restore old which we did above */ + if (rep->tokens_len == 0) + goto out; + + tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens); + if (!tr_shdr->replaced_tokens) + goto err; + + state = trace_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens); + if (!state) + goto err; + + /* bind new shader if the shader is currently a bound */ + if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) + trace_shader_bind_locked(pipe, tr_shdr, state); + + /* save state */ + tr_shdr->replaced = state; + +out: + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; + +err: + FREE(tr_shdr->replaced_tokens); + tr_shdr->replaced = NULL; + tr_shdr->replaced_tokens = NULL; + + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -EINVAL; +} + +static boolean +trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + int ret = 0; + + switch(header->opcode) { + case RBUG_OP_PING: + rbug_send_ping_reply(tr_rbug->con, serial, NULL); + break; + case RBUG_OP_TEXTURE_LIST: + ret = trace_rbug_texture_list(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_INFO: + ret = trace_rbug_texture_info(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_READ: + ret = trace_rbug_texture_read(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_LIST: + ret = trace_rbug_context_list(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_LIST: + ret = trace_rbug_shader_list(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_INFO: + ret = trace_rbug_shader_info(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_DISABLE: + ret = trace_rbug_shader_disable(tr_rbug, header); + break; + case RBUG_OP_SHADER_REPLACE: + ret = trace_rbug_shader_replace(tr_rbug, header); + break; + default: + debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode); + ret = -ENOSYS; + break; + } + rbug_free_header(header); + + if (ret) + rbug_send_error_reply(tr_rbug->con, serial, ret, NULL); + + return TRUE; +} + +static void +trace_rbug_con(struct trace_rbug *tr_rbug) +{ + struct rbug_header *header; + uint32_t serial; + + debug_printf("%s - connection received\n", __FUNCTION__); + + while(tr_rbug->running) { + header = rbug_get_message(tr_rbug->con, &serial); + if (!header) + break; + + if (!trace_rbug_header(tr_rbug, header, serial)) + break; + } + + debug_printf("%s - connection closed\n", __FUNCTION__); + + rbug_disconnect(tr_rbug->con); + tr_rbug->con = NULL; +} + +PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug) +{ + struct trace_rbug *tr_rbug = void_tr_rbug; + uint16_t port = 13370; + int s = -1; + int c; + + u_socket_init(); + + for (;port <= 13379 && s < 0; port++) + s = u_socket_listen_on_port(port); + + if (s < 0) { + debug_printf("trace_rbug - failed to listen\n"); + return NULL; + } + + u_socket_block(s, false); + + debug_printf("trace_rbug - remote debugging listening on port %u\n", --port); + + while(tr_rbug->running) { + sleep(1); + + c = u_socket_accept(s); + if (c < 0) + continue; + + u_socket_block(c, true); + tr_rbug->con = rbug_from_socket(c); + + trace_rbug_con(tr_rbug); + + u_socket_close(c); + } + + u_socket_close(s); + + u_socket_stop(); + + return NULL; +} + +/********************************************************** + * + */ + +struct trace_rbug * +trace_rbug_start(struct trace_screen *tr_scr) +{ + struct trace_rbug *tr_rbug = MALLOC_STRUCT(trace_rbug); + if (!tr_rbug) + return NULL; + + tr_rbug->tr_scr = tr_scr; + tr_rbug->running = TRUE; + tr_rbug->thread = pipe_thread_create(trace_rbug_thread, tr_rbug); + + return tr_rbug; +} + +void +trace_rbug_stop(struct trace_rbug *tr_rbug) +{ + if (!tr_rbug) + return; + + tr_rbug->running = false; + pipe_thread_wait(tr_rbug->thread); + + FREE(tr_rbug); + + return; +} diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index bc14248eeb..920f418ebf 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -826,24 +826,26 @@ trace_screen_destroy(struct pipe_screen *_screen) trace_dump_call_end(); trace_dump_trace_end(); + if (tr_scr->rbug) + trace_rbug_stop(tr_scr->rbug); + screen->destroy(screen); FREE(tr_scr); } - boolean trace_enabled(void) { return trace; } - struct pipe_screen * trace_screen_create(struct pipe_screen *screen) { struct trace_screen *tr_scr; struct pipe_winsys *winsys; + boolean rbug = FALSE; if(!screen) goto error1; @@ -855,6 +857,11 @@ trace_screen_create(struct pipe_screen *screen) trace = TRUE; } + if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) { + trace = TRUE; + rbug = TRUE; + } + if (!trace) goto error1; @@ -915,6 +922,9 @@ trace_screen_create(struct pipe_screen *screen) trace_dump_ret(ptr, screen); trace_dump_call_end(); + if (rbug) + tr_scr->rbug = trace_rbug_start(tr_scr); + return &tr_scr->base; #if 0 diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 7fae182985..dba8cd7c65 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -57,6 +57,9 @@ struct trace_screen struct pipe_screen *screen; + /* remote debugger */ + struct trace_rbug *rbug; + pipe_mutex list_mutex; int num_buffers; int num_contexts; @@ -71,21 +74,34 @@ struct trace_screen }; +/* + * tr_rbug.c + */ + + +struct trace_rbug; + +struct trace_rbug * +trace_rbug_start(struct trace_screen *tr_scr); + +void +trace_rbug_stop(struct trace_rbug *tr_rbug); + + /* * tr_screen.c */ + boolean trace_enabled(void); struct trace_screen * trace_screen(struct pipe_screen *screen); - struct pipe_screen * trace_screen_create(struct pipe_screen *screen); - void trace_screen_user_buffer_update(struct pipe_screen *screen, struct pipe_buffer *buffer); @@ -106,6 +122,7 @@ trace_screen_user_buffer_update(struct pipe_screen *screen, pipe_mutex_unlock(tr_scr->list_mutex); \ } while (0) + #ifdef __cplusplus } #endif -- cgit v1.2.3 From bc302b2a33ceffe454bcf443daa0ac1edc118e9b Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 22 May 2009 09:39:02 -0700 Subject: Use separate $(MINSTALL) for installing libraries The special feature of bin/minstall to copy symlinks is only ever needed when installing libraries which may have .so symlinks. All the headers and directories can use a normal install program. These two modes are separated as $(INSTALL) and $(MINSTALL) to allow the user (or autoconf) to override installing normal files as they please. An autoconf check for the install program has been added and will be used in preference to minstall when available. Fixes bug 16053. --- src/gallium/winsys/drm/Makefile.template | 2 +- src/gallium/winsys/drm/intel/xorg/Makefile | 2 +- src/gallium/winsys/drm/radeon/xorg/Makefile | 2 +- src/gallium/winsys/egl_xlib/Makefile | 2 +- src/gallium/winsys/xlib/Makefile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 9f92cb4207..985e5a861f 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -118,7 +118,7 @@ clean: install: $(LIBNAME) $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) include depend diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile index b1b6b9362b..d9aa5d54e1 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/winsys/drm/intel/xorg/Makefile @@ -39,6 +39,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile index 6ffd4a3a54..0241625f69 100644 --- a/src/gallium/winsys/drm/radeon/xorg/Makefile +++ b/src/gallium/winsys/drm/radeon/xorg/Makefile @@ -37,6 +37,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 8646ee3b52..a33a50ec22 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -74,7 +74,7 @@ depend: $(ALL_SOURCES) install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) @if [ -e $(TOP)/$(LIB_DIR) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 04309e67ee..522f6dc5ae 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -90,7 +90,7 @@ install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ fi -- cgit v1.2.3 From 1fa023ae48c31176434f5ad4691eae347e7a395f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 1 Jun 2009 12:04:29 -0700 Subject: r300-gallium: Slightly hacky fix for glxgears-style TCL. --- src/gallium/drivers/r300/r300_state_derived.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 7ae339cf97..2477b30822 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -163,6 +163,13 @@ static void r300_vs_tab_routes(struct r300_context* r300, vinfo->hwfmt[3] |= (4 << (3 * i)); } + /* Handle the case where the vertex shader will be generating some of + * the attribs based on its inputs. */ + if (r300screen->caps->has_tcl && + info->num_inputs < info->num_outputs) { + vinfo->num_attribs = info->num_inputs; + } + draw_compute_vertex_size(vinfo); } -- cgit v1.2.3 From 427554211b5b8ab2c6afcd5bd574ac97fb3457da Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 1 Jun 2009 14:28:57 -0600 Subject: draw: reset extra_vp_outputs.slot to zero in widepoint_flush() Fixes a crash when clearing the window with a quad after drawing large points. We were asking the draw module how many vertex shader outputs there were and got 3 instead of 2. This led to creating vertices with too many attributes and trying to read invalid memory. We reset extra_vp_outputs.slot to zero in the aaline/aapoint stage's flush functions already. This omission was just an oversight in the wide_point stage. --- src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index 49034ae86a..d84bab9eaa 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -253,6 +253,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags ) { stage->point = widepoint_first_point; stage->next->flush( stage->next, flags ); + stage->draw->extra_vp_outputs.slot = 0; } -- cgit v1.2.3 From 557d2bb42397bb5511c32b4a2b39c7978e69dc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 1 Jun 2009 20:20:48 -0700 Subject: wgl: Destroy the framebuffer when the window is destroyed. --- .../state_trackers/wgl/shared/stw_framebuffer.c | 72 ++++++++++++++-------- 1 file changed, 48 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 768cef3db6..de37d135df 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -45,6 +45,41 @@ #include "stw_tls.h" +struct stw_framebuffer * +stw_framebuffer_from_hwnd_locked( + HWND hwnd ) +{ + struct stw_framebuffer *fb; + + for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next) + if (fb->hWnd == hwnd) + break; + + return fb; +} + + +static INLINE void +stw_framebuffer_destroy_locked( + struct stw_framebuffer *fb ) +{ + struct stw_framebuffer **link; + + link = &stw_dev->fb_head; + while (*link != fb) + link = &(*link)->next; + assert(*link); + *link = fb->next; + fb->next = NULL; + + st_unreference_framebuffer(fb->stfb); + + pipe_mutex_destroy( fb->mutex ); + + FREE( fb ); +} + + /** * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx @@ -69,9 +104,7 @@ stw_call_window_proc( struct stw_framebuffer *fb; pipe_mutex_lock( stw_dev->mutex ); - for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next) - if (fb->hWnd == pParams->hwnd) - break; + fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd ); pipe_mutex_unlock( stw_dev->mutex ); if(fb) { @@ -90,6 +123,18 @@ stw_call_window_proc( } } + if (pParams->message == WM_DESTROY) { + struct stw_framebuffer *fb; + + pipe_mutex_lock( stw_dev->mutex ); + + fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd ); + if(fb) + stw_framebuffer_destroy_locked(fb); + + pipe_mutex_unlock( stw_dev->mutex ); + } + return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam); } @@ -212,27 +257,6 @@ stw_framebuffer_resize( } -static INLINE void -stw_framebuffer_destroy_locked( - struct stw_framebuffer *fb ) -{ - struct stw_framebuffer **link; - - link = &stw_dev->fb_head; - while (*link != fb) - link = &(*link)->next; - assert(*link); - *link = fb->next; - fb->next = NULL; - - st_unreference_framebuffer(fb->stfb); - - pipe_mutex_destroy( fb->mutex ); - - FREE( fb ); -} - - void stw_framebuffer_cleanup( void ) { -- cgit v1.2.3 From 69a765df1c3bf6acc549a5a6a047bbde16988721 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 19:48:40 -0700 Subject: draw: avoid leaking tokens when building pstipple fragment shader Add missing FREE() after MALLOC(). --- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 9287fc130e..bc63b700de 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -358,6 +358,7 @@ generate_pstip_fs(struct pstip_stage *pstip) pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs); + FREE((void *)pstip_fs.tokens); return TRUE; } -- cgit v1.2.3 From 003cfd4dd2491675058c53a8f59553f2443be349 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 20:15:28 -0700 Subject: draw: free more token arrays The AA line and point code also needs to free token arrays after building driver shaders. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 9 ++++++--- src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 9fedeef2d3..0d322b0aab 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -60,8 +60,6 @@ struct aaline_fragment_shader struct pipe_shader_state state; void *driver_fs; void *aaline_fs; - void *aapoint_fs; /* not yet */ - void *sprite_fs; /* not yet */ uint sampler_unit; int generic_attrib; /**< texcoord/generic used for texture */ }; @@ -373,10 +371,15 @@ generate_aaline_fs(struct aaline_stage *aaline) aaline->fs->aaline_fs = aaline->driver_create_fs_state(aaline->pipe, &aaline_fs); if (aaline->fs->aaline_fs == NULL) - return FALSE; + goto fail; aaline->fs->generic_attrib = transform.maxGeneric + 1; + FREE((void *)aaline_fs.tokens); return TRUE; + +fail: + FREE((void *)aaline_fs.tokens); + return FALSE; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 66839f7873..729cf75e65 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -523,11 +523,15 @@ generate_aapoint_fs(struct aapoint_stage *aapoint) aapoint->fs->aapoint_fs = aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs); if (aapoint->fs->aapoint_fs == NULL) - return FALSE; + goto fail; aapoint->fs->generic_attrib = transform.maxGeneric + 1; - + FREE((void *)aapoint_fs.tokens); return TRUE; + +fail: + FREE((void *)aapoint_fs.tokens); + return FALSE; } -- cgit v1.2.3 From 1aef032d438aaa40ec28bf279ad5c089370773f0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 20:16:20 -0700 Subject: gallium/draw: Free specialized versions of driver shaders The pstipple, aaline and aapoint code would create specialized versions of shaders and upload them to the driver -- but never free them. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 4 ++++ src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 5 +++++ src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 0d322b0aab..9f956715a2 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -819,6 +819,10 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs) struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs; /* pass-through */ aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs); + + if (aafs->aaline_fs) + aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs); + FREE(aafs); } diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 729cf75e65..ae1712fe12 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -829,8 +829,13 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs) { struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe); struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs; + /* pass-through */ aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs); + + if (aafs->aapoint_fs) + aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs); + FREE(aafs); } diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index bc63b700de..30a6d2919d 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -650,6 +650,10 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs) struct pstip_fragment_shader *aafs = (struct pstip_fragment_shader *) fs; /* pass-through */ pstip->driver_delete_fs_state(pstip->pipe, aafs->driver_fs); + + if (aafs->pstip_fs) + pstip->driver_delete_fs_state(pstip->pipe, aafs->pstip_fs); + FREE(aafs); } -- cgit v1.2.3 From c91df4c1534e2db2274b6d08e90470bf21a49e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 2 Jun 2009 11:46:06 -0700 Subject: util: Fix 24 to 32 bit expansion binary arithmetic expression. When approaching y = x * 0xffffffff / 0xffffff with bit arithmetic, the 8 least significant bits of y should come from the 8 most significant bits of x. --- src/gallium/auxiliary/util/u_tile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index f0a5a339eb..9becd9fea4 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1126,7 +1126,7 @@ pipe_get_tile_z(struct pipe_transfer *pt, for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 24-bit Z to 32-bit Z */ - pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff); + pDest[j] = (ptrc[j] << 8) | ((ptrc[j] >> 16) & 0xff); } pDest += dstStride; ptrc += pt->stride/4; -- cgit v1.2.3 From 840af5fd62edc01769cc3818702ea399a0c68c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 2 Jun 2009 11:46:53 -0700 Subject: util: Support Z24S8/Z24X8 -> unsigned conversion. --- src/gallium/auxiliary/util/u_tile.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 9becd9fea4..a2fcdad9e4 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1133,6 +1133,21 @@ pipe_get_tile_z(struct pipe_transfer *pt, } } break; + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + { + const uint *ptrc + = (const uint *)(map + y * pt->stride + x*4); + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + /* convert 24-bit Z to 32-bit Z */ + pDest[j] = (ptrc[j] & 0xffffff00) | (ptrc[j] & 0xff); + } + pDest += dstStride; + ptrc += pt->stride/4; + } + } + break; case PIPE_FORMAT_Z16_UNORM: { const ushort *ptrc -- cgit v1.2.3 From 45b77830eb6fa1b712b0416a27990ad8b6eaf78b Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Tue, 2 Jun 2009 22:23:17 +0200 Subject: r300-gallium: strip swtcl to the bare minimum This was originally taken from i915 and it shows. Basically most the stuff in r300_render.c was never needed and shouldn't have worked in the first place --- src/gallium/drivers/r300/r300_render.c | 56 +++++++++++++--------------------- 1 file changed, 22 insertions(+), 34 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 29b66cee7e..cd458d019a 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -45,11 +45,7 @@ struct r300_render { /* VBO */ struct pipe_buffer* vbo; - size_t vbo_size; - size_t vbo_offset; - void* vbo_map; size_t vbo_alloc_size; - size_t vbo_max_used; }; static INLINE struct r300_render* @@ -78,24 +74,21 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render, struct pipe_screen* screen = r300->context.screen; size_t size = (size_t)vertex_size * (size_t)count; - if (r300render->vbo) { + if (r300render->vbo && (size > r300render->vbo_alloc_size)) { pipe_buffer_reference(&r300render->vbo, NULL); } + + if (!r300render->vbo) { + r300render->vbo = pipe_buffer_create(screen, + 64, + PIPE_BUFFER_USAGE_VERTEX, + size); + } - r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size); - r300render->vbo_offset = 0; - r300render->vbo = pipe_buffer_create(screen, - 64, - PIPE_BUFFER_USAGE_VERTEX, - r300render->vbo_size); - + r300render->vbo_alloc_size = MAX2(size, r300render->vbo_alloc_size); r300render->vertex_size = vertex_size; - if (r300render->vbo) { - return TRUE; - } else { - return FALSE; - } + return (r300render->vbo) ? TRUE : FALSE; } static void* r300_render_map_vertices(struct vbuf_render* render) @@ -103,10 +96,8 @@ static void* r300_render_map_vertices(struct vbuf_render* render) struct r300_render* r300render = r300_render(render); struct pipe_screen* screen = r300render->r300->context.screen; - r300render->vbo_map = pipe_buffer_map(screen, r300render->vbo, - PIPE_BUFFER_USAGE_CPU_WRITE); - - return (unsigned char*)r300render->vbo_map + r300render->vbo_offset; + return (unsigned char*)pipe_buffer_map(screen, r300render->vbo, + PIPE_BUFFER_USAGE_CPU_WRITE); } static void r300_render_unmap_vertices(struct vbuf_render* render, @@ -116,9 +107,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render, struct r300_render* r300render = r300_render(render); struct pipe_screen* screen = r300render->r300->context.screen; - r300render->vbo_max_used = MAX2(r300render->vbo_max_used, - r300render->vertex_size * (max + 1)); - pipe_buffer_unmap(screen, r300render->vbo); } @@ -181,7 +169,6 @@ static void prepare_render(struct r300_render* render, unsigned count) CS_LOCALS(r300); r300->vbo = render->vbo; - r300->vbo_offset = render->vbo_offset; r300_emit_dirty_state(r300); } @@ -195,8 +182,6 @@ static void r300_render_draw_arrays(struct vbuf_render* render, CS_LOCALS(r300); - r300render->vbo_offset = start; - prepare_render(r300render, count); debug_printf("r300: Doing vbuf render, count %d\n", count); @@ -231,13 +216,14 @@ static void r300_render_draw(struct vbuf_render* render, return; } +/* index_map = pipe_buffer_map(screen, index_buffer, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(index_map, indices, count); pipe_buffer_unmap(screen, index_buffer); debug_printf("r300: Doing indexbuf render, count %d\n", count); -/* + BEGIN_CS(8); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | @@ -247,13 +233,15 @@ static void r300_render_draw(struct vbuf_render* render, OUT_CS_INDEX_RELOC(index_buffer, 0, count, RADEON_GEM_DOMAIN_GTT, 0, 0); END_CS; */ - BEGIN_CS(2 + count); - OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, count); + 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) | - r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); - for (i = 0; i < count; i++) { - index = indices[i]; - OUT_CS(index); + r300render->hwprim); + 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; } -- cgit v1.2.3 From 273117ceed47bff58a0f475dd36b37721e997f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 2 Jun 2009 16:41:45 -0700 Subject: util: Unsaved change missing from last commit. --- src/gallium/auxiliary/util/u_tile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index a2fcdad9e4..9747a55cbf 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1141,7 +1141,7 @@ pipe_get_tile_z(struct pipe_transfer *pt, for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 24-bit Z to 32-bit Z */ - pDest[j] = (ptrc[j] & 0xffffff00) | (ptrc[j] & 0xff); + pDest[j] = (ptrc[j] & 0xffffff00) | ((ptrc[j] >> 24) & 0xff); } pDest += dstStride; ptrc += pt->stride/4; -- cgit v1.2.3 From a64bbdaa3e0b036a880d6db65ceb4a66205062f1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Jun 2009 18:31:55 -0600 Subject: softpipe: fix incorrect tri vertex order for PIPE_PRIM_POLYGON rendering This fixes incorrect front/back-face orientation. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 329c92b8da..56f12b9810 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -420,8 +420,8 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) */ for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, - get_vert(vertex_buffer, i-0, stride), get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride), get_vert(vertex_buffer, 0, stride)); } break; -- cgit v1.2.3 From 086ecea179ed572c89aa77c5f465671a5cef87a7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Jun 2009 18:33:07 -0600 Subject: softpipe: separate case for PIPE_PRIM_POLYGON in sp_vbuf_draw() Because of flat shading, we can't use same code as PIPE_PRIM_TRIANGLE_FAN. This is a follow-on to commit a59575d8fbe8b0ca053cc8366ce7a42bc660158a. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 56f12b9810..06725fd09b 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -236,7 +236,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) } break; - case PIPE_PRIM_TRIANGLES: for (i = 2; i < nr; i += 3) { setup_tri( setup_ctx, @@ -256,7 +255,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, get_vert(vertex_buffer, indices[0], stride), @@ -264,6 +262,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + case PIPE_PRIM_QUADS: for (i = 3; i < nr; i += 4) { setup_tri( setup_ctx, @@ -277,6 +276,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + case PIPE_PRIM_QUAD_STRIP: for (i = 3; i < nr; i += 2) { setup_tri( setup_ctx, @@ -290,6 +290,16 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + + case PIPE_PRIM_POLYGON: + for (i = 2; i < nr; i += 1) { + setup_tri( setup_ctx, + get_vert(vertex_buffer, indices[0-1], stride), + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[0], stride)); + } + break; + default: assert(0); } -- cgit v1.2.3 From 45e744dddc8a8f3b42610bfa512bc296bd5264bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Jun 2009 13:08:52 -0600 Subject: tgsi: increase MAX_LABELS to 4096 --- src/gallium/auxiliary/tgsi/tgsi_exec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 0b4b2a6fb6..da22baad3e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -34,7 +34,7 @@ extern "C" { #endif -#define MAX_LABELS 1024 +#define MAX_LABELS (4 * 1024) /**< basically, max instructions */ #define NUM_CHANNELS 4 /* R,G,B,A */ #define QUAD_SIZE 4 /* 4 pixel/quad */ -- cgit v1.2.3 From 6907650211d136ee7cb5a8914c32196d35a75bf3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Jun 2009 13:12:13 -0600 Subject: softpipe: fix incorrect tri vertex order for PIPE_PRIM_POLYGON rendering This fixes incorrect front/back-face orientation. (cherry picked from commit a64bbdaa3e0b036a880d6db65ceb4a66205062f1) --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 329c92b8da..56f12b9810 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -420,8 +420,8 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) */ for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, - get_vert(vertex_buffer, i-0, stride), get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride), get_vert(vertex_buffer, 0, stride)); } break; -- cgit v1.2.3 From 9424d81d18770f0c436f0876dffe07cf7c094db4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Jun 2009 13:13:14 -0600 Subject: softpipe: separate case for PIPE_PRIM_POLYGON in sp_vbuf_draw() Because of flat shading, we can't use same code as PIPE_PRIM_TRIANGLE_FAN. This is a follow-on to commit a59575d8fbe8b0ca053cc8366ce7a42bc660158a. (cherry picked from commit 086ecea179ed572c89aa77c5f465671a5cef87a7) --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 56f12b9810..06725fd09b 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -236,7 +236,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) } break; - case PIPE_PRIM_TRIANGLES: for (i = 2; i < nr; i += 3) { setup_tri( setup_ctx, @@ -256,7 +255,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, get_vert(vertex_buffer, indices[0], stride), @@ -264,6 +262,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + case PIPE_PRIM_QUADS: for (i = 3; i < nr; i += 4) { setup_tri( setup_ctx, @@ -277,6 +276,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + case PIPE_PRIM_QUAD_STRIP: for (i = 3; i < nr; i += 2) { setup_tri( setup_ctx, @@ -290,6 +290,16 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) get_vert(vertex_buffer, indices[i-0], stride)); } break; + + case PIPE_PRIM_POLYGON: + for (i = 2; i < nr; i += 1) { + setup_tri( setup_ctx, + get_vert(vertex_buffer, indices[0-1], stride), + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[0], stride)); + } + break; + default: assert(0); } -- cgit v1.2.3 From 384bbe278d7e634cf1af5f786bfbde651c14df62 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Jun 2009 14:36:10 +0100 Subject: rbug: Update rbug protocol with new context calls --- src/gallium/auxiliary/rbug/rbug_context.c | 267 +++++++++++++++++++++++++--- src/gallium/auxiliary/rbug/rbug_context.h | 80 +++++++-- src/gallium/auxiliary/rbug/rbug_core.h | 4 + src/gallium/auxiliary/rbug/rbug_demarshal.c | 14 +- src/gallium/auxiliary/rbug/rbug_proto.h | 7 +- src/gallium/auxiliary/rbug/rbug_shader.h | 4 +- src/gallium/auxiliary/rbug/rbug_texture.h | 3 +- 7 files changed, 336 insertions(+), 43 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c index b4fad5300d..787f650f71 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.c +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -110,8 +110,9 @@ int rbug_send_context_info(struct rbug_connection *__con, return __ret; } -int rbug_send_context_block_draw(struct rbug_connection *__con, +int rbug_send_context_draw_block(struct rbug_connection *__con, rbug_context_t context, + rbug_block_t block, uint32_t *__serial) { uint32_t __len = 0; @@ -121,6 +122,7 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, LEN(8); /* header */ LEN(8); /* context */ + LEN(4); /* block */ /* align */ PAD(__len, 8); @@ -129,9 +131,10 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_BLOCK_DRAW)); + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK)); WRITE(4, uint32_t, ((uint32_t)(__len / 4))); WRITE(8, rbug_context_t, context); /* context */ + WRITE(4, rbug_block_t, block); /* block */ /* final pad */ PAD(__pos, 8); @@ -139,7 +142,7 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_BLOCK_DRAW, __len); + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len); rbug_connection_write(__con, __data, __len); __ret = rbug_connection_send_finish(__con, __serial); } @@ -148,8 +151,50 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, return __ret; } -int rbug_send_context_unblock_draw(struct rbug_connection *__con, +int rbug_send_context_draw_step(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_t step, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(4); /* step */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(4, rbug_block_t, step); /* step */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_STEP, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_draw_unblock(struct rbug_connection *__con, rbug_context_t context, + rbug_block_t unblock, uint32_t *__serial) { uint32_t __len = 0; @@ -159,6 +204,7 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, LEN(8); /* header */ LEN(8); /* context */ + LEN(4); /* unblock */ /* align */ PAD(__len, 8); @@ -167,9 +213,10 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW)); + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)); WRITE(4, uint32_t, ((uint32_t)(__len / 4))); WRITE(8, rbug_context_t, context); /* context */ + WRITE(4, rbug_block_t, unblock); /* unblock */ /* final pad */ PAD(__pos, 8); @@ -177,7 +224,48 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_UNBLOCK_DRAW, __len); + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_UNBLOCK, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_flush(struct rbug_connection *__con, + rbug_context_t context, + int32_t flags, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(4); /* flags */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(4, int32_t, flags); /* flags */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len); rbug_connection_write(__con, __data, __len); __ret = rbug_connection_send_finish(__con, __serial); } @@ -230,10 +318,13 @@ int rbug_send_context_list_reply(struct rbug_connection *__con, int rbug_send_context_info_reply(struct rbug_connection *__con, uint32_t serial, + rbug_shader_t vertex, + rbug_shader_t fragment, rbug_texture_t *cbufs, uint32_t cbufs_len, - rbug_texture_t zdbuf, - uint8_t blocked, + rbug_texture_t zsbuf, + rbug_block_t blocker, + rbug_block_t blocked, uint32_t *__serial) { uint32_t __len = 0; @@ -243,9 +334,12 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, LEN(8); /* header */ LEN(4); /* serial */ + LEN(8); /* vertex */ + LEN(8); /* fragment */ LEN_ARRAY(8, cbufs); /* cbufs */ - LEN(8); /* zdbuf */ - LEN(1); /* blocked */ + LEN(8); /* zsbuf */ + LEN(4); /* blocker */ + LEN(4); /* blocked */ /* align */ PAD(__len, 8); @@ -257,9 +351,12 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY)); WRITE(4, uint32_t, ((uint32_t)(__len / 4))); WRITE(4, uint32_t, serial); /* serial */ + WRITE(8, rbug_shader_t, vertex); /* vertex */ + WRITE(8, rbug_shader_t, fragment); /* fragment */ WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ - WRITE(8, rbug_texture_t, zdbuf); /* zdbuf */ - WRITE(1, uint8_t, blocked); /* blocked */ + WRITE(8, rbug_texture_t, zsbuf); /* zsbuf */ + WRITE(4, rbug_block_t, blocker); /* blocker */ + WRITE(4, rbug_block_t, blocked); /* blocked */ /* final pad */ PAD(__pos, 8); @@ -276,6 +373,47 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, return __ret; } +int rbug_send_context_draw_blocked(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_t block, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(4); /* block */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(4, rbug_block_t, block); /* block */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCKED, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header) { uint32_t len = 0; @@ -329,16 +467,72 @@ struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_h return ret; } -struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header) +struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_draw_block *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCK) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(4, rbug_block_t, block); /* block */ + + return ret; +} + +struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_draw_step *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_STEP) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(4, rbug_block_t, step); /* step */ + + return ret; +} + +struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header) { uint32_t len = 0; uint32_t pos = 0; uint8_t *data = NULL; - struct rbug_proto_context_block_draw *ret; + struct rbug_proto_context_draw_unblock *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_BLOCK_DRAW) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK) return NULL; pos = 0; @@ -352,20 +546,21 @@ struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct ret->header.opcode = header->opcode; READ(8, rbug_context_t, context); /* context */ + READ(4, rbug_block_t, unblock); /* unblock */ return ret; } -struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header) +struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header) { uint32_t len = 0; uint32_t pos = 0; uint8_t *data = NULL; - struct rbug_proto_context_unblock_draw *ret; + struct rbug_proto_context_flush *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_FLUSH) return NULL; pos = 0; @@ -379,6 +574,7 @@ struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(str ret->header.opcode = header->opcode; READ(8, rbug_context_t, context); /* context */ + READ(4, int32_t, flags); /* flags */ return ret; } @@ -434,9 +630,40 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct ret->header.opcode = header->opcode; READ(4, uint32_t, serial); /* serial */ + READ(8, rbug_shader_t, vertex); /* vertex */ + READ(8, rbug_shader_t, fragment); /* fragment */ READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ - READ(8, rbug_texture_t, zdbuf); /* zdbuf */ - READ(1, uint8_t, blocked); /* blocked */ + READ(8, rbug_texture_t, zsbuf); /* zsbuf */ + READ(4, rbug_block_t, blocker); /* blocker */ + READ(4, rbug_block_t, blocked); /* blocked */ + + return ret; +} + +struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_draw_blocked *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCKED) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(4, rbug_block_t, block); /* block */ return ret; } diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h index bcd2a826a7..9f1726d64d 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.h +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -39,9 +39,13 @@ #define _RBUG_PROTO_CONTEXT_H_ #include "rbug/rbug_proto.h" -#include "rbug/rbug_texture.h" +#include "rbug/rbug_core.h" -typedef uint64_t rbug_context_t; +typedef enum +{ + RBUG_BLOCK_BEFORE = 1, + RBUG_BLOCK_AFTER = 2, +} rbug_block_t; struct rbug_proto_context_list { @@ -54,16 +58,32 @@ struct rbug_proto_context_info rbug_context_t context; }; -struct rbug_proto_context_block_draw +struct rbug_proto_context_draw_block +{ + struct rbug_header header; + rbug_context_t context; + rbug_block_t block; +}; + +struct rbug_proto_context_draw_step { struct rbug_header header; rbug_context_t context; + rbug_block_t step; }; -struct rbug_proto_context_unblock_draw +struct rbug_proto_context_draw_unblock { struct rbug_header header; rbug_context_t context; + rbug_block_t unblock; +}; + +struct rbug_proto_context_flush +{ + struct rbug_header header; + rbug_context_t context; + int32_t flags; }; struct rbug_proto_context_list_reply @@ -78,10 +98,20 @@ struct rbug_proto_context_info_reply { struct rbug_header header; uint32_t serial; + rbug_shader_t vertex; + rbug_shader_t fragment; rbug_texture_t *cbufs; uint32_t cbufs_len; - rbug_texture_t zdbuf; - uint8_t blocked; + rbug_texture_t zsbuf; + rbug_block_t blocker; + rbug_block_t blocked; +}; + +struct rbug_proto_context_draw_blocked +{ + struct rbug_header header; + rbug_context_t context; + rbug_block_t block; }; int rbug_send_context_list(struct rbug_connection *__con, @@ -91,14 +121,26 @@ int rbug_send_context_info(struct rbug_connection *__con, rbug_context_t context, uint32_t *__serial); -int rbug_send_context_block_draw(struct rbug_connection *__con, +int rbug_send_context_draw_block(struct rbug_connection *__con, rbug_context_t context, + rbug_block_t block, uint32_t *__serial); -int rbug_send_context_unblock_draw(struct rbug_connection *__con, +int rbug_send_context_draw_step(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_t step, + uint32_t *__serial); + +int rbug_send_context_draw_unblock(struct rbug_connection *__con, rbug_context_t context, + rbug_block_t unblock, uint32_t *__serial); +int rbug_send_context_flush(struct rbug_connection *__con, + rbug_context_t context, + int32_t flags, + uint32_t *__serial); + int rbug_send_context_list_reply(struct rbug_connection *__con, uint32_t serial, rbug_context_t *contexts, @@ -107,22 +149,36 @@ int rbug_send_context_list_reply(struct rbug_connection *__con, int rbug_send_context_info_reply(struct rbug_connection *__con, uint32_t serial, + rbug_shader_t vertex, + rbug_shader_t fragment, rbug_texture_t *cbufs, uint32_t cbufs_len, - rbug_texture_t zdbuf, - uint8_t blocked, + rbug_texture_t zsbuf, + rbug_block_t blocker, + rbug_block_t blocked, uint32_t *__serial); +int rbug_send_context_draw_blocked(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_t block, + uint32_t *__serial); + struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header); struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header); -struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header); +struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header); -struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header); +struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header); + +struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header); + +struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header); struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header); struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header); +struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header); + #endif diff --git a/src/gallium/auxiliary/rbug/rbug_core.h b/src/gallium/auxiliary/rbug/rbug_core.h index d63a8c8076..99a36a0163 100644 --- a/src/gallium/auxiliary/rbug/rbug_core.h +++ b/src/gallium/auxiliary/rbug/rbug_core.h @@ -40,6 +40,10 @@ #include "rbug/rbug_proto.h" +typedef uint64_t rbug_shader_t; +typedef uint64_t rbug_context_t; +typedef uint64_t rbug_texture_t; + struct rbug_proto_noop { struct rbug_header header; diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c index e3c0954f9e..80894f4a64 100644 --- a/src/gallium/auxiliary/rbug/rbug_demarshal.c +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -59,14 +59,20 @@ struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) return (struct rbug_header *)rbug_demarshal_context_list(header); case RBUG_OP_CONTEXT_INFO: return (struct rbug_header *)rbug_demarshal_context_info(header); - case RBUG_OP_CONTEXT_BLOCK_DRAW: - return (struct rbug_header *)rbug_demarshal_context_block_draw(header); - case RBUG_OP_CONTEXT_UNBLOCK_DRAW: - return (struct rbug_header *)rbug_demarshal_context_unblock_draw(header); + case RBUG_OP_CONTEXT_DRAW_BLOCK: + return (struct rbug_header *)rbug_demarshal_context_draw_block(header); + case RBUG_OP_CONTEXT_DRAW_STEP: + return (struct rbug_header *)rbug_demarshal_context_draw_step(header); + case RBUG_OP_CONTEXT_DRAW_UNBLOCK: + return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header); + case RBUG_OP_CONTEXT_FLUSH: + return (struct rbug_header *)rbug_demarshal_context_flush(header); case RBUG_OP_CONTEXT_LIST_REPLY: return (struct rbug_header *)rbug_demarshal_context_list_reply(header); case RBUG_OP_CONTEXT_INFO_REPLY: return (struct rbug_header *)rbug_demarshal_context_info_reply(header); + case RBUG_OP_CONTEXT_DRAW_BLOCKED: + return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); case RBUG_OP_SHADER_LIST: return (struct rbug_header *)rbug_demarshal_shader_list(header); case RBUG_OP_SHADER_INFO: diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h index 8fa1836771..db9fa68500 100644 --- a/src/gallium/auxiliary/rbug/rbug_proto.h +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -52,10 +52,13 @@ enum rbug_opcode RBUG_OP_TEXTURE_READ_REPLY = -259, RBUG_OP_CONTEXT_LIST = 512, RBUG_OP_CONTEXT_INFO = 513, - RBUG_OP_CONTEXT_BLOCK_DRAW = 514, - RBUG_OP_CONTEXT_UNBLOCK_DRAW = 515, + RBUG_OP_CONTEXT_DRAW_BLOCK = 514, + RBUG_OP_CONTEXT_DRAW_STEP = 515, + RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516, + RBUG_OP_CONTEXT_FLUSH = 518, RBUG_OP_CONTEXT_LIST_REPLY = -512, RBUG_OP_CONTEXT_INFO_REPLY = -513, + RBUG_OP_CONTEXT_DRAW_BLOCKED = 517, RBUG_OP_SHADER_LIST = 768, RBUG_OP_SHADER_INFO = 769, RBUG_OP_SHADER_DISABLE = 770, diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h index fe1b9ac0f7..b5d886781d 100644 --- a/src/gallium/auxiliary/rbug/rbug_shader.h +++ b/src/gallium/auxiliary/rbug/rbug_shader.h @@ -39,9 +39,7 @@ #define _RBUG_PROTO_SHADER_H_ #include "rbug/rbug_proto.h" -#include "rbug/rbug_context.h" - -typedef uint64_t rbug_shader_t; +#include "rbug/rbug_core.h" struct rbug_proto_shader_list { diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h index 2bcc3566f3..fbb247e1d4 100644 --- a/src/gallium/auxiliary/rbug/rbug_texture.h +++ b/src/gallium/auxiliary/rbug/rbug_texture.h @@ -39,8 +39,7 @@ #define _RBUG_PROTO_TEXTURE_H_ #include "rbug/rbug_proto.h" - -typedef uint64_t rbug_texture_t; +#include "rbug/rbug_core.h" struct rbug_proto_texture_list { -- cgit v1.2.3 From 76b3072e9b7b8f98e926d531c0d63a0cb294e56d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Jun 2009 23:40:10 +0100 Subject: trace/rbug: Add new contexts functions to trace rbug --- src/gallium/drivers/trace/tr_context.c | 57 +++++++++++ src/gallium/drivers/trace/tr_context.h | 11 +++ src/gallium/drivers/trace/tr_rbug.c | 169 ++++++++++++++++++++++++++++++++- 3 files changed, 236 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 2ad5ca4998..b04cc2ce56 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -113,6 +113,28 @@ trace_context_set_edgeflags(struct pipe_context *_pipe, } +static INLINE void +trace_context_draw_block(struct trace_context *tr_ctx, int flag) +{ + pipe_mutex_lock(tr_ctx->draw_mutex); + + if (tr_ctx->draw_blocker & flag) { + tr_ctx->draw_blocked |= flag; + + trace_rbug_notify_draw_blocked(tr_ctx); + } + + /* wait for rbug to clear the blocked flag */ + while (tr_ctx->draw_blocked & flag) { + tr_ctx->draw_blocked |= flag; + pipe_mutex_unlock(tr_ctx->draw_mutex); + /* TODO sleep or use conditional */ + pipe_mutex_lock(tr_ctx->draw_mutex); + } + + pipe_mutex_unlock(tr_ctx->draw_mutex); +} + static INLINE boolean trace_context_draw_arrays(struct pipe_context *_pipe, unsigned mode, unsigned start, unsigned count) @@ -124,6 +146,8 @@ trace_context_draw_arrays(struct pipe_context *_pipe, if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) return 0; + trace_context_draw_block(tr_ctx, 1); + trace_dump_call_begin("pipe_context", "draw_arrays"); trace_dump_arg(ptr, pipe); @@ -137,6 +161,8 @@ trace_context_draw_arrays(struct pipe_context *_pipe, trace_dump_call_end(); + trace_context_draw_block(tr_ctx, 2); + return result; } @@ -156,6 +182,8 @@ trace_context_draw_elements(struct pipe_context *_pipe, if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) return 0; + trace_context_draw_block(tr_ctx, 1); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_elements"); @@ -173,6 +201,8 @@ trace_context_draw_elements(struct pipe_context *_pipe, trace_dump_call_end(); + trace_context_draw_block(tr_ctx, 2); + return result; } @@ -196,6 +226,8 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) return 0; + trace_context_draw_block(tr_ctx, 1); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_range_elements"); @@ -218,6 +250,8 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, trace_dump_call_end(); + trace_context_draw_block(tr_ctx, 2); + return result; } @@ -782,6 +816,19 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe, struct pipe_framebuffer_state unwrapped_state; unsigned i; + { + tr_ctx->curr.nr_cbufs = state->nr_cbufs; + for (i = 0; i < state->nr_cbufs; i++) + if (state->cbufs[i]) + tr_ctx->curr.cbufs[i] = trace_texture(state->cbufs[i]->texture); + else + tr_ctx->curr.cbufs[i] = NULL; + if (state->zsbuf) + tr_ctx->curr.zsbuf = trace_texture(state->zsbuf->texture); + else + tr_ctx->curr.zsbuf = NULL; + } + /* Unwrap the input state */ memcpy(&unwrapped_state, state, sizeof(unwrapped_state)); for(i = 0; i < state->nr_cbufs; ++i) @@ -1113,6 +1160,12 @@ trace_is_buffer_referenced( struct pipe_context *_pipe, return referenced; } +static const struct debug_named_value rbug_blocker_flags[] = { + {"before", 1}, + {"after", 2}, + {NULL, 0}, +}; + struct pipe_context * trace_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) @@ -1134,6 +1187,10 @@ trace_context_create(struct pipe_screen *_screen, if(!tr_ctx) goto error1; + tr_ctx->draw_blocker = debug_get_flags_option("RBUG_BLOCK", + rbug_blocker_flags, + 0); + pipe_mutex_init(tr_ctx->draw_mutex); pipe_mutex_init(tr_ctx->list_mutex); make_empty_list(&tr_ctx->shaders); diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 86827f97b2..770e975a14 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -50,8 +50,16 @@ struct trace_context struct { struct trace_shader *fs; struct trace_shader *vs; + + unsigned nr_cbufs; + struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS]; + struct trace_texture *zsbuf; } curr; + pipe_mutex draw_mutex; + int draw_blocker; + int draw_blocked; + /* for list on screen */ struct tr_list list; @@ -75,6 +83,9 @@ struct pipe_context * trace_context_create(struct pipe_screen *screen, struct pipe_context *pipe); +void +trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx); + #ifdef __cplusplus } diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c index 1b26f60da4..db9de8f3c4 100644 --- a/src/gallium/drivers/trace/tr_rbug.c +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -288,6 +288,147 @@ trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, return 0; } +static int +trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS]; + int i; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + pipe_mutex_lock(tr_ctx->draw_mutex); + trace_dump_call_lock(); + + for (i = 0; i < tr_ctx->curr.nr_cbufs; i++) + cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]); + + rbug_send_context_info_reply(tr_rbug->con, serial, + VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs), + cbufs, tr_ctx->curr.nr_cbufs, VOID2U64(tr_ctx->curr.zsbuf), + tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL); + + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_ctx->draw_mutex); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_draw_block(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_block *block = (struct rbug_proto_context_draw_block *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, block->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->draw_mutex); + tr_ctx->draw_blocker |= block->block; + pipe_mutex_unlock(tr_ctx->draw_mutex); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_step *step = (struct rbug_proto_context_draw_step *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, step->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->draw_mutex); + tr_ctx->draw_blocked &= ~step->step; + pipe_mutex_unlock(tr_ctx->draw_mutex); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_unblock *unblock = (struct rbug_proto_context_draw_unblock *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, unblock->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->draw_mutex); + tr_ctx->draw_blocked &= ~unblock->unblock; + tr_ctx->draw_blocker &= ~unblock->unblock; + pipe_mutex_unlock(tr_ctx->draw_mutex); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_flush(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, flush->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + trace_dump_call_lock(); + + tr_ctx->pipe->flush(tr_ctx->pipe, flush->flags, NULL); + + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + static int trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) { @@ -512,6 +653,21 @@ trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32 case RBUG_OP_CONTEXT_LIST: ret = trace_rbug_context_list(tr_rbug, header, serial); break; + case RBUG_OP_CONTEXT_INFO: + ret = trace_rbug_context_info(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_BLOCK: + ret = trace_rbug_context_draw_block(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_STEP: + ret = trace_rbug_context_draw_step(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_UNBLOCK: + ret = trace_rbug_context_draw_unblock(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_FLUSH: + ret = trace_rbug_context_flush(tr_rbug, header, serial); + break; case RBUG_OP_SHADER_LIST: ret = trace_rbug_shader_list(tr_rbug, header, serial); break; @@ -610,7 +766,7 @@ PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug) struct trace_rbug * trace_rbug_start(struct trace_screen *tr_scr) { - struct trace_rbug *tr_rbug = MALLOC_STRUCT(trace_rbug); + struct trace_rbug *tr_rbug = CALLOC_STRUCT(trace_rbug); if (!tr_rbug) return NULL; @@ -634,3 +790,14 @@ trace_rbug_stop(struct trace_rbug *tr_rbug) return; } + +void +trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx) +{ + struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); + struct trace_rbug *tr_rbug = tr_scr->rbug; + + if (tr_rbug && tr_rbug->con) + rbug_send_context_draw_blocked(tr_rbug->con, + VOID2U64(tr_ctx), tr_ctx->draw_blocked, NULL); +} -- cgit v1.2.3 From d4c578ae415623bdbc12885f93405b43141cc09a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 5 Jun 2009 02:57:19 +0100 Subject: gallium: Make pipe thread say if it has condvars or not --- src/gallium/include/pipe/p_thread.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h index de55e99ed4..df6d38904a 100644 --- a/src/gallium/include/pipe/p_thread.h +++ b/src/gallium/include/pipe/p_thread.h @@ -43,6 +43,8 @@ #include /* POSIX threads headers */ #include /* for perror() */ +#define PIPE_THREAD_HAVE_CONDVAR + typedef pthread_t pipe_thread; #define PIPE_THREAD_ROUTINE( name, param ) \ -- cgit v1.2.3 From 61ffba44fd70abefd22366aa296b7afb04c6767a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 5 Jun 2009 03:01:34 +0100 Subject: trace/rbug: Use condvar on system that has it for blocking --- src/gallium/drivers/trace/tr_context.c | 5 +++++ src/gallium/drivers/trace/tr_context.h | 1 + src/gallium/drivers/trace/tr_rbug.c | 8 ++++++++ 3 files changed, 14 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index b04cc2ce56..dd5cca58dd 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -127,9 +127,13 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag) /* wait for rbug to clear the blocked flag */ while (tr_ctx->draw_blocked & flag) { tr_ctx->draw_blocked |= flag; +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex); +#else pipe_mutex_unlock(tr_ctx->draw_mutex); /* TODO sleep or use conditional */ pipe_mutex_lock(tr_ctx->draw_mutex); +#endif } pipe_mutex_unlock(tr_ctx->draw_mutex); @@ -1191,6 +1195,7 @@ trace_context_create(struct pipe_screen *_screen, rbug_blocker_flags, 0); pipe_mutex_init(tr_ctx->draw_mutex); + pipe_condvar_init(tr_ctx->draw_cond); pipe_mutex_init(tr_ctx->list_mutex); make_empty_list(&tr_ctx->shaders); diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 770e975a14..0c2bf27689 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -56,6 +56,7 @@ struct trace_context struct trace_texture *zsbuf; } curr; + pipe_condvar draw_cond; pipe_mutex draw_mutex; int draw_blocker; int draw_blocked; diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c index db9de8f3c4..e2de108009 100644 --- a/src/gallium/drivers/trace/tr_rbug.c +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -371,6 +371,10 @@ trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *hea tr_ctx->draw_blocked &= ~step->step; pipe_mutex_unlock(tr_ctx->draw_mutex); +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_broadcast(tr_ctx->draw_cond); +#endif + pipe_mutex_unlock(tr_scr->list_mutex); return 0; @@ -397,6 +401,10 @@ trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header * tr_ctx->draw_blocker &= ~unblock->unblock; pipe_mutex_unlock(tr_ctx->draw_mutex); +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_broadcast(tr_ctx->draw_cond); +#endif + pipe_mutex_unlock(tr_scr->list_mutex); return 0; -- cgit v1.2.3 From 04cef8a03799aa88ebfa1c391e29f8d2ea020d95 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 15:26:07 +1000 Subject: nouveau: call nouveau_pushbuf directly rather than going through nvws --- src/gallium/drivers/nouveau/nouveau_push.h | 30 +++++++++++++++------- src/gallium/drivers/nouveau/nouveau_stateobj.h | 26 +++++++++++-------- src/gallium/drivers/nouveau/nouveau_winsys.h | 6 ----- src/gallium/drivers/nv30/nv30_screen.c | 2 +- src/gallium/drivers/nv40/nv40_screen.c | 2 +- src/gallium/drivers/nv50/nv50_screen.c | 2 +- .../winsys/drm/nouveau/drm/nouveau_winsys.c | 24 ----------------- 7 files changed, 39 insertions(+), 53 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_push.h b/src/gallium/drivers/nouveau/nouveau_push.h index 54ef1c1291..afe4668fcd 100644 --- a/src/gallium/drivers/nouveau/nouveau_push.h +++ b/src/gallium/drivers/nouveau/nouveau_push.h @@ -26,25 +26,36 @@ #define BEGIN_RING(obj,mthd,size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \ - pc->nvws->push_flush(pc->nvws, ((size) + 1), NULL); \ + struct nouveau_channel *chan = pc->nvws->channel; \ + if (chan->pushbuf->remaining < ((size) + 1)) \ + nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \ - pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \ + chan->pushbuf->remaining -= ((size) + 1); \ } while(0) #define BEGIN_RING_NI(obj,mthd,size) do { \ BEGIN_RING(obj, (mthd) | 0x40000000, (size)); \ } while(0) +static inline void +DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) +{ + nouveau_pushbuf_flush(chan, 0); + if (fence) + *fence = NULL; +} + #define FIRE_RING(fence) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - pc->nvws->push_flush(pc->nvws, 0, fence); \ + DO_FIRE_RING(pc->nvws->channel, fence); \ } while(0) #define OUT_RELOC(bo,data,flags,vor,tor) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - pc->nvws->push_reloc(pc->nvws, pc->nvws->channel->pushbuf->cur++, \ - (bo), (data), (flags), (vor), (tor)); \ + struct nouveau_channel *chan = pc->nvws->channel; \ + nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, \ + pc->nvws->get_bo(bo), \ + (data), (flags), (vor), (tor)); \ } while(0) /* Raw data + flags depending on FB/TT buffer */ @@ -72,11 +83,12 @@ /* A reloc which'll recombine into a NV_DMA_METHOD packet header */ #define OUT_RELOCm(bo, flags, obj, mthd, size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \ - pc->nvws->push_flush(pc->nvws->channel, ((size) + 1), NULL); \ + struct nouveau_channel *chan = pc->nvws->channel; \ + if (chan->pushbuf->remaining < ((size) + 1)) \ + nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \ (flags), 0, 0); \ - pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \ + chan->pushbuf->remaining -= ((size) + 1); \ } while(0) #endif diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index a54820e851..fbb05db7df 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -114,15 +114,16 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) nr = so->cur - so->push; if (pb->remaining < nr) - nvws->push_flush(nvws, nr, NULL); + nouveau_pushbuf_flush(nvws->channel, nr); pb->remaining -= nr; memcpy(pb->cur, so->push, nr * 4); for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nvws->push_reloc(nvws, pb->cur + r->offset, r->bo, - r->data, r->flags, r->vor, r->tor); + nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur + r->offset, + nvws->get_bo(r->bo), r->data, + r->flags, r->vor, r->tor); } pb->cur += nr; } @@ -138,19 +139,22 @@ so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) i = so->cur_reloc << 1; if (nvws->channel->pushbuf->remaining < i) - nvws->push_flush(nvws, i, NULL); + nouveau_pushbuf_flush(nvws->channel, i); nvws->channel->pushbuf->remaining -= i; for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nvws->push_reloc(nvws, pb->cur++, r->bo, r->packet, - (r->flags & (NOUVEAU_BO_VRAM | - NOUVEAU_BO_GART | - NOUVEAU_BO_RDWR)) | - NOUVEAU_BO_DUMMY, 0, 0); - nvws->push_reloc(nvws, pb->cur++, r->bo, r->data, - r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor); + nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, + nvws->get_bo(r->bo), r->packet, + (r->flags & (NOUVEAU_BO_VRAM | + NOUVEAU_BO_GART | + NOUVEAU_BO_RDWR)) | + NOUVEAU_BO_DUMMY, 0, 0); + nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, + nvws->get_bo(r->bo), r->data, + r->flags | NOUVEAU_BO_DUMMY, + r->vor, r->tor); } } diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index ff7dd1c51c..762c3a2a21 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -34,12 +34,6 @@ struct nouveau_winsys { struct nouveau_resource **); void (*res_free)(struct nouveau_resource **); - int (*push_reloc)(struct nouveau_winsys *, void *ptr, - struct pipe_buffer *, uint32_t data, - uint32_t flags, uint32_t vor, uint32_t tor); - int (*push_flush)(struct nouveau_winsys *, unsigned size, - struct pipe_fence_handle **fence); - int (*grobj_alloc)(struct nouveau_winsys *, int grclass, struct nouveau_grobj **); void (*grobj_free)(struct nouveau_grobj **); diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index d395c5e1b7..772eb78566 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -303,7 +303,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref(NULL, &so); - nvws->push_flush(nvws, 0, NULL); + nouveau_pushbuf_flush(nvws->channel, 0); screen->pipe.winsys = ws; screen->pipe.destroy = nv30_screen_destroy; diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 0d4baefaea..5030c3ecbc 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -283,7 +283,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref(NULL, &so); - nvws->push_flush(nvws, 0, NULL); + nouveau_pushbuf_flush(nvws->channel, 0); screen->pipe.winsys = ws; screen->pipe.destroy = nv40_screen_destroy; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index a7981a3615..425ac92d9f 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -400,7 +400,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref (so, &screen->static_init); so_ref (NULL, &so); - nvws->push_flush(nvws, 0, NULL); + nouveau_pushbuf_flush(nvws->channel, 0); return &screen->pipe; } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c index e3175fd775..2e0148543d 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c @@ -30,27 +30,6 @@ nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass, return 0; } -static int -nouveau_pipe_push_reloc(struct nouveau_winsys *nvws, void *ptr, - struct pipe_buffer *buf, uint32_t data, - uint32_t flags, uint32_t vor, uint32_t tor) -{ - struct nouveau_bo *bo = nouveau_pipe_buffer(buf)->bo; - - return nouveau_pushbuf_emit_reloc(nvws->channel, ptr, bo, - data, flags, vor, tor); -} - -static int -nouveau_pipe_push_flush(struct nouveau_winsys *nvws, unsigned size, - struct pipe_fence_handle **fence) -{ - if (fence) - *fence = NULL; - - return nouveau_pushbuf_flush(nvws->channel, size); -} - static struct nouveau_bo * nouveau_pipe_get_bo(struct pipe_buffer *pb) { @@ -74,9 +53,6 @@ nouveau_winsys_new(struct pipe_winsys *ws) nvws->res_alloc = nouveau_resource_alloc; nvws->res_free = nouveau_resource_free; - nvws->push_reloc = nouveau_pipe_push_reloc; - nvws->push_flush = nouveau_pipe_push_flush; - nvws->grobj_alloc = nouveau_pipe_grobj_alloc; nvws->grobj_free = nouveau_grobj_free; -- cgit v1.2.3 From 072fdc1fd325256d87b182d4f55c8a5838119cf0 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 16:13:56 +1000 Subject: nouveau: pass nouveau_bo instead of pipe_buffer to so_ calls --- src/gallium/drivers/nouveau/nouveau_stateobj.h | 21 ++++++------- src/gallium/drivers/nv30/nv30_context.h | 2 ++ src/gallium/drivers/nv30/nv30_fragprog.c | 7 +++-- src/gallium/drivers/nv30/nv30_fragtex.c | 7 +++-- src/gallium/drivers/nv30/nv30_state_fb.c | 30 +++++++++--------- src/gallium/drivers/nv30/nv30_vbo.c | 14 +++++---- src/gallium/drivers/nv40/nv40_context.h | 2 ++ src/gallium/drivers/nv40/nv40_fragprog.c | 7 +++-- src/gallium/drivers/nv40/nv40_fragtex.c | 7 +++-- src/gallium/drivers/nv40/nv40_state_fb.c | 4 ++- src/gallium/drivers/nv40/nv40_vbo.c | 13 +++++--- src/gallium/drivers/nv50/nv50_context.h | 2 ++ src/gallium/drivers/nv50/nv50_program.c | 31 +++++++++---------- src/gallium/drivers/nv50/nv50_program.h | 2 +- src/gallium/drivers/nv50/nv50_screen.c | 42 ++++++++++++++++++-------- src/gallium/drivers/nv50/nv50_screen.h | 8 ++--- src/gallium/drivers/nv50/nv50_state_validate.c | 24 +++++++-------- src/gallium/drivers/nv50/nv50_tex.c | 9 ++++-- src/gallium/drivers/nv50/nv50_vbo.c | 5 +-- 19 files changed, 136 insertions(+), 101 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index fbb05db7df..de3ba9cf14 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -4,7 +4,7 @@ #include "util/u_debug.h" struct nouveau_stateobj_reloc { - struct pipe_buffer *bo; + struct nouveau_bo *bo; unsigned offset; unsigned packet; @@ -51,7 +51,7 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) { free(so->push); for (i = 0; i < so->cur_reloc; i++) - pipe_buffer_reference(&so->reloc[i].bo, NULL); + nouveau_bo_ref(NULL, &so->reloc[i].bo); free(so->reloc); free(so); } @@ -81,13 +81,13 @@ so_method(struct nouveau_stateobj *so, struct nouveau_grobj *gr, } static INLINE void -so_reloc(struct nouveau_stateobj *so, struct pipe_buffer *bo, +so_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo, unsigned data, unsigned flags, unsigned vor, unsigned tor) { struct nouveau_stateobj_reloc *r = &so->reloc[so->cur_reloc++]; r->bo = NULL; - pipe_buffer_reference(&r->bo, bo); + nouveau_bo_ref(bo, &r->bo); r->offset = so->cur - so->push; r->packet = so->cur_packet; r->data = data; @@ -122,8 +122,8 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) struct nouveau_stateobj_reloc *r = &so->reloc[i]; nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur + r->offset, - nvws->get_bo(r->bo), r->data, - r->flags, r->vor, r->tor); + r->bo, r->data, r->flags, r->vor, + r->tor); } pb->cur += nr; } @@ -145,15 +145,14 @@ so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, - nvws->get_bo(r->bo), r->packet, + nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, + r->packet, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, - nvws->get_bo(r->bo), r->data, - r->flags | NOUVEAU_BO_DUMMY, + nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, + r->data, r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor); } } diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index 4229c0a0e1..5ba474cc33 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -19,6 +19,8 @@ #include "nouveau/nouveau_push.h" #include "nouveau/nouveau_stateobj.h" +#define nouveau_bo(pb) nv30->screen->nvws->get_bo(pb) + #include "nv30_state.h" #define NOUVEAU_ERR(fmt, args...) \ diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c index bdfe1425d2..956b450726 100644 --- a/src/gallium/drivers/nv30/nv30_fragprog.c +++ b/src/gallium/drivers/nv30/nv30_fragprog.c @@ -855,9 +855,10 @@ nv30_fragprog_validate(struct nv30_context *nv30) so = so_new(8, 1); so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1); - so_reloc (so, fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, - NV34TCL_FP_ACTIVE_PROGRAM_DMA0, NV34TCL_FP_ACTIVE_PROGRAM_DMA1); + so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM | + NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW | + NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0, + NV34TCL_FP_ACTIVE_PROGRAM_DMA1); so_method(so, nv30->screen->rankine, NV34TCL_FP_CONTROL, 1); so_data (so, fp->fp_control); so_method(so, nv30->screen->rankine, NV34TCL_FP_REG_CONTROL, 1); diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index 8b6ab992d1..822e1d8def 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -61,6 +61,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) struct nv30_sampler_state *ps = nv30->tex_sampler[unit]; struct nv30_miptree *nv30mt = nv30->tex_miptree[unit]; struct pipe_texture *pt = &nv30mt->base; + struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer); struct nv30_texture_format *tf; struct nouveau_stateobj *so; uint32_t txf, txs , txp; @@ -106,9 +107,9 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) so = so_new(16, 2); so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8); - so_reloc (so, nv30mt->buffer, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); - so_reloc (so, nv30mt->buffer, txf, tex_flags | NOUVEAU_BO_OR, - NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1); + so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR, + NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1); so_data (so, ps->wrap); so_data (so, NV34TCL_TX_ENABLE_ENABLE | ps->en); so_data (so, txs); diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index fdc1cade90..1be916872f 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -80,36 +80,36 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) nv30mt = (struct nv30_miptree *)rt[0]->base.texture; so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1); - so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); + so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, + nv30->nvws->channel->vram->handle, + nv30->nvws->channel->gart->handle); so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2); so_data (so, pitch); - so_reloc (so, nv30mt->buffer, rt[0]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, nouveau_bo(nv30mt->buffer), rt[0]->base.offset, + rt_flags | NOUVEAU_BO_LOW, 0, 0); } if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) { nv30mt = (struct nv30_miptree *)rt[1]->base.texture; so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1); - so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); + so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, + nv30->nvws->channel->vram->handle, + nv30->nvws->channel->gart->handle); so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2); - so_reloc (so, nv30mt->buffer, rt[1]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset, + rt_flags | NOUVEAU_BO_LOW, 0, 0); so_data (so, rt[1]->pitch); } if (zeta_format) { nv30mt = (struct nv30_miptree *)zeta->base.texture; so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1); - so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); + so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, + nv30->nvws->channel->vram->handle, + nv30->nvws->channel->gart->handle); so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1); - so_reloc (so, nv30mt->buffer, zeta->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset, + rt_flags | NOUVEAU_BO_LOW, 0, 0); /* TODO: allocate LMA depth buffer */ } diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index 990a876382..b7d8c2e008 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -521,18 +521,20 @@ nv30_vbo_validate(struct nv30_context *nv30) return FALSE; } - so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset, - vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, - 0, NV34TCL_VTXBUF_ADDRESS_DMA1); + so_reloc(vtxbuf, nouveau_bo(vb->buffer), vb->buffer_offset + + ve->src_offset, vb_flags | NOUVEAU_BO_LOW | + NOUVEAU_BO_OR, 0, NV34TCL_VTXBUF_ADDRESS_DMA1); so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) | (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type)); } if (ib) { + struct nouveau_bo *bo = nouveau_bo(ib); + so_method(vtxbuf, rankine, NV34TCL_IDXBUF_ADDRESS, 2); - so_reloc (vtxbuf, ib, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0); - so_reloc (vtxbuf, ib, ib_format, vb_flags | NOUVEAU_BO_OR, - 0, NV34TCL_IDXBUF_FORMAT_DMA1); + so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0); + so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR, + 0, NV34TCL_IDXBUF_FORMAT_DMA1); } so_method(vtxbuf, rankine, 0x1710, 1); diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 97bc83292d..393b31c5f0 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -21,6 +21,8 @@ #include "nv40_state.h" +#define nouveau_bo(pb) nv40->screen->nvws->get_bo(pb) + #define NOUVEAU_ERR(fmt, args...) \ fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); #define NOUVEAU_MSG(fmt, args...) \ diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c index 16e40889ec..b45dfaa913 100644 --- a/src/gallium/drivers/nv40/nv40_fragprog.c +++ b/src/gallium/drivers/nv40/nv40_fragprog.c @@ -938,9 +938,10 @@ nv40_fragprog_validate(struct nv40_context *nv40) so = so_new(4, 1); so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1); - so_reloc (so, fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, - NV40TCL_FP_ADDRESS_DMA0, NV40TCL_FP_ADDRESS_DMA1); + so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM | + NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW | + NOUVEAU_BO_OR, NV40TCL_FP_ADDRESS_DMA0, + NV40TCL_FP_ADDRESS_DMA1); so_method(so, nv40->screen->curie, NV40TCL_FP_CONTROL, 1); so_data (so, fp->fp_control); so_ref(so, &fp->so); diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c index eb3002dc05..f6cdf31dfe 100644 --- a/src/gallium/drivers/nv40/nv40_fragtex.c +++ b/src/gallium/drivers/nv40/nv40_fragtex.c @@ -62,6 +62,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) { struct nv40_sampler_state *ps = nv40->tex_sampler[unit]; struct nv40_miptree *nv40mt = nv40->tex_miptree[unit]; + struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer); struct pipe_texture *pt = &nv40mt->base; struct nv40_texture_format *tf; struct nouveau_stateobj *so; @@ -108,9 +109,9 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) so = so_new(16, 2); so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8); - so_reloc (so, nv40mt->buffer, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); - so_reloc (so, nv40mt->buffer, txf, tex_flags | NOUVEAU_BO_OR, - NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1); + so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR, + NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1); so_data (so, ps->wrap); so_data (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en); so_data (so, txs); diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c index be618a306b..d8364ff993 100644 --- a/src/gallium/drivers/nv40/nv40_state_fb.c +++ b/src/gallium/drivers/nv40/nv40_state_fb.c @@ -2,12 +2,14 @@ #include "nouveau/nouveau_util.h" static struct pipe_buffer * -nv40_surface_buffer(struct pipe_surface *surface) +nv40_do_surface_buffer(struct pipe_surface *surface) { struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture; return mt->buffer; } +#define nv40_surface_buffer(ps) nouveau_bo(nv40_do_surface_buffer(ps)) + static boolean nv40_state_framebuffer_validate(struct nv40_context *nv40) { diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index f3518b2e4f..7add803df7 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -519,17 +519,20 @@ nv40_vbo_validate(struct nv40_context *nv40) return FALSE; } - so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset, - vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, - 0, NV40TCL_VTXBUF_ADDRESS_DMA1); + so_reloc(vtxbuf, nouveau_bo(vb->buffer), + vb->buffer_offset + ve->src_offset, + vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, + 0, NV40TCL_VTXBUF_ADDRESS_DMA1); so_data (vtxfmt, ((vb->stride << NV40TCL_VTXFMT_STRIDE_SHIFT) | (ncomp << NV40TCL_VTXFMT_SIZE_SHIFT) | type)); } if (ib) { + struct nouveau_bo *bo = nouveau_bo(ib); + so_method(vtxbuf, curie, NV40TCL_IDXBUF_ADDRESS, 2); - so_reloc (vtxbuf, ib, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0); - so_reloc (vtxbuf, ib, ib_format, vb_flags | NOUVEAU_BO_OR, + so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0); + so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR, 0, NV40TCL_IDXBUF_FORMAT_DMA1); } diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 7b67a75439..d960657066 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -23,6 +23,8 @@ #define NOUVEAU_MSG(fmt, args...) \ fprintf(stderr, "nouveau: "fmt, ##args); +#define nouveau_bo(pb) nv50->screen->nvws->get_bo(pb) + /* Constant buffer assignment */ #define NV50_CB_PMISC 0 #define NV50_CB_PVP 1 diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index aada285f2c..1576d4295e 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2288,15 +2288,15 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) { struct nouveau_channel *chan = nv50->screen->nvws->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct pipe_screen *screen = nv50->pipe.screen; struct nv50_program_exec *e; struct nouveau_stateobj *so; const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR; unsigned start, count, *up, *ptr; boolean upload = FALSE; - if (!p->buffer) { - p->buffer = screen->buffer_create(screen, 0x100, 0, p->exec_size * 4); + if (!p->bo) { + nouveau_bo_new(chan->device, NOUVEAU_BO_VRAM, 0x100, + p->exec_size * 4, &p->bo); upload = TRUE; } @@ -2345,8 +2345,8 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) so = so_new(4,2); so_method(so, nv50->screen->tesla, 0x1280, 3); - so_reloc (so, p->buffer, 0, flags | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, p->buffer, 0, flags | NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, p->bo, 0, flags | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, p->bo, 0, flags | NOUVEAU_BO_LOW, 0, 0); so_data (so, (NV50_CB_PUPLOAD << 16) | 0x0800); //(p->exec_size * 4)); start = 0; count = p->exec_size; @@ -2394,10 +2394,10 @@ nv50_vertprog_validate(struct nv50_context *nv50) so = so_new(13, 2); so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2); - so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | - NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | + NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | + NOUVEAU_BO_LOW, 0, 0); so_method(so, tesla, 0x1650, 2); so_data (so, p->cfg.vp.attr[0]); so_data (so, p->cfg.vp.attr[1]); @@ -2431,10 +2431,10 @@ nv50_fragprog_validate(struct nv50_context *nv50) so = so_new(64, 2); so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2); - so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | - NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | + NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | + NOUVEAU_BO_LOW, 0, 0); so_method(so, tesla, 0x1904, 4); so_data (so, p->cfg.fp.regs[0]); /* 0x01000404 / 0x00040404 */ so_data (so, 0x00000004); @@ -2461,8 +2461,6 @@ nv50_fragprog_validate(struct nv50_context *nv50) void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) { - struct pipe_screen *pscreen = nv50->pipe.screen; - while (p->exec_head) { struct nv50_program_exec *e = p->exec_head; @@ -2472,8 +2470,7 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) p->exec_tail = NULL; p->exec_size = 0; - if (p->buffer) - pipe_buffer_reference(&p->buffer, NULL); + nouveau_bo_ref(NULL, &p->bo); nv50->screen->nvws->res_free(&p->data[0]); nv50->screen->nvws->res_free(&p->data[1]); diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h index c650ecfc81..096e0476aa 100644 --- a/src/gallium/drivers/nv50/nv50_program.h +++ b/src/gallium/drivers/nv50/nv50_program.h @@ -27,7 +27,7 @@ struct nv50_program { struct nouveau_resource *data[2]; unsigned data_start[2]; - struct pipe_buffer *buffer; + struct nouveau_bo *bo; float *immd; unsigned immd_nr; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 425ac92d9f..b7e9df77db 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -160,10 +160,11 @@ struct pipe_screen * nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); + struct nouveau_device *dev = nvws->channel->device; struct nouveau_stateobj *so; - unsigned tesla_class = 0, ret; - unsigned chipset = nvws->channel->device->chipset; - int i; + unsigned chipset = dev->chipset; + unsigned tesla_class = 0; + int ret, i; if (!screen) return NULL; @@ -291,14 +292,21 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_data (so, 8); /* constant buffers for immediates and VP/FP parameters */ - screen->constbuf_misc[0] = - screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); - - screen->constbuf_parm[0] = - screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, + &screen->constbuf_misc[0]); + if (ret) { + nv50_screen_destroy(&screen->pipe); + return NULL; + } - screen->constbuf_parm[1] = - screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4); + for (i = 0; i < 2; i++) { + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, + &screen->constbuf_parm[i]); + if (ret) { + nv50_screen_destroy(&screen->pipe); + return NULL; + } + } if (nvws->res_init(&screen->immd_heap[0], 0, 128) || nvws->res_init(&screen->parm_heap[0], 0, 128) || @@ -352,7 +360,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) * blocks. At some point we *may* want to go the NVIDIA way of doing * things? */ - screen->tic = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4); + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic); + if (ret) { + nv50_screen_destroy(&screen->pipe); + return NULL; + } + so_method(so, screen->tesla, 0x1280, 3); so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); @@ -366,7 +379,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); so_data (so, 0x00000800); - screen->tsc = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4); + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc); + if (ret) { + nv50_screen_destroy(&screen->pipe); + return NULL; + } + so_method(so, screen->tesla, 0x1280, 3); so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index 31b8ef29c9..fa7d8d0f0d 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -15,14 +15,14 @@ struct nv50_screen { struct nouveau_grobj *m2mf; struct nouveau_notifier *sync; - struct pipe_buffer *constbuf_misc[1]; - struct pipe_buffer *constbuf_parm[2]; + struct nouveau_bo *constbuf_misc[1]; + struct nouveau_bo *constbuf_parm[2]; struct nouveau_resource *immd_heap[1]; struct nouveau_resource *parm_heap[2]; - struct pipe_buffer *tic; - struct pipe_buffer *tsc; + struct nouveau_bo *tic; + struct nouveau_bo *tsc; struct nouveau_stateobj *static_init; }; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index c13d3de1cb..d1f0ccdd8a 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -32,6 +32,8 @@ nv50_state_validate_fb(struct nv50_context *nv50) unsigned i, w, h, gw = 0; for (i = 0; i < fb->nr_cbufs; i++) { + struct nouveau_bo *bo = nouveau_bo(nv50_surface_buffer(fb->cbufs[i])); + if (!gw) { w = fb->cbufs[i]->width; h = fb->cbufs[i]->height; @@ -46,12 +48,10 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_data (so, fb->cbufs[i]->height); so_method(so, tesla, NV50TCL_RT_ADDRESS_HIGH(i), 5); - so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH | - NOUVEAU_BO_RDWR, 0, 0); - so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | - NOUVEAU_BO_RDWR, 0, 0); + so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM | + NOUVEAU_BO_HIGH | NOUVEAU_BO_RDWR, 0, 0); + so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM | + NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->cbufs[i]->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: so_data(so, 0xcf); @@ -73,6 +73,8 @@ nv50_state_validate_fb(struct nv50_context *nv50) } if (fb->zsbuf) { + struct nouveau_bo *bo = nouveau_bo(nv50_surface_buffer(fb->zsbuf)); + if (!gw) { w = fb->zsbuf->width; h = fb->zsbuf->height; @@ -83,12 +85,10 @@ nv50_state_validate_fb(struct nv50_context *nv50) } so_method(so, tesla, NV50TCL_ZETA_ADDRESS_HIGH, 5); - so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH | - NOUVEAU_BO_RDWR, 0, 0); - so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset, - NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | - NOUVEAU_BO_RDWR, 0, 0); + so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM | + NOUVEAU_BO_HIGH | NOUVEAU_BO_RDWR, 0, 0); + so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM | + NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->zsbuf->format) { case PIPE_FORMAT_Z24S8_UNORM: so_data(so, 0x16); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 775e9f30ef..86947faee3 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -26,8 +26,11 @@ #include "nouveau/nouveau_stateobj.h" static int -nv50_tex_construct(struct nouveau_stateobj *so, struct nv50_miptree *mt) +nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, + struct nv50_miptree *mt) { + struct nouveau_bo *bo = nouveau_bo(mt->buffer); + switch (mt->base.format) { case PIPE_FORMAT_A8R8G8B8_UNORM: so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | @@ -117,7 +120,7 @@ nv50_tex_construct(struct nouveau_stateobj *so, struct nv50_miptree *mt) return 1; } - so_reloc(so, mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | + so_reloc(so, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); so_data (so, 0xd0005000); so_data (so, 0x00300000); @@ -144,7 +147,7 @@ nv50_tex_validate(struct nv50_context *nv50) for (unit = 0; unit < nv50->miptree_nr; unit++) { struct nv50_miptree *mt = nv50->miptree[unit]; - if (nv50_tex_construct(so, mt)) { + if (nv50_tex_construct(nv50, so, mt)) { NOUVEAU_ERR("failed tex validate\n"); so_ref(NULL, &so); return; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 0749c90691..6f4981d1ff 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -212,6 +212,7 @@ nv50_vbo_validate(struct nv50_context *nv50) struct pipe_vertex_element *ve = &nv50->vtxelt[i]; struct pipe_vertex_buffer *vb = &nv50->vtxbuf[ve->vertex_buffer_index]; + struct nouveau_bo *bo = nouveau_bo(vb->buffer); switch (ve->src_format) { case PIPE_FORMAT_R32G32B32A32_FLOAT: @@ -240,10 +241,10 @@ nv50_vbo_validate(struct nv50_context *nv50) so_method(vtxbuf, tesla, 0x900 + (i * 16), 3); so_data (vtxbuf, 0x20000000 | vb->stride); - so_reloc (vtxbuf, vb->buffer, vb->buffer_offset + + so_reloc (vtxbuf, bo, vb->buffer_offset + ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (vtxbuf, vb->buffer, vb->buffer_offset + + so_reloc (vtxbuf, bo, vb->buffer_offset + ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); } -- cgit v1.2.3 From bc466be695913cd504cefddd857ac1cefda87a04 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 10:19:04 +1000 Subject: nouveau: add pipe_buffer/fence code to pipe drivers, move nv50 over --- src/gallium/drivers/nouveau/nouveau_screen.c | 242 +++++++++++++++++++++++++++ src/gallium/drivers/nouveau/nouveau_screen.h | 24 +++ src/gallium/drivers/nv50/nv50_context.h | 2 - src/gallium/drivers/nv50/nv50_query.c | 2 +- src/gallium/drivers/nv50/nv50_screen.c | 83 ++++----- src/gallium/drivers/nv50/nv50_screen.h | 4 +- src/gallium/drivers/nv50/nv50_surface.c | 6 +- src/gallium/drivers/nv50/nv50_transfer.c | 4 +- src/gallium/winsys/drm/nouveau/dri/Makefile | 3 +- 9 files changed, 309 insertions(+), 61 deletions(-) create mode 100644 src/gallium/drivers/nouveau/nouveau_screen.c create mode 100644 src/gallium/drivers/nouveau/nouveau_screen.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c new file mode 100644 index 0000000000..3cab83eec0 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -0,0 +1,242 @@ +#include +#include +#include + +#include + +#include "nouveau/nouveau_bo.h" +#include "nouveau_winsys.h" +#include "nouveau_screen.h" + +static const char * +nouveau_screen_get_name(struct pipe_screen *pscreen) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + static char buffer[128]; + + snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); + return buffer; +} + +static const char * +nouveau_screen_get_vendor(struct pipe_screen *pscreen) +{ + return "nouveau"; +} + +static struct pipe_buffer * +nouveau_screen_bo_skel(struct pipe_screen *pscreen, struct nouveau_bo *bo, + unsigned alignment, unsigned usage, unsigned size) +{ + struct pipe_buffer *pb; + + pb = CALLOC(1, sizeof(struct pipe_buffer)+sizeof(struct nouveau_bo *)); + if (!pb) { + nouveau_bo_ref(NULL, &bo); + return NULL; + } + + pipe_reference_init(&pb->reference, 1); + pb->screen = pscreen; + pb->alignment = alignment; + pb->usage = usage; + pb->size = size; + *(struct nouveau_bo **)(pb + 1) = bo; + return pb; +} + +static struct pipe_buffer * +nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment, + unsigned usage, unsigned size) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct nouveau_bo *bo = NULL; + uint32_t flags = NOUVEAU_BO_MAP; + int ret; + + if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER) + flags |= NOUVEAU_BO_GART; + else + if (usage & PIPE_BUFFER_USAGE_VERTEX) { + if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF)) + flags |= NOUVEAU_BO_GART; + } else + if (usage & PIPE_BUFFER_USAGE_INDEX) { + if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF)) + flags |= NOUVEAU_BO_GART; + } + + if (usage & PIPE_BUFFER_USAGE_PIXEL) { + if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE) + flags |= NOUVEAU_BO_GART; + if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE)) + flags |= NOUVEAU_BO_VRAM; + + if (dev->chipset == 0x50 || dev->chipset >= 0x80) { + flags |= NOUVEAU_BO_TILED; + if (usage & NOUVEAU_BUFFER_USAGE_ZETA) + flags |= NOUVEAU_BO_ZTILE; + } + } + + ret = nouveau_bo_new(dev, flags, alignment, size, &bo); + if (ret) + return NULL; + + return nouveau_screen_bo_skel(pscreen, bo, alignment, usage, size); +} + +static struct pipe_buffer * +nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct nouveau_bo *bo = NULL; + int ret; + + ret = nouveau_bo_user(dev, ptr, bytes, &bo); + if (ret) + return NULL; + + return nouveau_screen_bo_skel(pscreen, bo, 0, 0, bytes); +} + +static inline uint32_t +nouveau_screen_map_flags(unsigned pipe) +{ + uint32_t flags = 0; + + if (pipe & PIPE_BUFFER_USAGE_CPU_READ) + flags |= NOUVEAU_BO_RD; + if (pipe & PIPE_BUFFER_USAGE_CPU_WRITE) + flags |= NOUVEAU_BO_WR; +#ifdef NOUVEAU_BO_NOWAIT + if (pipe & PIPE_BUFFER_USAGE_DISCARD) + flags |= NOUVEAU_BO_INVAL; + + if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK) + flags |= NOUVEAU_BO_NOWAIT; + else + if (pipe & 0 /*PIPE_BUFFER_USAGE_UNSYNCHRONIZED*/) + flags |= NOUVEAU_BO_NOSYNC; +#endif + + return flags; +} + +static void * +nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned usage) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + int ret; + + ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage)); + if (ret) { + debug_printf("map failed: %d\n", ret); + return NULL; + } + + return bo->map; +} + +#ifdef NOUVEAU_BO_NOWAIT +static void * +nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned offset, unsigned length, unsigned usage) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + int ret; + + ret = nouveau_bo_map_range(bo, offset, length, + nouveau_screen_map_flags(usage)); + if (ret) { + debug_printf("map_range failed: %d\n", ret); + return NULL; + } + + return bo->map; +} + +static void +nouveau_screen_bo_map_flush(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned offset, unsigned length) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_map_flush(bo, offset, length); +} +#endif + +static void +nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct pipe_buffer *pb) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_unmap(bo); +} + +static void +nouveau_screen_bo_del(struct pipe_buffer *pb) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_ref(NULL, &bo); + FREE(pb); +} + +static void +nouveau_screen_fence_ref(struct pipe_screen *pscreen, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *pfence) +{ + *ptr = pfence; +} + +static int +nouveau_screen_fence_signalled(struct pipe_screen *screen, + struct pipe_fence_handle *pfence, + unsigned flags) +{ + return 0; +} + +static int +nouveau_screen_fence_finish(struct pipe_screen *screen, + struct pipe_fence_handle *pfence, + unsigned flags) +{ + return 0; +} + +int +nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) +{ + struct pipe_screen *pscreen = &screen->base; + + screen->device = dev; + + pscreen->get_name = nouveau_screen_get_name; + pscreen->get_vendor = nouveau_screen_get_vendor; + + pscreen->buffer_create = nouveau_screen_bo_new; + pscreen->user_buffer_create = nouveau_screen_bo_user; + pscreen->buffer_map = nouveau_screen_bo_map; +#ifdef NOUVEAU_BO_NOWAIT + pscreen->buffer_map_range = nouveau_screen_bo_map_range; + pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush; +#endif + pscreen->buffer_unmap = nouveau_screen_bo_unmap; + pscreen->buffer_destroy = nouveau_screen_bo_del; + + pscreen->fence_reference = nouveau_screen_fence_ref; + pscreen->fence_signalled = nouveau_screen_fence_signalled; + pscreen->fence_finish = nouveau_screen_fence_finish; + + return 0; +} + +void +nouveau_screen_fini(struct nouveau_screen *screen) +{ +} + diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h new file mode 100644 index 0000000000..cffba11762 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -0,0 +1,24 @@ +#ifndef __NOUVEAU_SCREEN_H__ +#define __NOUVEAU_SCREEN_H__ + +struct nouveau_screen { + struct pipe_screen base; + struct nouveau_device *device; +}; + +static inline struct nouveau_screen * +nouveau_screen(struct pipe_screen *pscreen) +{ + return (struct nouveau_screen *)pscreen; +} + +static inline struct nouveau_bo * +nouveau_bo(struct pipe_buffer *pb) +{ + return pb ? *(struct nouveau_bo **)(pb + 1) : NULL; +} + +int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *); +void nouveau_screen_fini(struct nouveau_screen *); + +#endif diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index d960657066..7b67a75439 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -23,8 +23,6 @@ #define NOUVEAU_MSG(fmt, args...) \ fprintf(stderr, "nouveau: "fmt, ##args); -#define nouveau_bo(pb) nv50->screen->nvws->get_bo(pb) - /* Constant buffer assignment */ #define NV50_CB_PMISC 0 #define NV50_CB_PVP 1 diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 35cebdbdc3..4d05eeac2c 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -90,7 +90,7 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) struct nouveau_channel *chan = nv50->screen->nvws->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); - struct nouveau_bo *bo = nv50->screen->nvws->get_bo(q->buffer); + struct nouveau_bo *bo = nouveau_bo(q->buffer); WAIT_RING (chan, 5); BEGIN_RING(chan, tesla, 0x1b00, 4); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index b7e9df77db..3b830847ca 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -22,8 +22,6 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" - #include "nv50_context.h" #include "nv50_screen.h" @@ -68,23 +66,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, return FALSE; } -static const char * -nv50_screen_get_name(struct pipe_screen *pscreen) -{ - struct nv50_screen *screen = nv50_screen(pscreen); - struct nouveau_device *dev = screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv50_screen_get_vendor(struct pipe_screen *pscreen) -{ - return "nouveau"; -} - static int nv50_screen_get_param(struct pipe_screen *pscreen, int param) { @@ -153,7 +134,10 @@ nv50_screen_get_paramf(struct pipe_screen *pscreen, int param) static void nv50_screen_destroy(struct pipe_screen *pscreen) { - FREE(pscreen); + struct nv50_screen *screen = nv50_screen(pscreen); + + nouveau_screen_fini(&screen->base); + FREE(screen); } struct pipe_screen * @@ -161,6 +145,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned chipset = dev->chipset; unsigned tesla_class = 0; @@ -168,13 +153,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) if (!screen) return NULL; + pscreen = &screen->base.base; + + ret = nouveau_screen_init(&screen->base, nvws->channel->device); + if (ret) { + nv50_screen_destroy(pscreen); + return NULL; + } + + /* Setup the pipe */ screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv50_screen_destroy; + pscreen->get_param = nv50_screen_get_param; + pscreen->get_paramf = nv50_screen_get_paramf; + pscreen->is_format_supported = nv50_screen_is_format_supported; + + nv50_screen_init_miptree_functions(pscreen); + nv50_transfer_init_screen_functions(pscreen); + /* DMA engine object */ ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf); if (ret) { NOUVEAU_ERR("Error creating M2MF object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -182,7 +185,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d); if (ret) { NOUVEAU_ERR("Error creating 2D object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -200,20 +203,20 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) break; default: NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } if (tesla_class == 0) { NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -221,26 +224,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } - /* Setup the pipe */ - screen->pipe.winsys = ws; - - screen->pipe.destroy = nv50_screen_destroy; - - screen->pipe.get_name = nv50_screen_get_name; - screen->pipe.get_vendor = nv50_screen_get_vendor; - screen->pipe.get_param = nv50_screen_get_param; - screen->pipe.get_paramf = nv50_screen_get_paramf; - - screen->pipe.is_format_supported = nv50_screen_is_format_supported; - - nv50_screen_init_miptree_functions(&screen->pipe); - nv50_transfer_init_screen_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - /* Static M2MF init */ so = so_new(32, 0); so_method(so, screen->m2mf, 0x0180, 3); @@ -295,7 +282,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, &screen->constbuf_misc[0]); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -303,7 +290,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, &screen->constbuf_parm[i]); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } } @@ -313,7 +300,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nvws->res_init(&screen->parm_heap[1], 0, 128)) { NOUVEAU_ERR("Error initialising constant buffers.\n"); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -362,7 +349,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) */ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -381,7 +368,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -420,6 +407,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_ref (NULL, &so); nouveau_pushbuf_flush(nvws->channel, 0); - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index fa7d8d0f0d..61e24a5b57 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -1,10 +1,10 @@ #ifndef __NV50_SCREEN_H__ #define __NV50_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" struct nv50_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index c0f0efe158..121eddfc83 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -54,14 +54,10 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) struct nv50_miptree *mt = nv50_miptree(ps->texture); struct nouveau_channel *chan = screen->nvws->channel; struct nouveau_grobj *eng2d = screen->eng2d; - struct nouveau_bo *bo; + struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer); int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); - bo = screen->nvws->get_bo(nv50_miptree(ps->texture)->buffer); - if (!bo) - return 1; - format = nv50_format(ps->format); if (format < 0) return 1; diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 28e7edd144..5f1e430ad1 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -27,8 +27,8 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, struct nouveau_winsys *nvws = screen->nvws; struct nouveau_channel *chan = nvws->channel; struct nouveau_grobj *m2mf = screen->m2mf; - struct nouveau_bo *src_bo = nvws->get_bo(src); - struct nouveau_bo *dst_bo = nvws->get_bo(dst); + struct nouveau_bo *src_bo = nouveau_bo(src); + struct nouveau_bo *dst_bo = nouveau_bo(dst); src_reloc |= NOUVEAU_BO_RD; dst_reloc |= NOUVEAU_BO_WR; diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile index 024ab150cb..0937f68c34 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile @@ -11,7 +11,8 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/nv20/libnv20.a \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a + $(TOP)/src/gallium/drivers/nv50/libnv50.a \ + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a DRIVER_SOURCES = -- cgit v1.2.3 From 74adb150d595a7bc3f769bd2520c98a07bbc8531 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:30:41 +1000 Subject: nv40: remove u_simple_screen usage --- src/gallium/drivers/nv40/nv40_context.h | 2 - src/gallium/drivers/nv40/nv40_screen.c | 69 +++++++++++++-------------------- src/gallium/drivers/nv40/nv40_screen.h | 4 +- src/gallium/drivers/nv40/nv40_surface.c | 5 ++- src/gallium/drivers/nv40/nv40_vbo.c | 2 +- 5 files changed, 32 insertions(+), 50 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 393b31c5f0..97bc83292d 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -21,8 +21,6 @@ #include "nv40_state.h" -#define nouveau_bo(pb) nv40->screen->nvws->get_bo(pb) - #define NOUVEAU_ERR(fmt, args...) \ fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); #define NOUVEAU_MSG(fmt, args...) \ diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 5030c3ecbc..3049bd8031 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -1,5 +1,4 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" #include "nv40_context.h" #include "nv40_screen.h" @@ -8,23 +7,6 @@ #define NV4X_GRCLASS4497_CHIPSETS 0x00005450 #define NV6X_GRCLASS4497_CHIPSETS 0x00000088 -static const char * -nv40_screen_get_name(struct pipe_screen *pscreen) -{ - struct nv40_screen *screen = nv40_screen(pscreen); - struct nouveau_device *dev = screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv40_screen_get_vendor(struct pipe_screen *pscreen) -{ - return "nouveau"; -} - static int nv40_screen_get_param(struct pipe_screen *pscreen, int param) { @@ -157,6 +139,8 @@ nv40_screen_destroy(struct pipe_screen *pscreen) nvws->notifier_free(&screen->sync); nvws->grobj_free(&screen->curie); + nouveau_screen_fini(&screen->base); + FREE(pscreen); } @@ -164,36 +148,49 @@ struct pipe_screen * nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned curie_class = 0; - unsigned chipset = nvws->channel->device->chipset; int ret; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv40_screen_destroy; + pscreen->get_param = nv40_screen_get_param; + pscreen->get_paramf = nv40_screen_get_paramf; + pscreen->is_format_supported = nv40_screen_surface_format_supported; + + nv40_screen_init_miptree_functions(pscreen); + nv40_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(nvws); screen->eng2d->buf = nv40_surface_buffer; /* 3D object */ - switch (chipset & 0xf0) { + switch (dev->chipset & 0xf0) { case 0x40: - if (NV4X_GRCLASS4097_CHIPSETS & (1 << (chipset & 0x0f))) + if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f))) curie_class = NV40TCL; else - if (NV4X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f))) + if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f))) curie_class = NV44TCL; break; case 0x60: - if (NV6X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f))) + if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f))) curie_class = NV44TCL; break; } if (!curie_class) { - NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", chipset); + NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", dev->chipset); return NULL; } @@ -207,7 +204,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv40_screen_destroy(&screen->pipe); + nv40_screen_destroy(pscreen); return NULL; } @@ -215,21 +212,21 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); - nv40_screen_destroy(&screen->pipe); + nv40_screen_destroy(pscreen); return NULL; } ret = nvws->res_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); - nv40_screen_destroy(&screen->pipe); + nv40_screen_destroy(pscreen); return NULL; } /* Vtxprog resources */ if (nvws->res_init(&screen->vp_exec_heap, 0, 512) || nvws->res_init(&screen->vp_data_heap, 0, 256)) { - nv40_screen_destroy(&screen->pipe); + nv40_screen_destroy(pscreen); return NULL; } @@ -285,20 +282,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_ref(NULL, &so); nouveau_pushbuf_flush(nvws->channel, 0); - screen->pipe.winsys = ws; - screen->pipe.destroy = nv40_screen_destroy; - - screen->pipe.get_name = nv40_screen_get_name; - screen->pipe.get_vendor = nv40_screen_get_vendor; - screen->pipe.get_param = nv40_screen_get_param; - screen->pipe.get_paramf = nv40_screen_get_paramf; - - screen->pipe.is_format_supported = nv40_screen_surface_format_supported; - - nv40_screen_init_miptree_functions(&screen->pipe); - nv40_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h index 7b503bd207..57b4c8fc46 100644 --- a/src/gallium/drivers/nv40/nv40_screen.h +++ b/src/gallium/drivers/nv40/nv40_screen.h @@ -1,11 +1,11 @@ #ifndef __NV40_SCREEN_H__ #define __NV40_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" #include "nv04/nv04_surface_2d.h" struct nv40_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c index 1a849da32d..a596547974 100644 --- a/src/gallium/drivers/nv40/nv40_surface.c +++ b/src/gallium/drivers/nv40/nv40_surface.c @@ -26,12 +26,13 @@ * **************************************************************************/ -#include "nv40_context.h" #include "pipe/p_defines.h" -#include "pipe/internal/p_winsys_screen.h" #include "pipe/p_inlines.h" + #include "util/u_tile.h" +#include "nv40_context.h" + static void nv40_surface_copy(struct pipe_context *pipe, struct pipe_surface *dest, unsigned destx, unsigned desty, diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 7add803df7..4abddba110 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -70,7 +70,7 @@ static boolean nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib, unsigned ib_size) { - struct pipe_screen *pscreen = &nv40->screen->pipe; + struct pipe_screen *pscreen = &nv40->screen->base.base; unsigned type; if (!ib) { -- cgit v1.2.3 From 901d7c3057d7ca3d12d5e417e376cb25ded0070c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:37:59 +1000 Subject: nv30: remove u_simple_screen usage --- src/gallium/drivers/nv30/nv30_context.h | 2 - src/gallium/drivers/nv30/nv30_screen.c | 70 +++++++++++++-------------------- src/gallium/drivers/nv30/nv30_screen.h | 5 ++- src/gallium/drivers/nv30/nv30_vbo.c | 2 +- 4 files changed, 31 insertions(+), 48 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index 5ba474cc33..4229c0a0e1 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -19,8 +19,6 @@ #include "nouveau/nouveau_push.h" #include "nouveau/nouveau_stateobj.h" -#define nouveau_bo(pb) nv30->screen->nvws->get_bo(pb) - #include "nv30_state.h" #define NOUVEAU_ERR(fmt, args...) \ diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 772eb78566..f516038b9c 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -1,5 +1,7 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" +#include "pipe/p_state.h" + +#include "nouveau/nouveau_screen.h" #include "nv30_context.h" #include "nv30_screen.h" @@ -8,23 +10,6 @@ #define NV34TCL_CHIPSET_3X_MASK 0x00000010 #define NV35TCL_CHIPSET_3X_MASK 0x000001e0 -static const char * -nv30_screen_get_name(struct pipe_screen *pscreen) -{ - struct nv30_screen *screen = nv30_screen(pscreen); - struct nouveau_device *dev = screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv30_screen_get_vendor(struct pipe_screen *pscreen) -{ - return "nouveau"; -} - static int nv30_screen_get_param(struct pipe_screen *pscreen, int param) { @@ -155,29 +140,42 @@ struct pipe_screen * nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned rankine_class = 0; - unsigned chipset = nvws->channel->device->chipset; int ret, i; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv30_screen_destroy; + pscreen->get_param = nv30_screen_get_param; + pscreen->get_paramf = nv30_screen_get_paramf; + pscreen->is_format_supported = nv30_screen_surface_format_supported; + + nv30_screen_init_miptree_functions(pscreen); + nv30_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(nvws); screen->eng2d->buf = nv30_surface_buffer; /* 3D object */ - switch (chipset & 0xf0) { + switch (dev->chipset & 0xf0) { case 0x30: - if (NV30TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) + if (NV30TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f))) rankine_class = 0x0397; else - if (NV34TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) + if (NV34TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f))) rankine_class = 0x0697; else - if (NV35TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f))) + if (NV35TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f))) rankine_class = 0x0497; break; default: @@ -185,7 +183,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } if (!rankine_class) { - NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", chipset); + NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", dev->chipset); return NULL; } @@ -199,7 +197,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv30_screen_destroy(&screen->pipe); + nv30_screen_destroy(pscreen); return NULL; } @@ -207,21 +205,21 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); - nv30_screen_destroy(&screen->pipe); + nv30_screen_destroy(pscreen); return NULL; } ret = nvws->res_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); - nv30_screen_destroy(&screen->pipe); + nv30_screen_destroy(pscreen); return NULL; } /* Vtxprog resources */ if (nvws->res_init(&screen->vp_exec_heap, 0, 256) || nvws->res_init(&screen->vp_data_heap, 0, 256)) { - nv30_screen_destroy(&screen->pipe); + nv30_screen_destroy(pscreen); return NULL; } @@ -305,19 +303,5 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_ref(NULL, &so); nouveau_pushbuf_flush(nvws->channel, 0); - screen->pipe.winsys = ws; - screen->pipe.destroy = nv30_screen_destroy; - - screen->pipe.get_name = nv30_screen_get_name; - screen->pipe.get_vendor = nv30_screen_get_vendor; - screen->pipe.get_param = nv30_screen_get_param; - screen->pipe.get_paramf = nv30_screen_get_paramf; - - screen->pipe.is_format_supported = nv30_screen_surface_format_supported; - - nv30_screen_init_miptree_functions(&screen->pipe); - nv30_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h index 8e36883975..5fbd998b53 100644 --- a/src/gallium/drivers/nv30/nv30_screen.h +++ b/src/gallium/drivers/nv30/nv30_screen.h @@ -1,11 +1,12 @@ #ifndef __NV30_SCREEN_H__ #define __NV30_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" + #include "nv04/nv04_surface_2d.h" struct nv30_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index b7d8c2e008..ff2bf6e71b 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -70,7 +70,7 @@ static boolean nv30_vbo_set_idxbuf(struct nv30_context *nv30, struct pipe_buffer *ib, unsigned ib_size) { - struct pipe_screen *pscreen = &nv30->screen->pipe; + struct pipe_screen *pscreen = &nv30->screen->base.base; unsigned type; if (!ib) { -- cgit v1.2.3 From 74c45add474862e9c4e5063d2c5173546366bfe6 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:44:20 +1000 Subject: nv20: remove u_simple_screen usage --- src/gallium/drivers/nv20/nv20_prim_vbuf.c | 2 +- src/gallium/drivers/nv20/nv20_screen.c | 58 +++++++++++-------------------- src/gallium/drivers/nv20/nv20_screen.h | 4 +-- 3 files changed, 23 insertions(+), 41 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c index 8aa342cd2d..8f9f27ebdc 100644 --- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c +++ b/src/gallium/drivers/nv20/nv20_prim_vbuf.c @@ -358,7 +358,7 @@ nv20_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); struct nv20_context *nv20 = nv20_render->nv20; - struct pipe_screen *pscreen = &nv20->screen->pipe; + struct pipe_screen *pscreen = &nv20->screen->base.base; if (nv20_render->pbuffer) { pipe_buffer_reference(&nv20_render->pbuffer, NULL); diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 7760ae27c0..6f3d73fe16 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -4,23 +4,6 @@ #include "nv20_context.h" #include "nv20_screen.h" -static const char * -nv20_screen_get_name(struct pipe_screen *screen) -{ - struct nv20_screen *nv20screen = nv20_screen(screen); - struct nouveau_device *dev = nv20screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv20_screen_get_vendor(struct pipe_screen *screen) -{ - return "nouveau"; -} - static int nv20_screen_get_param(struct pipe_screen *screen, int param) { @@ -140,26 +123,39 @@ struct pipe_screen * nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; unsigned kelvin_class = 0; - unsigned chipset = nvws->channel->device->chipset; int ret; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv20_screen_destroy; + pscreen->get_param = nv20_screen_get_param; + pscreen->get_paramf = nv20_screen_get_paramf; + pscreen->is_format_supported = nv20_screen_is_format_supported; + + nv20_screen_init_miptree_functions(pscreen); + nv20_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(nvws); screen->eng2d->buf = nv20_surface_buffer; /* 3D object */ - if (chipset >= 0x25) + if (dev->chipset >= 0x25) kelvin_class = NV25TCL; - else if (chipset >= 0x20) + else if (dev->chipset >= 0x20) kelvin_class = NV20TCL; - if (!kelvin_class || chipset >= 0x30) { - NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", chipset); + if (!kelvin_class || dev->chipset >= 0x30) { + NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", dev->chipset); return NULL; } @@ -173,24 +169,10 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv20_screen_destroy(&screen->pipe); + nv20_screen_destroy(pscreen); return NULL; } - screen->pipe.winsys = ws; - screen->pipe.destroy = nv20_screen_destroy; - - screen->pipe.get_name = nv20_screen_get_name; - screen->pipe.get_vendor = nv20_screen_get_vendor; - screen->pipe.get_param = nv20_screen_get_param; - screen->pipe.get_paramf = nv20_screen_get_paramf; - - screen->pipe.is_format_supported = nv20_screen_is_format_supported; - - nv20_screen_init_miptree_functions(&screen->pipe); - nv20_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv20/nv20_screen.h b/src/gallium/drivers/nv20/nv20_screen.h index d9fce2bced..fc7bb05033 100644 --- a/src/gallium/drivers/nv20/nv20_screen.h +++ b/src/gallium/drivers/nv20/nv20_screen.h @@ -1,11 +1,11 @@ #ifndef __NV20_SCREEN_H__ #define __NV20_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" #include "nv04/nv04_surface_2d.h" struct nv20_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; -- cgit v1.2.3 From 251c47117b6268e03f7dd033b3f98033272916f3 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:53:57 +1000 Subject: nv10: remove u_simple_screen usage --- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 2 +- src/gallium/drivers/nv10/nv10_screen.c | 67 +++++++++++-------------------- src/gallium/drivers/nv10/nv10_screen.h | 4 +- 3 files changed, 27 insertions(+), 46 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c index 089c236302..f16e343fa6 100644 --- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c +++ b/src/gallium/drivers/nv10/nv10_prim_vbuf.c @@ -203,7 +203,7 @@ nv10_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *pscreen = &nv10->screen->pipe; + struct pipe_screen *pscreen = &nv10->screen->base.base; assert(nv10_render->buffer); pipe_buffer_reference(&nv10_render->buffer, NULL); diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index 6532a93c7b..5c36bee6e2 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -1,26 +1,8 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" #include "nv10_context.h" #include "nv10_screen.h" -static const char * -nv10_screen_get_name(struct pipe_screen *screen) -{ - struct nv10_screen *nv10screen = nv10_screen(screen); - struct nouveau_device *dev = nv10screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv10_screen_get_vendor(struct pipe_screen *screen) -{ - return "nouveau"; -} - static int nv10_screen_get_param(struct pipe_screen *screen, int param) { @@ -140,30 +122,43 @@ struct pipe_screen * nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; unsigned celsius_class; - unsigned chipset = nvws->channel->device->chipset; int ret; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv10_screen_destroy; + pscreen->get_param = nv10_screen_get_param; + pscreen->get_paramf = nv10_screen_get_paramf; + pscreen->is_format_supported = nv10_screen_is_format_supported; + + nv10_screen_init_miptree_functions(pscreen); + nv10_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(nvws); screen->eng2d->buf = nv10_surface_buffer; /* 3D object */ - if (chipset>=0x20) - celsius_class=NV11TCL; - else if (chipset>=0x17) - celsius_class=NV17TCL; - else if (chipset>=0x11) - celsius_class=NV11TCL; + if (dev->chipset >= 0x20) + celsius_class = NV11TCL; + else if (dev->chipset >= 0x17) + celsius_class = NV17TCL; + else if (dev->chipset >= 0x11) + celsius_class = NV11TCL; else - celsius_class=NV10TCL; + celsius_class = NV10TCL; if (!celsius_class) { - NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", chipset); + NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", dev->chipset); return NULL; } @@ -177,24 +172,10 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv10_screen_destroy(&screen->pipe); + nv10_screen_destroy(pscreen); return NULL; } - screen->pipe.winsys = ws; - screen->pipe.destroy = nv10_screen_destroy; - - screen->pipe.get_name = nv10_screen_get_name; - screen->pipe.get_vendor = nv10_screen_get_vendor; - screen->pipe.get_param = nv10_screen_get_param; - screen->pipe.get_paramf = nv10_screen_get_paramf; - - screen->pipe.is_format_supported = nv10_screen_is_format_supported; - - nv10_screen_init_miptree_functions(&screen->pipe); - nv10_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv10/nv10_screen.h b/src/gallium/drivers/nv10/nv10_screen.h index ad829ee3fd..86b6d8def5 100644 --- a/src/gallium/drivers/nv10/nv10_screen.h +++ b/src/gallium/drivers/nv10/nv10_screen.h @@ -1,11 +1,11 @@ #ifndef __NV10_SCREEN_H__ #define __NV10_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" #include "nv04/nv04_surface_2d.h" struct nv10_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; -- cgit v1.2.3 From d4d584b16e21b24a473d3a31d361432b8fa0b945 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:57:53 +1000 Subject: nv04: remove u_simple_screen usage --- src/gallium/drivers/nv04/nv04_screen.c | 57 ++++++++++-------------------- src/gallium/drivers/nv04/nv04_screen.h | 4 +-- src/gallium/drivers/nv04/nv04_surface_2d.c | 14 ++++---- 3 files changed, 28 insertions(+), 47 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index f9f6d97426..308f7e5960 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -1,27 +1,9 @@ #include "pipe/p_screen.h" #include "pipe/p_inlines.h" -#include "util/u_simple_screen.h" #include "nv04_context.h" #include "nv04_screen.h" -static const char * -nv04_screen_get_name(struct pipe_screen *screen) -{ - struct nv04_screen *nv04screen = nv04_screen(screen); - struct nouveau_device *dev = nv04screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv04_screen_get_vendor(struct pipe_screen *screen) -{ - return "nouveau"; -} - static int nv04_screen_get_param(struct pipe_screen *screen, int param) { @@ -144,18 +126,31 @@ struct pipe_screen * nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; - unsigned chipset = nvws->channel->device->chipset; int ret; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; - if (chipset>=0x20) { + pscreen->winsys = ws; + pscreen->destroy = nv04_screen_destroy; + pscreen->get_param = nv04_screen_get_param; + pscreen->get_paramf = nv04_screen_get_paramf; + pscreen->is_format_supported = nv04_screen_is_format_supported; + + nv04_screen_init_miptree_functions(pscreen); + nv04_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + + if (dev->chipset >= 0x20) { fahrenheit_class = 0; sub3d_class = 0; - } else if (chipset>=0x10) { + } else if (dev->chipset >= 0x10) { fahrenheit_class = NV10_DX5_TEXTURED_TRIANGLE; sub3d_class = NV10_CONTEXT_SURFACES_3D; } else { @@ -164,7 +159,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } if (!fahrenheit_class) { - NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", chipset); + NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset); return NULL; } @@ -190,24 +185,10 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv04_screen_destroy(&screen->pipe); + nv04_screen_destroy(pscreen); return NULL; } - screen->pipe.winsys = ws; - screen->pipe.destroy = nv04_screen_destroy; - - screen->pipe.get_name = nv04_screen_get_name; - screen->pipe.get_vendor = nv04_screen_get_vendor; - screen->pipe.get_param = nv04_screen_get_param; - screen->pipe.get_paramf = nv04_screen_get_paramf; - - screen->pipe.is_format_supported = nv04_screen_is_format_supported; - - nv04_screen_init_miptree_functions(&screen->pipe); - nv04_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h index ee6fb6db44..11466b9442 100644 --- a/src/gallium/drivers/nv04/nv04_screen.h +++ b/src/gallium/drivers/nv04/nv04_screen.h @@ -1,11 +1,11 @@ #ifndef __NV04_SCREEN_H__ #define __NV04_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" #include "nv04_surface_2d.h" struct nv04_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; unsigned chipset; diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index f3a8d7efee..2133123582 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -99,8 +99,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *swzsurf = ctx->swzsurf; struct nouveau_grobj *sifm = ctx->sifm; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); const unsigned src_pitch = ((struct nv04_surface *)src)->pitch; const unsigned max_w = 1024; const unsigned max_h = 1024; @@ -169,8 +169,8 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, { struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *m2mf = ctx->m2mf; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned src_pitch = ((struct nv04_surface *)src)->pitch; unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; unsigned dst_offset = dst->offset + dy * dst_pitch + @@ -216,8 +216,8 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *blit = ctx->blit; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned src_pitch = ((struct nv04_surface *)src)->pitch; unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; int format; @@ -282,7 +282,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *rect = ctx->rect; - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; int cs2d_format, gdirect_format; -- cgit v1.2.3 From 1b207d9bb81ae3385e5658a81c71fbf2fe15c18f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 08:47:42 +1000 Subject: nouveau: call notifier/grobj etc funcs directly libdrm_nouveau is linked with the winsys, there's no good reason to do all this through yet another layer. --- src/gallium/drivers/nouveau/nouveau_screen.h | 1 + src/gallium/drivers/nouveau/nouveau_winsys.h | 27 --------- src/gallium/drivers/nv04/nv04_screen.c | 32 +++++++---- src/gallium/drivers/nv04/nv04_surface_2d.c | 1 + src/gallium/drivers/nv10/nv10_screen.c | 28 ++++++---- src/gallium/drivers/nv20/nv20_screen.c | 29 ++++++---- src/gallium/drivers/nv30/nv30_query.c | 25 ++++----- src/gallium/drivers/nv30/nv30_screen.c | 64 ++++++++++++---------- src/gallium/drivers/nv30/nv30_vertprog.c | 20 +++---- src/gallium/drivers/nv40/nv40_query.c | 25 ++++----- src/gallium/drivers/nv40/nv40_screen.c | 43 +++++++++------ src/gallium/drivers/nv40/nv40_vertprog.c | 19 +++---- src/gallium/drivers/nv50/nv50_program.c | 18 +++--- src/gallium/drivers/nv50/nv50_screen.c | 39 ++++++++----- .../winsys/drm/nouveau/drm/nouveau_winsys.c | 50 ----------------- 15 files changed, 195 insertions(+), 226 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index cffba11762..9968b07896 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -4,6 +4,7 @@ struct nouveau_screen { struct pipe_screen base; struct nouveau_device *device; + struct nouveau_channel *channel; }; static inline struct nouveau_screen * diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index 762c3a2a21..7998497240 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -27,33 +27,6 @@ struct nouveau_winsys { struct pipe_winsys *ws; struct nouveau_channel *channel; - - int (*res_init)(struct nouveau_resource **heap, unsigned start, - unsigned size); - int (*res_alloc)(struct nouveau_resource *heap, int size, void *priv, - struct nouveau_resource **); - void (*res_free)(struct nouveau_resource **); - - int (*grobj_alloc)(struct nouveau_winsys *, int grclass, - struct nouveau_grobj **); - void (*grobj_free)(struct nouveau_grobj **); - - int (*notifier_alloc)(struct nouveau_winsys *, int count, - struct nouveau_notifier **); - void (*notifier_free)(struct nouveau_notifier **); - void (*notifier_reset)(struct nouveau_notifier *, int id); - uint32_t (*notifier_status)(struct nouveau_notifier *, int id); - uint32_t (*notifier_retval)(struct nouveau_notifier *, int id); - int (*notifier_wait)(struct nouveau_notifier *, int id, - int status, double timeout); - - int (*surface_copy)(struct nouveau_winsys *, struct pipe_surface *, - unsigned, unsigned, struct pipe_surface *, - unsigned, unsigned, unsigned, unsigned); - int (*surface_fill)(struct nouveau_winsys *, struct pipe_surface *, - unsigned, unsigned, unsigned, unsigned, unsigned); - - struct nouveau_bo *(*get_bo)(struct pipe_buffer *); }; extern struct pipe_screen * diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 308f7e5960..98e2dafcd8 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -105,10 +105,9 @@ static void nv04_screen_destroy(struct pipe_screen *pscreen) { struct nv04_screen *screen = nv04_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->fahrenheit); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->fahrenheit); nv04_surface_2d_takedown(&screen->eng2d); FREE(pscreen); @@ -127,6 +126,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; int ret; @@ -135,6 +135,13 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv04_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -145,7 +152,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv04_screen_init_miptree_functions(pscreen); nv04_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); if (dev->chipset >= 0x20) { fahrenheit_class = 0; @@ -163,26 +169,30 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv04_surface_buffer; - /* 3D object */ - ret = nvws->grobj_alloc(nvws, fahrenheit_class, &screen->fahrenheit); + ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class, + &screen->fahrenheit); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return NULL; } + BIND_RING(chan, screen->fahrenheit, 7); /* 3D surface object */ - ret = nvws->grobj_alloc(nvws, sub3d_class, &screen->context_surfaces_3d); + ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class, + &screen->context_surfaces_3d); if (ret) { NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); return NULL; } + BIND_RING(chan, screen->context_surfaces_3d, 6); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv04_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv04_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index 2133123582..fcb6501411 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -4,6 +4,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_util.h" +#include "nouveau/nouveau_screen.h" #include "nv04_surface_2d.h" static INLINE int diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index 5c36bee6e2..f090d2b0b7 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -102,10 +102,9 @@ static void nv10_screen_destroy(struct pipe_screen *pscreen) { struct nv10_screen *screen = nv10_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->celsius); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->celsius); FREE(pscreen); } @@ -123,6 +122,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned celsius_class; int ret; @@ -131,6 +131,13 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv10_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -141,11 +148,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv10_screen_init_miptree_functions(pscreen); nv10_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv10_surface_buffer; /* 3D object */ if (dev->chipset >= 0x20) @@ -162,14 +164,20 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, celsius_class, &screen->celsius); + ret = nouveau_grobj_alloc(chan, 0xbeef0001, celsius_class, + &screen->celsius); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->celsius, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv10_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv10_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 6f3d73fe16..4d991852a1 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -1,5 +1,4 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" #include "nv20_context.h" #include "nv20_screen.h" @@ -103,10 +102,9 @@ static void nv20_screen_destroy(struct pipe_screen *pscreen) { struct nv20_screen *screen = nv20_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->kelvin); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->kelvin); FREE(pscreen); } @@ -124,6 +122,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned kelvin_class = 0; int ret; @@ -132,6 +131,13 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv20_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -142,11 +148,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv20_screen_init_miptree_functions(pscreen); nv20_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv20_surface_buffer; /* 3D object */ if (dev->chipset >= 0x25) @@ -159,14 +160,20 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, kelvin_class, &screen->kelvin); + ret = nouveau_grobj_alloc(chan, 0xbeef0097, kelvin_class, + &screen->kelvin); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->kelvin, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv20_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv20_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c index 2f974cf5c4..1d1c8a484e 100644 --- a/src/gallium/drivers/nv30/nv30_query.c +++ b/src/gallium/drivers/nv30/nv30_query.c @@ -29,11 +29,10 @@ nv30_query_create(struct pipe_context *pipe, unsigned query_type) static void nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) { - struct nv30_context *nv30 = nv30_context(pipe); struct nv30_query *q = nv30_query(pq); if (q->object) - nv30->nvws->res_free(&q->object); + nouveau_resource_free(&q->object); FREE(q); } @@ -54,9 +53,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) pipe->get_query_result(pipe, pq, 1, &tmp); } - if (nv30->nvws->res_alloc(nv30->screen->query_heap, 1, NULL, &q->object)) + if (nouveau_resource_alloc(nv30->screen->query_heap, 1, NULL, &q->object)) assert(0); - nv30->nvws->notifier_reset(nv30->screen->query, q->object->start); + nouveau_notifier_reset(nv30->screen->query, q->object->start); BEGIN_RING(rankine, NV34TCL_QUERY_RESET, 1); OUT_RING (1); @@ -84,27 +83,27 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_query *q = nv30_query(pq); - struct nouveau_winsys *nvws = nv30->nvws; assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER); if (!q->ready) { unsigned status; - status = nvws->notifier_status(nv30->screen->query, - q->object->start); + status = nouveau_notifier_status(nv30->screen->query, + q->object->start); if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) { if (wait == FALSE) return FALSE; - nvws->notifier_wait(nv30->screen->query, q->object->start, - NV_NOTIFY_STATE_STATUS_COMPLETED, - 0); + + nouveau_notifier_wait_status(nv30->screen->query, + q->object->start, + NV_NOTIFY_STATE_STATUS_COMPLETED, 0); } - q->result = nvws->notifier_retval(nv30->screen->query, - q->object->start); + q->result = nouveau_notifier_return_val(nv30->screen->query, + q->object->start); q->ready = TRUE; - nvws->res_free(&q->object); + nouveau_resource_free(&q->object); } *result = q->result; diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index f516038b9c..60e2f0855d 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -124,14 +124,13 @@ static void nv30_screen_destroy(struct pipe_screen *pscreen) { struct nv30_screen *screen = nv30_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->res_free(&screen->vp_exec_heap); - nvws->res_free(&screen->vp_data_heap); - nvws->res_free(&screen->query_heap); - nvws->notifier_free(&screen->query); - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->rankine); + nouveau_resource_free(&screen->vp_exec_heap); + nouveau_resource_free(&screen->vp_data_heap); + nouveau_resource_free(&screen->query_heap); + nouveau_notifier_free(&screen->query); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->rankine); FREE(pscreen); } @@ -141,6 +140,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned rankine_class = 0; @@ -150,6 +150,13 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv30_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -160,11 +167,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv30_screen_init_miptree_functions(pscreen); nv30_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv30_surface_buffer; /* 3D object */ switch (dev->chipset & 0xf0) { @@ -187,14 +189,20 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, rankine_class, &screen->rankine); + ret = nouveau_grobj_alloc(chan, 0xbeef3097, rankine_class, + &screen->rankine); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->rankine, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv30_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv30_screen_destroy(pscreen); @@ -202,14 +210,14 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Query objects */ - ret = nvws->notifier_alloc(nvws, 32, &screen->query); + ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); nv30_screen_destroy(pscreen); return NULL; } - ret = nvws->res_init(&screen->query_heap, 0, 32); + ret = nouveau_resource_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); nv30_screen_destroy(pscreen); @@ -217,8 +225,8 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Vtxprog resources */ - if (nvws->res_init(&screen->vp_exec_heap, 0, 256) || - nvws->res_init(&screen->vp_data_heap, 0, 256)) { + if (nouveau_resource_init(&screen->vp_exec_heap, 0, 256) || + nouveau_resource_init(&screen->vp_data_heap, 0, 256)) { nv30_screen_destroy(pscreen); return NULL; } @@ -228,23 +236,23 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->rankine, NV34TCL_DMA_COLOR1, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_COLOR0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_VTXBUF0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); /* so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2); so_data (so, 0); so_data (so, screen->query->handle);*/ so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY7, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY8, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); for (i=1; i<8; i++) { so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1); @@ -301,7 +309,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref(NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c index eaf543b8f7..aec39aae9c 100644 --- a/src/gallium/drivers/nv30/nv30_vertprog.c +++ b/src/gallium/drivers/nv30/nv30_vertprog.c @@ -645,7 +645,6 @@ out_err: static boolean nv30_vertprog_validate(struct nv30_context *nv30) { - struct nouveau_winsys *nvws = nv30->nvws; struct pipe_winsys *ws = nv30->pipe.winsys; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_vertex_program *vp; @@ -669,15 +668,15 @@ nv30_vertprog_validate(struct nv30_context *nv30) struct nouveau_stateobj *so; uint vplen = vp->nr_insns; - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) { + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) { while (heap->next && heap->size < vplen) { struct nv30_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->exec); + nouveau_resource_free(&evict->exec); } - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) assert(0); } @@ -694,15 +693,16 @@ nv30_vertprog_validate(struct nv30_context *nv30) if (vp->nr_consts && !vp->data) { struct nouveau_resource *heap = nv30->screen->vp_data_heap; - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) { + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) { while (heap->next && heap->size < vp->nr_consts) { struct nv30_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->data); + nouveau_resource_free(&evict->data); } - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, + &vp->data)) assert(0); } @@ -804,8 +804,6 @@ nv30_vertprog_validate(struct nv30_context *nv30) void nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp) { - struct nouveau_winsys *nvws = nv30->screen->nvws; - vp->translated = FALSE; if (vp->nr_insns) { @@ -820,9 +818,9 @@ nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp) vp->nr_consts = 0; } - nvws->res_free(&vp->exec); + nouveau_resource_free(&vp->exec); vp->exec_start = 0; - nvws->res_free(&vp->data); + nouveau_resource_free(&vp->data); vp->data_start = 0; vp->data_start_min = 0; diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c index 9b9a43f49d..7874aedd42 100644 --- a/src/gallium/drivers/nv40/nv40_query.c +++ b/src/gallium/drivers/nv40/nv40_query.c @@ -29,11 +29,10 @@ nv40_query_create(struct pipe_context *pipe, unsigned query_type) static void nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) { - struct nv40_context *nv40 = nv40_context(pipe); struct nv40_query *q = nv40_query(pq); if (q->object) - nv40->nvws->res_free(&q->object); + nouveau_resource_free(&q->object); FREE(q); } @@ -54,9 +53,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq) pipe->get_query_result(pipe, pq, 1, &tmp); } - if (nv40->nvws->res_alloc(nv40->screen->query_heap, 1, NULL, &q->object)) + if (nouveau_resource_alloc(nv40->screen->query_heap, 1, NULL, &q->object)) assert(0); - nv40->nvws->notifier_reset(nv40->screen->query, q->object->start); + nouveau_notifier_reset(nv40->screen->query, q->object->start); BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1); OUT_RING (1); @@ -84,27 +83,27 @@ nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_query *q = nv40_query(pq); - struct nouveau_winsys *nvws = nv40->nvws; assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER); if (!q->ready) { unsigned status; - status = nvws->notifier_status(nv40->screen->query, - q->object->start); + status = nouveau_notifier_status(nv40->screen->query, + q->object->start); if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) { if (wait == FALSE) return FALSE; - nvws->notifier_wait(nv40->screen->query, q->object->start, - NV_NOTIFY_STATE_STATUS_COMPLETED, - 0); + nouveau_notifier_wait_status(nv40->screen->query, + q->object->start, + NV_NOTIFY_STATE_STATUS_COMPLETED, + 0); } - q->result = nvws->notifier_retval(nv40->screen->query, - q->object->start); + q->result = nouveau_notifier_return_val(nv40->screen->query, + q->object->start); q->ready = TRUE; - nvws->res_free(&q->object); + nouveau_resource_free(&q->object); } *result = q->result; diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 3049bd8031..2114c93cd9 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -130,14 +130,13 @@ static void nv40_screen_destroy(struct pipe_screen *pscreen) { struct nv40_screen *screen = nv40_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->res_free(&screen->vp_exec_heap); - nvws->res_free(&screen->vp_data_heap); - nvws->res_free(&screen->query_heap); - nvws->notifier_free(&screen->query); - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->curie); + nouveau_resource_free(&screen->vp_exec_heap); + nouveau_resource_free(&screen->vp_data_heap); + nouveau_resource_free(&screen->query_heap); + nouveau_notifier_free(&screen->query); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->curie); nouveau_screen_fini(&screen->base); @@ -149,6 +148,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned curie_class = 0; @@ -158,6 +158,13 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv40_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -168,11 +175,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv40_screen_init_miptree_functions(pscreen); nv40_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv40_surface_buffer; /* 3D object */ switch (dev->chipset & 0xf0) { @@ -194,14 +196,19 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, curie_class, &screen->curie); + ret = nouveau_grobj_alloc(chan, 0xbeef3097, curie_class, &screen->curie); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->curie, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv40_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv40_screen_destroy(pscreen); @@ -209,14 +216,14 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Query objects */ - ret = nvws->notifier_alloc(nvws, 32, &screen->query); + ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); nv40_screen_destroy(pscreen); return NULL; } - ret = nvws->res_init(&screen->query_heap, 0, 32); + nouveau_resource_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); nv40_screen_destroy(pscreen); @@ -224,8 +231,8 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Vtxprog resources */ - if (nvws->res_init(&screen->vp_exec_heap, 0, 512) || - nvws->res_init(&screen->vp_data_heap, 0, 256)) { + if (nouveau_resource_init(&screen->vp_exec_heap, 0, 512) || + nouveau_resource_init(&screen->vp_data_heap, 0, 256)) { nv40_screen_destroy(pscreen); return NULL; } diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c index 7df9a4d326..f32d4d690c 100644 --- a/src/gallium/drivers/nv40/nv40_vertprog.c +++ b/src/gallium/drivers/nv40/nv40_vertprog.c @@ -855,7 +855,6 @@ out_err: static boolean nv40_vertprog_validate(struct nv40_context *nv40) { - struct nouveau_winsys *nvws = nv40->nvws; struct pipe_winsys *ws = nv40->pipe.winsys; struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_vertex_program *vp; @@ -895,15 +894,15 @@ check_gpu_resources: struct nouveau_stateobj *so; uint vplen = vp->nr_insns; - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) { + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) { while (heap->next && heap->size < vplen) { struct nv40_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->exec); + nouveau_resource_free(&evict->exec); } - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) assert(0); } @@ -925,15 +924,15 @@ check_gpu_resources: if (vp->nr_consts && !vp->data) { struct nouveau_resource *heap = nv40->screen->vp_data_heap; - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) { + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) { while (heap->next && heap->size < vp->nr_consts) { struct nv40_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->data); + nouveau_resource_free(&evict->data); } - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) assert(0); } @@ -1035,8 +1034,6 @@ check_gpu_resources: void nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp) { - struct nouveau_winsys *nvws = nv40->screen->nvws; - vp->translated = FALSE; if (vp->nr_insns) { @@ -1051,9 +1048,9 @@ nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp) vp->nr_consts = 0; } - nvws->res_free(&vp->exec); + nouveau_resource_free(&vp->exec); vp->exec_start = 0; - nvws->res_free(&vp->data); + nouveau_resource_free(&vp->data); vp->data_start = 0; vp->data_start_min = 0; diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 1576d4295e..bc853296cb 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2241,13 +2241,14 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) if (!p->data[0] && p->immd_nr) { struct nouveau_resource *heap = nv50->screen->immd_heap[0]; - if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) { + if (nouveau_resource_alloc(heap, p->immd_nr, p, &p->data[0])) { while (heap->next && heap->size < p->immd_nr) { struct nv50_program *evict = heap->next->priv; - nvws->res_free(&evict->data[0]); + nouveau_resource_free(&evict->data[0]); } - if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) + if (nouveau_resource_alloc(heap, p->immd_nr, p, + &p->data[0])) assert(0); } @@ -2260,13 +2261,14 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) struct nouveau_resource *heap = nv50->screen->parm_heap[p->type]; - if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) { + if (nouveau_resource_alloc(heap, p->param_nr, p, &p->data[1])) { while (heap->next && heap->size < p->param_nr) { struct nv50_program *evict = heap->next->priv; - nvws->res_free(&evict->data[1]); + nouveau_resource_free(&evict->data[1]); } - if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) + if (nouveau_resource_alloc(heap, p->param_nr, p, + &p->data[1])) assert(0); } } @@ -2472,8 +2474,8 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) nouveau_bo_ref(NULL, &p->bo); - nv50->screen->nvws->res_free(&p->data[0]); - nv50->screen->nvws->res_free(&p->data[1]); + nouveau_resource_free(&p->data[0]); + nouveau_resource_free(&p->data[1]); p->translated = 0; } diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 3b830847ca..709b7419da 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -136,6 +136,10 @@ nv50_screen_destroy(struct pipe_screen *pscreen) { struct nv50_screen *screen = nv50_screen(pscreen); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->tesla); + nouveau_grobj_free(&screen->eng2d); + nouveau_grobj_free(&screen->m2mf); nouveau_screen_fini(&screen->base); FREE(screen); } @@ -145,6 +149,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned chipset = dev->chipset; @@ -160,6 +165,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv50_screen_destroy(pscreen); return NULL; } + screen->base.channel = chan = nvws->channel; /* Setup the pipe */ screen->nvws = nvws; @@ -174,20 +180,22 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv50_transfer_init_screen_functions(pscreen); /* DMA engine object */ - ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf); + ret = nouveau_grobj_alloc(chan, 0xbeef5039, 0x5039, &screen->m2mf); if (ret) { NOUVEAU_ERR("Error creating M2MF object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->m2mf, 1); /* 2D object */ - ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d); + ret = nouveau_grobj_alloc(chan, 0xbeef502d, 0x502d, &screen->eng2d); if (ret) { NOUVEAU_ERR("Error creating 2D object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->eng2d, 2); /* 3D object */ switch (chipset & 0xf0) { @@ -213,15 +221,16 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla); + ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class, &screen->tesla); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->tesla, 3); /* Sync notifier */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv50_screen_destroy(pscreen); @@ -232,8 +241,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so = so_new(32, 0); so_method(so, screen->m2mf, 0x0180, 3); so_data (so, screen->sync->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_emit(nvws, so); so_ref (NULL, &so); @@ -241,9 +250,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so = so_new(64, 0); so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); so_data (so, screen->sync->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->eng2d, NV50_2D_OPERATION, 1); so_data (so, NV50_2D_OPERATION_SRCCOPY); so_method(so, screen->eng2d, 0x0290, 1); @@ -263,11 +272,11 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->tesla, NV50TCL_DMA_UNK0(0), NV50TCL_DMA_UNK0__SIZE); for (i = 0; i < NV50TCL_DMA_UNK0__SIZE; i++) - so_data(so, nvws->channel->vram->handle); + so_data(so, chan->vram->handle); so_method(so, screen->tesla, NV50TCL_DMA_UNK1(0), NV50TCL_DMA_UNK1__SIZE); for (i = 0; i < NV50TCL_DMA_UNK1__SIZE; i++) - so_data(so, nvws->channel->vram->handle); + so_data(so, chan->vram->handle); so_method(so, screen->tesla, 0x121c, 1); so_data (so, 1); @@ -295,9 +304,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } } - if (nvws->res_init(&screen->immd_heap[0], 0, 128) || - nvws->res_init(&screen->parm_heap[0], 0, 128) || - nvws->res_init(&screen->parm_heap[1], 0, 128)) + 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_ERR("Error initialising constant buffers.\n"); nv50_screen_destroy(pscreen); @@ -405,7 +414,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref (so, &screen->static_init); so_ref (NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c index 2e0148543d..c03e6ddcae 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c @@ -2,40 +2,6 @@ #include "nouveau_winsys_pipe.h" -static int -nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count, - struct nouveau_notifier **notify) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws); - - return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++, - count, notify); -} - -static int -nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass, - struct nouveau_grobj **grobj) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws); - struct nouveau_channel *chan = nvpws->channel; - int ret; - - ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj); - if (ret) - return ret; - - BEGIN_RING(chan, *grobj, 0x0000, 1); - OUT_RING (chan, (*grobj)->handle); - (*grobj)->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT; - return 0; -} - -static struct nouveau_bo * -nouveau_pipe_get_bo(struct pipe_buffer *pb) -{ - return nouveau_pipe_buffer(pb)->bo; -} - struct nouveau_winsys * nouveau_winsys_new(struct pipe_winsys *ws) { @@ -49,22 +15,6 @@ nouveau_winsys_new(struct pipe_winsys *ws) nvws->ws = ws; nvws->channel = nvpws->channel; - nvws->res_init = nouveau_resource_init; - nvws->res_alloc = nouveau_resource_alloc; - nvws->res_free = nouveau_resource_free; - - nvws->grobj_alloc = nouveau_pipe_grobj_alloc; - nvws->grobj_free = nouveau_grobj_free; - - nvws->notifier_alloc = nouveau_pipe_notifier_alloc; - nvws->notifier_free = nouveau_notifier_free; - nvws->notifier_reset = nouveau_notifier_reset; - nvws->notifier_status = nouveau_notifier_status; - nvws->notifier_retval = nouveau_notifier_return_val; - nvws->notifier_wait = nouveau_notifier_wait_status; - - nvws->get_bo = nouveau_pipe_get_bo; - return nvws; } -- cgit v1.2.3 From 80e9e1ee8172d1e5a81d702681897dddd9d815f1 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 10:28:13 +1000 Subject: nouveau: move channel creation into pipe drivers --- src/gallium/drivers/nouveau/nouveau_push.h | 21 +++-- src/gallium/drivers/nouveau/nouveau_screen.c | 5 ++ src/gallium/drivers/nouveau/nouveau_stateobj.h | 25 +++--- src/gallium/drivers/nouveau/nouveau_winsys.h | 18 ++--- src/gallium/drivers/nv04/nv04_screen.c | 9 +-- src/gallium/drivers/nv04/nv04_surface_2d.c | 13 ++- src/gallium/drivers/nv04/nv04_surface_2d.h | 3 +- src/gallium/drivers/nv10/nv10_context.c | 10 +-- src/gallium/drivers/nv10/nv10_screen.c | 9 +-- src/gallium/drivers/nv20/nv20_context.c | 14 ++-- src/gallium/drivers/nv20/nv20_screen.c | 9 +-- src/gallium/drivers/nv30/nv30_screen.c | 11 +-- src/gallium/drivers/nv30/nv30_state_emit.c | 11 +-- src/gallium/drivers/nv30/nv30_state_fb.c | 35 ++++---- src/gallium/drivers/nv30/nv30_vbo.c | 10 +-- src/gallium/drivers/nv40/nv40_draw.c | 2 +- src/gallium/drivers/nv40/nv40_screen.c | 35 ++++---- src/gallium/drivers/nv40/nv40_state_emit.c | 11 +-- src/gallium/drivers/nv40/nv40_state_fb.c | 92 ++++++++++++---------- src/gallium/drivers/nv40/nv40_vbo.c | 10 +-- src/gallium/drivers/nv50/nv50_clear.c | 2 +- src/gallium/drivers/nv50/nv50_context.c | 2 +- src/gallium/drivers/nv50/nv50_program.c | 13 ++- src/gallium/drivers/nv50/nv50_query.c | 4 +- src/gallium/drivers/nv50/nv50_screen.c | 16 ++-- src/gallium/drivers/nv50/nv50_state_validate.c | 40 +++++----- src/gallium/drivers/nv50/nv50_surface.c | 6 +- src/gallium/drivers/nv50/nv50_transfer.c | 3 +- src/gallium/drivers/nv50/nv50_vbo.c | 10 +-- src/gallium/winsys/drm/nouveau/drm/Makefile | 3 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 11 +-- .../winsys/drm/nouveau/drm/nouveau_winsys.c | 20 ----- 32 files changed, 218 insertions(+), 265 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_push.h b/src/gallium/drivers/nouveau/nouveau_push.h index afe4668fcd..0f2c42915b 100644 --- a/src/gallium/drivers/nouveau/nouveau_push.h +++ b/src/gallium/drivers/nouveau/nouveau_push.h @@ -9,13 +9,13 @@ #define OUT_RING(data) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - (*pc->nvws->channel->pushbuf->cur++) = (data); \ + (*pc->base.channel->pushbuf->cur++) = (data); \ } while(0) #define OUT_RINGp(src,size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - memcpy(pc->nvws->channel->pushbuf->cur, (src), (size) * 4); \ - pc->nvws->channel->pushbuf->cur += (size); \ + memcpy(pc->base.channel->pushbuf->cur, (src), (size) * 4); \ + pc->base.channel->pushbuf->cur += (size); \ } while(0) #define OUT_RINGf(data) do { \ @@ -26,7 +26,7 @@ #define BEGIN_RING(obj,mthd,size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ + struct nouveau_channel *chan = pc->base.channel; \ if (chan->pushbuf->remaining < ((size) + 1)) \ nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \ @@ -47,14 +47,13 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) #define FIRE_RING(fence) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - DO_FIRE_RING(pc->nvws->channel, fence); \ + DO_FIRE_RING(pc->base.channel, fence); \ } while(0) #define OUT_RELOC(bo,data,flags,vor,tor) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ - nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, \ - pc->nvws->get_bo(bo), \ + struct nouveau_channel *chan = pc->base.channel; \ + nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, nouveau_bo(bo), \ (data), (flags), (vor), (tor)); \ } while(0) @@ -66,8 +65,8 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) /* FB/TT object handle */ #define OUT_RELOCo(bo,flags) do { \ OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \ - pc->nvws->channel->vram->handle, \ - pc->nvws->channel->gart->handle); \ + pc->base.channel->vram->handle, \ + pc->base.channel->gart->handle); \ } while(0) /* Low 32-bits of offset */ @@ -83,7 +82,7 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) /* A reloc which'll recombine into a NV_DMA_METHOD packet header */ #define OUT_RELOCm(bo, flags, obj, mthd, size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ + struct nouveau_channel *chan = pc->base.channel; \ if (chan->pushbuf->remaining < ((size) + 1)) \ nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 3cab83eec0..ab522a124a 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -212,7 +212,12 @@ int nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) { struct pipe_screen *pscreen = &screen->base; + int ret; + ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202, + &screen->channel); + if (ret) + return ret; screen->device = dev; pscreen->get_name = nouveau_screen_get_name; diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index de3ba9cf14..8e818d9d38 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -107,21 +107,21 @@ so_dump(struct nouveau_stateobj *so) } static INLINE void -so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) +so_emit(struct nouveau_channel *chan, struct nouveau_stateobj *so) { - struct nouveau_pushbuf *pb = nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = chan->pushbuf; unsigned nr, i; nr = so->cur - so->push; if (pb->remaining < nr) - nouveau_pushbuf_flush(nvws->channel, nr); + nouveau_pushbuf_flush(chan, nr); pb->remaining -= nr; memcpy(pb->cur, so->push, nr * 4); for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur + r->offset, + nouveau_pushbuf_emit_reloc(chan, pb->cur + r->offset, r->bo, r->data, r->flags, r->vor, r->tor); } @@ -129,30 +129,29 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) } static INLINE void -so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) +so_emit_reloc_markers(struct nouveau_channel *chan, struct nouveau_stateobj *so) { - struct nouveau_pushbuf *pb = nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = chan->pushbuf; unsigned i; if (!so) return; i = so->cur_reloc << 1; - if (nvws->channel->pushbuf->remaining < i) - nouveau_pushbuf_flush(nvws->channel, i); - nvws->channel->pushbuf->remaining -= i; + if (pb->remaining < i) + nouveau_pushbuf_flush(chan, i); + pb->remaining -= i; for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, - r->packet, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->packet, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, - r->data, r->flags | NOUVEAU_BO_DUMMY, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->data, + r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor); } } diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index 7998497240..42c77e5e77 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -23,44 +23,38 @@ #define NOUVEAU_BUFFER_USAGE_ZETA (1 << 17) #define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18) -struct nouveau_winsys { - struct pipe_winsys *ws; - - struct nouveau_channel *channel; -}; - extern struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv04_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv10_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv20_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv30_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv40_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv50_create(struct pipe_screen *, unsigned pctx_id); diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 98e2dafcd8..4bbedfb4d6 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -122,10 +122,9 @@ nv04_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; @@ -140,9 +139,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv04_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv04_screen_destroy; @@ -188,7 +185,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->context_surfaces_3d, 6); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv04_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index fcb6501411..5afd028ddd 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -97,7 +97,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->swzsurf->channel; struct nouveau_grobj *swzsurf = ctx->swzsurf; struct nouveau_grobj *sifm = ctx->sifm; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); @@ -168,7 +168,7 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->m2mf->channel; struct nouveau_grobj *m2mf = ctx->m2mf; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); @@ -214,7 +214,7 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->surf2d->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *blit = ctx->blit; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); @@ -280,7 +280,7 @@ static void nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, int w, int h, unsigned value) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->surf2d->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *rect = ctx->rect; struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); @@ -335,10 +335,10 @@ nv04_surface_2d_takedown(struct nv04_surface_2d **pctx) } struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_winsys *nvws) +nv04_surface_2d_init(struct nouveau_screen *screen) { struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d); - struct nouveau_channel *chan = nvws->channel; + struct nouveau_channel *chan = screen->channel; unsigned handle = 0x88000000, class; int ret; @@ -461,7 +461,6 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws) return NULL; } - ctx->nvws = nvws; ctx->copy = nv04_surface_copy; ctx->fill = nv04_surface_fill; return ctx; diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nv04/nv04_surface_2d.h index 82ce7189c8..02b3f56ba8 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.h +++ b/src/gallium/drivers/nv04/nv04_surface_2d.h @@ -7,7 +7,6 @@ struct nv04_surface { }; struct nv04_surface_2d { - struct nouveau_winsys *nvws; struct nouveau_notifier *ntfy; struct nouveau_grobj *surf2d; struct nouveau_grobj *swzsurf; @@ -26,7 +25,7 @@ struct nv04_surface_2d { }; struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_winsys *nvws); +nv04_surface_2d_init(struct nouveau_screen *screen); void nv04_surface_2d_takedown(struct nv04_surface_2d **); diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c index 3da8d2f568..a127b134ec 100644 --- a/src/gallium/drivers/nv10/nv10_context.c +++ b/src/gallium/drivers/nv10/nv10_context.c @@ -30,18 +30,18 @@ nv10_destroy(struct pipe_context *pipe) static void nv10_init_hwctx(struct nv10_context *nv10) { struct nv10_screen *screen = nv10->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; int i; float projectionmatrix[16]; BEGIN_RING(celsius, NV10TCL_DMA_NOTIFY, 1); OUT_RING (screen->sync->handle); BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY0, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->gart->handle); + OUT_RING (chan->vram->handle); + OUT_RING (chan->gart->handle); BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY2, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); + OUT_RING (chan->vram->handle); BEGIN_RING(celsius, NV10TCL_NOP, 1); OUT_RING (0); diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index f090d2b0b7..b03c291f9d 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -118,10 +118,9 @@ nv10_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned celsius_class; @@ -136,9 +135,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv10_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv10_screen_destroy; @@ -173,7 +170,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->celsius, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv10_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c index cbc41707d5..b32d0d83ba 100644 --- a/src/gallium/drivers/nv20/nv20_context.c +++ b/src/gallium/drivers/nv20/nv20_context.c @@ -30,7 +30,7 @@ nv20_destroy(struct pipe_context *pipe) static void nv20_init_hwctx(struct nv20_context *nv20) { struct nv20_screen *screen = nv20->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; int i; float projectionmatrix[16]; const boolean is_nv25tcl = (nv20->screen->kelvin->grclass == NV25TCL); @@ -38,11 +38,11 @@ static void nv20_init_hwctx(struct nv20_context *nv20) BEGIN_RING(kelvin, NV20TCL_DMA_NOTIFY, 1); OUT_RING (screen->sync->handle); BEGIN_RING(kelvin, NV20TCL_DMA_TEXTURE0, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->gart->handle); /* TEXTURE1 */ + OUT_RING (chan->vram->handle); + OUT_RING (chan->gart->handle); /* TEXTURE1 */ BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->vram->handle); /* ZETA */ + OUT_RING (chan->vram->handle); + OUT_RING (chan->vram->handle); /* ZETA */ BEGIN_RING(kelvin, NV20TCL_DMA_QUERY, 1); OUT_RING (0); /* renouveau: beef0351, unique */ @@ -99,9 +99,9 @@ static void nv20_init_hwctx(struct nv20_context *nv20) OUT_RING (3); BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY9, 1); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY8, 1); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); } BEGIN_RING(kelvin, NV20TCL_DMA_FENCE, 1); OUT_RING (0); /* renouveau: beef1e10 */ diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 4d991852a1..024356ca74 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -118,10 +118,9 @@ nv20_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned kelvin_class = 0; @@ -136,9 +135,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv20_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv20_screen_destroy; @@ -169,7 +166,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->kelvin, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv20_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 60e2f0855d..31bc1f3173 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -136,10 +136,9 @@ nv30_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -155,9 +154,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv30_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv30_screen_destroy; @@ -198,7 +195,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->rankine, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv30_surface_buffer; /* Notifier for sync purposes */ @@ -307,7 +304,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->rankine, 0x1e94, 1); so_data (so, 0x13); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); nouveau_pushbuf_flush(chan, 0); diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c index c18be20a32..621b8846c8 100644 --- a/src/gallium/drivers/nv30/nv30_state_emit.c +++ b/src/gallium/drivers/nv30/nv30_state_emit.c @@ -38,6 +38,7 @@ nv30_state_do_validate(struct nv30_context *nv30, void nv30_state_emit(struct nv30_context *nv30) { + struct nouveau_channel *chan = nv30->screen->base.channel; struct nv30_state *state = &nv30->state; struct nv30_screen *screen = nv30->screen; unsigned i, samplers; @@ -57,23 +58,23 @@ nv30_state_emit(struct nv30_context *nv30) continue; so_ref (state->hw[i], &nv30->screen->state[i]); if (state->hw[i]) - so_emit(nv30->nvws, nv30->screen->state[i]); + so_emit(chan, nv30->screen->state[i]); states &= ~(1ULL << i); } state->dirty = 0; - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FB]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]); for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) { if (!(samplers & (1 << i))) continue; - so_emit_reloc_markers(nv30->nvws, + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGTEX0+i]); samplers &= ~(1ULL << i); } - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FRAGPROG]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGPROG]); if (state->hw[NV30_STATE_VTXBUF] /*&& nv30->render_mode == HW*/) - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_VTXBUF]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_VTXBUF]); } boolean diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 1be916872f..cb1a260eaa 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -5,6 +5,8 @@ static boolean nv30_state_framebuffer_validate(struct nv30_context *nv30) { struct pipe_framebuffer_state *fb = &nv30->framebuffer; + struct nouveau_channel *chan = nv30->screen->base.channel; + struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv04_surface *rt[2], *zeta = NULL; uint32_t rt_enable, rt_format; int i, colour_format = 0, zeta_format = 0; @@ -79,11 +81,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) } nv30mt = (struct nv30_miptree *)rt[0]->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1); + so_method(so, rankine, NV34TCL_DMA_COLOR0, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2); + 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, rt_flags | NOUVEAU_BO_LOW, 0, 0); @@ -91,11 +92,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) { nv30mt = (struct nv30_miptree *)rt[1]->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1); + so_method(so, rankine, NV34TCL_DMA_COLOR1, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2); + chan->vram->handle, chan->gart->handle); + so_method(so, rankine, NV34TCL_COLOR1_OFFSET, 2); so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); so_data (so, rt[1]->pitch); @@ -103,32 +103,31 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) if (zeta_format) { nv30mt = (struct nv30_miptree *)zeta->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1); + so_method(so, rankine, NV34TCL_DMA_ZETA, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1); + chan->vram->handle, chan->gart->handle); + so_method(so, rankine, NV34TCL_ZETA_OFFSET, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); /* TODO: allocate LMA depth buffer */ } - so_method(so, nv30->screen->rankine, NV34TCL_RT_ENABLE, 1); + so_method(so, rankine, NV34TCL_RT_ENABLE, 1); so_data (so, rt_enable); - so_method(so, nv30->screen->rankine, NV34TCL_RT_HORIZ, 3); + so_method(so, rankine, NV34TCL_RT_HORIZ, 3); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); so_data (so, rt_format); - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_HORIZ, 2); + so_method(so, rankine, NV34TCL_VIEWPORT_HORIZ, 2); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2); + so_method(so, rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2); so_data (so, ((w - 1) << 16) | 0); so_data (so, ((h - 1) << 16) | 0); - so_method(so, nv30->screen->rankine, 0x1d88, 1); + so_method(so, rankine, 0x1d88, 1); so_data (so, (1 << 12) | h); /* Wonder why this is needed, context should all be set to zero on init */ - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1); + so_method(so, rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1); so_data (so, 0); so_ref(so, &nv30->state.hw[NV30_STATE_FB]); diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index ff2bf6e71b..9b72bc3002 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -168,7 +168,7 @@ nv30_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; unsigned restart = 0; nv30_vbo_set_idxbuf(nv30, NULL, 0); @@ -228,7 +228,7 @@ static INLINE void nv30_draw_elements_u08(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint8_t *elts = (uint8_t *)ib + start; @@ -277,7 +277,7 @@ static INLINE void nv30_draw_elements_u16(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint16_t *elts = (uint16_t *)ib + start; @@ -326,7 +326,7 @@ static INLINE void nv30_draw_elements_u32(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint32_t *elts = (uint32_t *)ib + start; @@ -401,7 +401,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; unsigned restart = 0; while (count) { diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c index c83ff91d7e..e7d8cf93a9 100644 --- a/src/gallium/drivers/nv40/nv40_draw.c +++ b/src/gallium/drivers/nv40/nv40_draw.c @@ -81,7 +81,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim, { struct nv40_render_stage *rs = nv40_render_stage(stage); struct nv40_context *nv40 = rs->nv40; - struct nouveau_pushbuf *pb = nv40->nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = nv40->screen->base.channel->pushbuf; unsigned i; /* Ensure there's room for 4xfloat32 + potentially 3 begin/end */ diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 2114c93cd9..b8b2af482a 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -144,10 +144,9 @@ nv40_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -163,9 +162,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv40_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv40_screen_destroy; @@ -204,7 +201,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->curie, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv40_surface_buffer; /* Notifier for sync purposes */ @@ -242,25 +239,25 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR1, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_VTXBUF0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->curie, NV40TCL_DMA_FENCE, 2); so_data (so, 0); so_data (so, screen->query->handle); so_method(so, screen->curie, NV40TCL_DMA_UNK01AC, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR2, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, 0x1ea4, 3); so_data (so, 0x00000010); @@ -285,9 +282,9 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->curie, 0x1e94, 1); so_data (so, 0x00000001); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c index 10aae29832..198692965d 100644 --- a/src/gallium/drivers/nv40/nv40_state_emit.c +++ b/src/gallium/drivers/nv40/nv40_state_emit.c @@ -54,6 +54,7 @@ nv40_state_do_validate(struct nv40_context *nv40, void nv40_state_emit(struct nv40_context *nv40) { + struct nouveau_channel *chan = nv40->screen->base.channel; struct nv40_state *state = &nv40->state; struct nv40_screen *screen = nv40->screen; unsigned i, samplers; @@ -73,7 +74,7 @@ nv40_state_emit(struct nv40_context *nv40) continue; so_ref (state->hw[i], &nv40->screen->state[i]); if (state->hw[i]) - so_emit(nv40->nvws, nv40->screen->state[i]); + so_emit(chan, nv40->screen->state[i]); states &= ~(1ULL << i); } @@ -87,17 +88,17 @@ nv40_state_emit(struct nv40_context *nv40) state->dirty = 0; - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FB]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]); for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) { if (!(samplers & (1 << i))) continue; - so_emit_reloc_markers(nv40->nvws, + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGTEX0+i]); samplers &= ~(1ULL << i); } - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FRAGPROG]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGPROG]); if (state->hw[NV40_STATE_VTXBUF] && nv40->render_mode == HW) - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_VTXBUF]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_VTXBUF]); } boolean diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c index d8364ff993..273142f9e0 100644 --- a/src/gallium/drivers/nv40/nv40_state_fb.c +++ b/src/gallium/drivers/nv40/nv40_state_fb.c @@ -13,6 +13,8 @@ nv40_do_surface_buffer(struct pipe_surface *surface) static boolean nv40_state_framebuffer_validate(struct nv40_context *nv40) { + struct nouveau_channel *chan = nv40->screen->base.channel; + struct nouveau_grobj *curie = nv40->screen->curie; struct pipe_framebuffer_state *fb = &nv40->framebuffer; struct nv04_surface *rt[4], *zeta; uint32_t rt_enable, rt_format; @@ -79,76 +81,80 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) } if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR0, 1); - so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2); + so_method(so, curie, NV40TCL_DMA_COLOR0, 1); + so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR0_PITCH, 2); so_data (so, rt[0]->pitch); - so_reloc (so, nv40_surface_buffer(&rt[0]->base), rt[0]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, nv40_surface_buffer(&rt[0]->base), + rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR1, 1); - so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2); - so_reloc (so, nv40_surface_buffer(&rt[1]->base), rt[1]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_method(so, curie, NV40TCL_DMA_COLOR1, 1); + so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR1_OFFSET, 2); + so_reloc (so, nv40_surface_buffer(&rt[1]->base), + rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); so_data (so, rt[1]->pitch); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR2, 1); - so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR2_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&rt[2]->base), rt[2]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_COLOR2, 1); + so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR2_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&rt[2]->base), + rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); + so_method(so, curie, NV40TCL_COLOR2_PITCH, 1); so_data (so, rt[2]->pitch); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR3, 1); - so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR3_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&rt[3]->base), rt[3]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_COLOR3, 1); + so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR3_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&rt[3]->base), + rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); + so_method(so, curie, NV40TCL_COLOR3_PITCH, 1); so_data (so, rt[3]->pitch); } if (zeta_format) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_ZETA, 1); - so_reloc (so, nv40_surface_buffer(&zeta->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_ZETA_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&zeta->base), zeta->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_ZETA, 1); + so_reloc (so, nv40_surface_buffer(&zeta->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_ZETA_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&zeta->base), + zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); + so_method(so, curie, NV40TCL_ZETA_PITCH, 1); so_data (so, zeta->pitch); } - so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1); + so_method(so, curie, NV40TCL_RT_ENABLE, 1); so_data (so, rt_enable); - so_method(so, nv40->screen->curie, NV40TCL_RT_HORIZ, 3); + so_method(so, curie, NV40TCL_RT_HORIZ, 3); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); so_data (so, rt_format); - so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_HORIZ, 2); + so_method(so, curie, NV40TCL_VIEWPORT_HORIZ, 2); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); - so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2); + so_method(so, curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2); so_data (so, ((w - 1) << 16) | 0); so_data (so, ((h - 1) << 16) | 0); - so_method(so, nv40->screen->curie, 0x1d88, 1); + so_method(so, curie, 0x1d88, 1); so_data (so, (1 << 12) | h); so_ref(so, &nv40->state.hw[NV40_STATE_FB]); diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 4abddba110..24bd116539 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -168,7 +168,7 @@ nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; unsigned restart; nv40_vbo_set_idxbuf(nv40, NULL, 0); @@ -227,7 +227,7 @@ static INLINE void nv40_draw_elements_u08(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint8_t *elts = (uint8_t *)ib + start; @@ -276,7 +276,7 @@ static INLINE void nv40_draw_elements_u16(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint16_t *elts = (uint16_t *)ib + start; @@ -325,7 +325,7 @@ static INLINE void nv40_draw_elements_u32(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint32_t *elts = (uint32_t *)ib + start; @@ -400,7 +400,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; unsigned restart; while (count) { diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index 33427a15a5..e0b2d2880b 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -31,7 +31,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, double depth, unsigned stencil) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned mode = 0, i; diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index a511f655c1..e02afc4be9 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -33,7 +33,7 @@ nv50_flush(struct pipe_context *pipe, unsigned flags, { struct nv50_context *nv50 = (struct nv50_context *)pipe; - FIRE_RING(nv50->screen->nvws->channel); + FIRE_RING(nv50->screen->base.channel); } static void diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index bc853296cb..9d6427e2bc 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2215,7 +2215,7 @@ static void nv50_program_upload_data(struct nv50_context *nv50, float *map, unsigned start, unsigned count, unsigned cbuf) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; while (count) { @@ -2235,7 +2235,6 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map, static void nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) { - struct nouveau_winsys *nvws = nv50->screen->nvws; struct pipe_winsys *ws = nv50->pipe.winsys; if (!p->data[0] && p->immd_nr) { @@ -2288,7 +2287,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) static void nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_program_exec *e; struct nouveau_stateobj *so; @@ -2353,14 +2352,14 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) start = 0; count = p->exec_size; while (count) { - struct nouveau_winsys *nvws = nv50->screen->nvws; + struct nouveau_channel *chan = nv50->screen->base.channel; unsigned nr; - so_emit(nvws, so); + so_emit(chan, so); nr = MIN2(count, 2047); - nr = MIN2(nvws->channel->pushbuf->remaining, nr); - if (nvws->channel->pushbuf->remaining < (nr + 3)) { + nr = MIN2(chan->pushbuf->remaining, nr); + if (chan->pushbuf->remaining < (nr + 3)) { FIRE_RING(chan); continue; } diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 4d05eeac2c..c77ffe84e7 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -71,7 +71,7 @@ static void nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); @@ -87,7 +87,7 @@ static void nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); struct nouveau_bo *bo = nouveau_bo(q->buffer); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 709b7419da..7904b51f77 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -145,10 +145,9 @@ nv50_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -160,15 +159,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; - ret = nouveau_screen_init(&screen->base, nvws->channel->device); + ret = nouveau_screen_init(&screen->base, dev); if (ret) { nv50_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - /* Setup the pipe */ - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv50_screen_destroy; @@ -243,7 +239,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_data (so, screen->sync->handle); so_data (so, chan->vram->handle); so_data (so, chan->vram->handle); - so_emit(nvws, so); + so_emit(chan, so); so_ref (NULL, &so); /* Static 2D init */ @@ -259,7 +255,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_data (so, 0); so_method(so, screen->eng2d, 0x0888, 1); so_data (so, 1); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); /* Static tesla init */ @@ -411,7 +407,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->tesla, 0x1458, 1); so_data (so, 1); - so_emit(nvws, so); + so_emit(chan, so); so_ref (so, &screen->static_init); so_ref (NULL, &so); nouveau_pushbuf_flush(chan, 0); diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index d1f0ccdd8a..9e70d4b78d 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -131,7 +131,7 @@ static void nv50_state_emit(struct nv50_context *nv50) { struct nv50_screen *screen = nv50->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; if (nv50->pctx_id != screen->cur_pctx) { nv50->state.dirty |= 0xffffffff; @@ -139,40 +139,40 @@ nv50_state_emit(struct nv50_context *nv50) } if (nv50->state.dirty & NV50_NEW_FRAMEBUFFER) - so_emit(nvws, nv50->state.fb); + so_emit(chan, nv50->state.fb); if (nv50->state.dirty & NV50_NEW_BLEND) - so_emit(nvws, nv50->state.blend); + so_emit(chan, nv50->state.blend); if (nv50->state.dirty & NV50_NEW_ZSA) - so_emit(nvws, nv50->state.zsa); + so_emit(chan, nv50->state.zsa); if (nv50->state.dirty & NV50_NEW_VERTPROG) - so_emit(nvws, nv50->state.vertprog); + so_emit(chan, nv50->state.vertprog); if (nv50->state.dirty & NV50_NEW_FRAGPROG) - so_emit(nvws, nv50->state.fragprog); + so_emit(chan, nv50->state.fragprog); if (nv50->state.dirty & NV50_NEW_RASTERIZER) - so_emit(nvws, nv50->state.rast); + so_emit(chan, nv50->state.rast); if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR) - so_emit(nvws, nv50->state.blend_colour); + so_emit(chan, nv50->state.blend_colour); if (nv50->state.dirty & NV50_NEW_STIPPLE) - so_emit(nvws, nv50->state.stipple); + so_emit(chan, nv50->state.stipple); if (nv50->state.dirty & NV50_NEW_SCISSOR) - so_emit(nvws, nv50->state.scissor); + so_emit(chan, nv50->state.scissor); if (nv50->state.dirty & NV50_NEW_VIEWPORT) - so_emit(nvws, nv50->state.viewport); + so_emit(chan, nv50->state.viewport); if (nv50->state.dirty & NV50_NEW_SAMPLER) - so_emit(nvws, nv50->state.tsc_upload); + so_emit(chan, nv50->state.tsc_upload); if (nv50->state.dirty & NV50_NEW_TEXTURE) - so_emit(nvws, nv50->state.tic_upload); + so_emit(chan, nv50->state.tic_upload); if (nv50->state.dirty & NV50_NEW_ARRAYS) { - so_emit(nvws, nv50->state.vtxfmt); - so_emit(nvws, nv50->state.vtxbuf); + so_emit(chan, nv50->state.vtxfmt); + so_emit(chan, nv50->state.vtxbuf); } nv50->state.dirty = 0; - so_emit_reloc_markers(nvws, nv50->state.fb); - so_emit_reloc_markers(nvws, nv50->state.vertprog); - so_emit_reloc_markers(nvws, nv50->state.fragprog); - so_emit_reloc_markers(nvws, nv50->state.vtxbuf); - so_emit_reloc_markers(nvws, nv50->screen->static_init); + so_emit_reloc_markers(chan, nv50->state.fb); + so_emit_reloc_markers(chan, nv50->state.vertprog); + so_emit_reloc_markers(chan, nv50->state.fragprog); + so_emit_reloc_markers(chan, nv50->state.vtxbuf); + so_emit_reloc_markers(chan, nv50->screen->static_init); } boolean diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 121eddfc83..cd4e7ef690 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -52,7 +52,7 @@ static int nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) { struct nv50_miptree *mt = nv50_miptree(ps->texture); - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer); int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; @@ -104,7 +104,7 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; int ret; @@ -161,7 +161,7 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, { struct nv50_context *nv50 = (struct nv50_context *)pipe; struct nv50_screen *screen = nv50->screen; - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; int format, ret; diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 5f1e430ad1..a0a2099035 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -24,8 +24,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, unsigned src_reloc, unsigned dst_reloc) { struct nv50_screen *screen = nv50_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - struct nouveau_channel *chan = nvws->channel; + struct nouveau_channel *chan = screen->m2mf->channel; struct nouveau_grobj *m2mf = screen->m2mf; struct nouveau_bo *src_bo = nouveau_bo(src); struct nouveau_bo *dst_bo = nouveau_bo(dst); diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 6f4981d1ff..a9b53a0f2e 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -53,7 +53,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; nv50_state_validate(nv50); @@ -83,7 +83,7 @@ static INLINE void nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -112,7 +112,7 @@ static INLINE void nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -141,7 +141,7 @@ static INLINE void nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint8_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -163,7 +163,7 @@ nv50_draw_elements(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_winsys *ws = pipe->winsys; void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile index 2da78d8690..621ad2a807 100644 --- a/src/gallium/winsys/drm/nouveau/drm/Makefile +++ b/src/gallium/winsys/drm/nouveau/drm/Makefile @@ -4,8 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveaudrm C_SOURCES = nouveau_drm_api.c \ - nouveau_winsys_pipe.c \ - nouveau_winsys.c + nouveau_winsys_pipe.c LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index b355a1391d..22c53f6ea9 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -70,10 +70,9 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct dri1_create_screen_arg *dri1 = (void *)arg; struct pipe_winsys *ws; - struct nouveau_winsys *nvws; struct nouveau_device *dev = NULL; struct pipe_screen *(*init)(struct pipe_winsys *, - struct nouveau_winsys *); + struct nouveau_device *); int ret; ret = nouveau_device_open_existing(&dev, 0, fd, 0); @@ -114,13 +113,7 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) return NULL; } - nvws = nouveau_winsys_new(ws); - if (!nvws) { - ws->destroy(ws); - return NULL; - } - - nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws); + nouveau_pipe_winsys(ws)->pscreen = init(ws, dev); if (!nouveau_pipe_winsys(ws)->pscreen) { ws->destroy(ws); return NULL; diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c deleted file mode 100644 index c03e6ddcae..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "util/u_memory.h" - -#include "nouveau_winsys_pipe.h" - -struct nouveau_winsys * -nouveau_winsys_new(struct pipe_winsys *ws) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_winsys *nvws; - - nvws = CALLOC_STRUCT(nouveau_winsys); - if (!nvws) - return NULL; - - nvws->ws = ws; - nvws->channel = nvpws->channel; - - return nvws; -} - -- cgit v1.2.3 From 6b3ca672eb85d30d6c28e91000e2cc2231a41bef Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 11:21:08 +1000 Subject: nouveau: remove unneeded code from ws, use pipe_buffer_ instead of ws-> --- src/gallium/drivers/nv04/nv04_state.c | 7 +- src/gallium/drivers/nv04/nv04_vbo.c | 16 +- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 14 +- src/gallium/drivers/nv10/nv10_state.c | 7 +- src/gallium/drivers/nv10/nv10_vbo.c | 15 +- src/gallium/drivers/nv20/nv20_prim_vbuf.c | 12 +- src/gallium/drivers/nv20/nv20_state.c | 7 +- src/gallium/drivers/nv20/nv20_vbo.c | 16 +- src/gallium/drivers/nv20/nv20_vertprog.c | 12 +- src/gallium/drivers/nv30/nv30_fragprog.c | 17 +- src/gallium/drivers/nv30/nv30_vbo.c | 18 +- src/gallium/drivers/nv30/nv30_vertprog.c | 12 +- src/gallium/drivers/nv40/nv40_draw.c | 19 +- src/gallium/drivers/nv40/nv40_fragprog.c | 17 +- src/gallium/drivers/nv40/nv40_vbo.c | 17 +- src/gallium/drivers/nv40/nv40_vertprog.c | 9 +- src/gallium/drivers/nv50/nv50_program.c | 8 +- src/gallium/drivers/nv50/nv50_query.c | 8 +- src/gallium/drivers/nv50/nv50_vbo.c | 8 +- src/gallium/winsys/drm/nouveau/drm/Makefile | 3 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 84 +++++---- .../winsys/drm/nouveau/drm/nouveau_drm_api.h | 27 +++ .../winsys/drm/nouveau/drm/nouveau_winsys_pipe.c | 205 --------------------- .../winsys/drm/nouveau/drm/nouveau_winsys_pipe.h | 54 ------ 24 files changed, 198 insertions(+), 414 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c index 87c635f962..d356ebd8b3 100644 --- a/src/gallium/drivers/nv04/nv04_state.c +++ b/src/gallium/drivers/nv04/nv04_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -334,7 +335,7 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv04_context *nv04 = nv04_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -342,12 +343,12 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv04->constbuf[shader], mapped, buf->buffer->size); nv04->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c index d21a0e34f7..e3167814f2 100644 --- a/src/gallium/drivers/nv04/nv04_vbo.c +++ b/src/gallium/drivers/nv04/nv04_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv04_context.h" #include "nv04_state.h" @@ -13,6 +14,7 @@ boolean nv04_draw_elements( struct pipe_context *pipe, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { + struct pipe_screen *pscreen = pipe->screen; struct nv04_context *nv04 = nv04_context( pipe ); struct draw_context *draw = nv04->draw; unsigned i; @@ -25,17 +27,17 @@ boolean nv04_draw_elements( struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv04->vtxbuf[i].buffer) { void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv04->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, + nv04->vtxbuf[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +57,12 @@ boolean nv04_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv04->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv04->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c index f16e343fa6..1806d5f8cc 100644 --- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c +++ b/src/gallium/drivers/nv10/nv10_prim_vbuf.c @@ -40,7 +40,6 @@ #include "util/u_debug.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "nv10_context.h" #include "nv10_state.h" @@ -124,11 +123,10 @@ nv10_vbuf_render_map_vertices( struct vbuf_render *render ) { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_winsys *winsys = nv10->pipe.winsys; + struct pipe_screen *pscreen = nv10->pipe.screen; - return winsys->buffer_map(winsys, - nv10_render->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); + return pipe_buffer_map(pscreen, nv10_render->buffer, + PIPE_BUFFER_USAGE_CPU_WRITE); } static void @@ -138,10 +136,10 @@ nv10_vbuf_render_unmap_vertices( struct vbuf_render *render, { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_winsys *winsys = nv10->pipe.winsys; + struct pipe_screen *pscreen = nv10->pipe.screen; assert(!nv10_render->buffer); - winsys->buffer_unmap(winsys, nv10_render->buffer); + pipe_buffer_unmap(pscreen, nv10_render->buffer); } static boolean @@ -202,8 +200,6 @@ static void nv10_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *pscreen = &nv10->screen->base.base; assert(nv10_render->buffer); pipe_buffer_reference(&nv10_render->buffer, NULL); diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c index 119af66dfd..9b38219b99 100644 --- a/src/gallium/drivers/nv10/nv10_state.c +++ b/src/gallium/drivers/nv10/nv10_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -460,7 +461,7 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv10_context *nv10 = nv10_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -468,12 +469,12 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv10->constbuf[shader], mapped, buf->buffer->size); nv10->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c index d0e788ac03..441a4f75f3 100644 --- a/src/gallium/drivers/nv10/nv10_vbo.c +++ b/src/gallium/drivers/nv10/nv10_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv10_context.h" #include "nv10_state.h" @@ -15,6 +16,7 @@ boolean nv10_draw_elements( struct pipe_context *pipe, { struct nv10_context *nv10 = nv10_context( pipe ); struct draw_context *draw = nv10->draw; + struct pipe_screen *pscreen = pipe->screen; unsigned i; nv10_emit_hw_state(nv10); @@ -24,9 +26,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv10->vtxbuf[i].buffer) { - void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv10->vtxbuf[i].buffer, + void *buf = + pipe_buffer_map(pscreen, nv10->vtxbuf[i].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } @@ -34,8 +35,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe, /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +56,12 @@ boolean nv10_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv10->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv10->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv10->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c index 8f9f27ebdc..ddfcdb8057 100644 --- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c +++ b/src/gallium/drivers/nv20/nv20_prim_vbuf.c @@ -152,12 +152,11 @@ static void * nv20_vbuf_render_map_vertices( struct vbuf_render *render ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys; + struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; if (nv20_render->pbuffer) { - return winsys->buffer_map(winsys, - nv20_render->pbuffer, - PIPE_BUFFER_USAGE_CPU_WRITE); + return pipe_buffer_map(pscreen, nv20_render->pbuffer, + PIPE_BUFFER_USAGE_CPU_WRITE); } else if (nv20_render->mbuffer) { return nv20_render->mbuffer; } else @@ -173,10 +172,10 @@ nv20_vbuf_render_unmap_vertices( struct vbuf_render *render, ushort max_index ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys; + struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; if (nv20_render->pbuffer) - winsys->buffer_unmap(winsys, nv20_render->pbuffer); + pipe_buffer_unmap(pscreen, nv20_render->pbuffer); } static boolean @@ -358,7 +357,6 @@ nv20_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); struct nv20_context *nv20 = nv20_render->nv20; - struct pipe_screen *pscreen = &nv20->screen->base.base; if (nv20_render->pbuffer) { pipe_buffer_reference(&nv20_render->pbuffer, NULL); diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c index ecec4f49a0..ed4084980f 100644 --- a/src/gallium/drivers/nv20/nv20_state.c +++ b/src/gallium/drivers/nv20/nv20_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -453,7 +454,7 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv20_context *nv20 = nv20_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -461,12 +462,12 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv20->constbuf[shader], mapped, buf->buffer->size); nv20->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c index 24d8f4bef0..84d7db6c5e 100644 --- a/src/gallium/drivers/nv20/nv20_vbo.c +++ b/src/gallium/drivers/nv20/nv20_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv20_context.h" #include "nv20_state.h" @@ -13,6 +14,7 @@ boolean nv20_draw_elements( struct pipe_context *pipe, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { + struct pipe_screen *pscreen = pipe->screen; struct nv20_context *nv20 = nv20_context( pipe ); struct draw_context *draw = nv20->draw; unsigned i; @@ -25,17 +27,17 @@ boolean nv20_draw_elements( struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv20->vtxbuf[i].buffer) { void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv20->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, + nv20->vtxbuf[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +57,12 @@ boolean nv20_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv20->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv20->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv20->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv20/nv20_vertprog.c b/src/gallium/drivers/nv20/nv20_vertprog.c index 5db0e807ff..c1e588902b 100644 --- a/src/gallium/drivers/nv20/nv20_vertprog.c +++ b/src/gallium/drivers/nv20/nv20_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -645,8 +646,8 @@ out_err: static boolean nv20_vertprog_validate(struct nv20_context *nv20) { + struct pipe_screen *pscreen = nv20->pipe.screen; struct nouveau_winsys *nvws = nv20->nvws; - struct pipe_winsys *ws = nv20->pipe.winsys; struct nouveau_grobj *rankine = nv20->screen->rankine; struct nv20_vertex_program *vp; struct pipe_buffer *constbuf; @@ -749,8 +750,8 @@ nv20_vertprog_validate(struct nv20_context *nv20) float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -770,9 +771,8 @@ nv20_vertprog_validate(struct nv20_context *nv20) OUT_RINGp ((uint32_t *)vpd->value, 4); } - if (constbuf) { - ws->buffer_unmap(ws, constbuf); - } + if (constbuf) + pipe_buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c index 956b450726..1d1c556fb1 100644 --- a/src/gallium/drivers/nv30/nv30_fragprog.c +++ b/src/gallium/drivers/nv30/nv30_fragprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -798,12 +799,12 @@ static void nv30_fragprog_upload(struct nv30_context *nv30, struct nv30_fragment_program *fp) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; const uint32_t le = 1; uint32_t *map; int i; - map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); #if 0 for (i = 0; i < fp->insn_len; i++) { @@ -825,7 +826,7 @@ nv30_fragprog_upload(struct nv30_context *nv30, } } - ws->buffer_unmap(ws, fp->buffer); + pipe_buffer_unmap(pscreen, fp->buffer); } static boolean @@ -834,8 +835,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) struct nv30_fragment_program *fp = nv30->fragprog; struct pipe_buffer *constbuf = nv30->constbuf[PIPE_SHADER_FRAGMENT]; - struct pipe_screen *screen = nv30->pipe.screen; - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_stateobj *so; boolean new_consts = FALSE; int i; @@ -850,7 +850,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) return FALSE; } - fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4); + fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv30_fragprog_upload(nv30, fp); so = so_new(8, 1); @@ -872,7 +872,8 @@ update_constants: if (fp->nr_consts) { float *map; - map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); for (i = 0; i < fp->nr_consts; i++) { struct nv30_fragment_program_data *fpd = &fp->consts[i]; uint32_t *p = &fp->insn[fpd->offset]; @@ -883,7 +884,7 @@ update_constants: memcpy(p, cb, 4 * sizeof(float)); new_consts = TRUE; } - ws->buffer_unmap(ws, constbuf); + pipe_buffer_unmap(pscreen, constbuf); if (new_consts) nv30_fragprog_upload(nv30, fp); diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index 9b72bc3002..189656ec81 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -1,5 +1,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv30_context.h" #include "nv30_state.h" @@ -108,7 +109,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, int attrib, struct pipe_vertex_element *ve, struct pipe_vertex_buffer *vb) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_grobj *rankine = nv30->screen->rankine; unsigned type, ncomp; void *map; @@ -116,7 +117,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp)) return FALSE; - map = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); map += vb->buffer_offset + ve->src_offset; switch (type) { @@ -148,18 +149,17 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, so_data (so, fui(v[0])); break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } } break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } - ws->buffer_unmap(ws, vb->buffer); - + pipe_buffer_unmap(pscreen, vb->buffer); return TRUE; } @@ -368,10 +368,10 @@ nv30_draw_elements_inline(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; void *map; - map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ); if (!ib) { NOUVEAU_ERR("failed mapping ib\n"); return FALSE; @@ -392,7 +392,7 @@ nv30_draw_elements_inline(struct pipe_context *pipe, break; } - ws->buffer_unmap(ws, ib); + pipe_buffer_unmap(pscreen, ib); return TRUE; } diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c index aec39aae9c..c7514efcfe 100644 --- a/src/gallium/drivers/nv30/nv30_vertprog.c +++ b/src/gallium/drivers/nv30/nv30_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -645,7 +646,7 @@ out_err: static boolean nv30_vertprog_validate(struct nv30_context *nv30) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_vertex_program *vp; struct pipe_buffer *constbuf; @@ -750,8 +751,8 @@ nv30_vertprog_validate(struct nv30_context *nv30) float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -771,9 +772,8 @@ nv30_vertprog_validate(struct nv30_context *nv30) OUT_RINGp ((uint32_t *)vpd->value, 4); } - if (constbuf) { - ws->buffer_unmap(ws, constbuf); - } + if (constbuf) + pipe_buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c index e7d8cf93a9..b2f19ecb69 100644 --- a/src/gallium/drivers/nv40/nv40_draw.c +++ b/src/gallium/drivers/nv40/nv40_draw.c @@ -1,4 +1,5 @@ #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "util/u_pack_color.h" @@ -231,7 +232,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; unsigned i; void *map; @@ -241,13 +242,14 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, nv40_state_emit(nv40); for (i = 0; i < nv40->vtxbuf_nr; i++) { - map = ws->buffer_map(ws, nv40->vtxbuf[i].buffer, + map = pipe_buffer_map(pscreen, nv40->vtxbuf[i].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(nv40->draw, i, map); } if (idxbuf) { - map = ws->buffer_map(ws, idxbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, idxbuf, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(nv40->draw, idxbuf_size, map); } else { draw_set_mapped_element_buffer(nv40->draw, 0, NULL); @@ -256,21 +258,22 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, if (nv40->constbuf[PIPE_SHADER_VERTEX]) { const unsigned nr = nv40->constbuf_nr[PIPE_SHADER_VERTEX]; - map = ws->buffer_map(ws, nv40->constbuf[PIPE_SHADER_VERTEX], - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, + nv40->constbuf[PIPE_SHADER_VERTEX], + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_constant_buffer(nv40->draw, map, nr); } draw_arrays(nv40->draw, mode, start, count); for (i = 0; i < nv40->vtxbuf_nr; i++) - ws->buffer_unmap(ws, nv40->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv40->vtxbuf[i].buffer); if (idxbuf) - ws->buffer_unmap(ws, idxbuf); + pipe_buffer_unmap(pscreen, idxbuf); if (nv40->constbuf[PIPE_SHADER_VERTEX]) - ws->buffer_unmap(ws, nv40->constbuf[PIPE_SHADER_VERTEX]); + pipe_buffer_unmap(pscreen, nv40->constbuf[PIPE_SHADER_VERTEX]); draw_flush(nv40->draw); pipe->flush(pipe, 0, NULL); diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c index b45dfaa913..680976da56 100644 --- a/src/gallium/drivers/nv40/nv40_fragprog.c +++ b/src/gallium/drivers/nv40/nv40_fragprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -881,12 +882,12 @@ static void nv40_fragprog_upload(struct nv40_context *nv40, struct nv40_fragment_program *fp) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; const uint32_t le = 1; uint32_t *map; int i; - map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); #if 0 for (i = 0; i < fp->insn_len; i++) { @@ -908,7 +909,7 @@ nv40_fragprog_upload(struct nv40_context *nv40, } } - ws->buffer_unmap(ws, fp->buffer); + pipe_buffer_unmap(pscreen, fp->buffer); } static boolean @@ -917,8 +918,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) struct nv40_fragment_program *fp = nv40->fragprog; struct pipe_buffer *constbuf = nv40->constbuf[PIPE_SHADER_FRAGMENT]; - struct pipe_screen *screen = nv40->pipe.screen; - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_stateobj *so; boolean new_consts = FALSE; int i; @@ -933,7 +933,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) return FALSE; } - fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4); + fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv40_fragprog_upload(nv40, fp); so = so_new(4, 1); @@ -951,7 +951,8 @@ update_constants: if (fp->nr_consts) { float *map; - map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); for (i = 0; i < fp->nr_consts; i++) { struct nv40_fragment_program_data *fpd = &fp->consts[i]; uint32_t *p = &fp->insn[fpd->offset]; @@ -962,7 +963,7 @@ update_constants: memcpy(p, cb, 4 * sizeof(float)); new_consts = TRUE; } - ws->buffer_unmap(ws, constbuf); + pipe_buffer_unmap(pscreen, constbuf); if (new_consts) nv40_fragprog_upload(nv40, fp); diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 24bd116539..b2753b8e2e 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -1,5 +1,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv40_context.h" #include "nv40_state.h" @@ -108,7 +109,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, int attrib, struct pipe_vertex_element *ve, struct pipe_vertex_buffer *vb) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_grobj *curie = nv40->screen->curie; unsigned type, ncomp; void *map; @@ -116,7 +117,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp)) return FALSE; - map = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); map += vb->buffer_offset + ve->src_offset; switch (type) { @@ -148,17 +149,17 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, so_data (so, fui(v[0])); break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } } break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return TRUE; } @@ -367,10 +368,10 @@ nv40_draw_elements_inline(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; void *map; - map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ); if (!ib) { NOUVEAU_ERR("failed mapping ib\n"); return FALSE; @@ -391,7 +392,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe, break; } - ws->buffer_unmap(ws, ib); + pipe_buffer_unmap(pscreen, ib); return TRUE; } diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c index f32d4d690c..e75e8d3f42 100644 --- a/src/gallium/drivers/nv40/nv40_vertprog.c +++ b/src/gallium/drivers/nv40/nv40_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -855,7 +856,7 @@ out_err: static boolean nv40_vertprog_validate(struct nv40_context *nv40) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_vertex_program *vp; struct pipe_buffer *constbuf; @@ -980,8 +981,8 @@ check_gpu_resources: float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -1002,7 +1003,7 @@ check_gpu_resources: } if (constbuf) - ws->buffer_unmap(ws, constbuf); + pscreen->buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 9d6427e2bc..5f7d06dbec 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2235,7 +2235,7 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map, static void nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) { - struct pipe_winsys *ws = nv50->pipe.winsys; + struct pipe_screen *pscreen = nv50->pipe.screen; if (!p->data[0] && p->immd_nr) { struct nouveau_resource *heap = nv50->screen->immd_heap[0]; @@ -2274,13 +2274,13 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) if (p->param_nr) { unsigned cbuf = NV50_CB_PVP; - float *map = ws->buffer_map(ws, nv50->constbuf[p->type], - PIPE_BUFFER_USAGE_CPU_READ); + float *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type], + PIPE_BUFFER_USAGE_CPU_READ); if (p->type == PIPE_SHADER_FRAGMENT) cbuf = NV50_CB_PFP; nv50_program_upload_data(nv50, map, p->data[1]->start, p->param_nr, cbuf); - ws->buffer_unmap(ws, nv50->constbuf[p->type]); + pipe_buffer_unmap(pscreen, nv50->constbuf[p->type]); } } diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index c77ffe84e7..f57540150a 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -105,7 +105,7 @@ static boolean nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, boolean wait, uint64_t *result) { - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; struct nv50_query *q = nv50_query(pq); /*XXX: Want to be able to return FALSE here instead of blocking @@ -113,11 +113,11 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, */ if (!q->ready) { - uint32_t *map = ws->buffer_map(ws, q->buffer, - PIPE_BUFFER_USAGE_CPU_READ); + uint32_t *map = pipe_buffer_map(pscreen, q->buffer, + PIPE_BUFFER_USAGE_CPU_READ); q->result = map[1]; q->ready = TRUE; - ws->buffer_unmap(ws, q->buffer); + pipe_buffer_unmap(pscreen, q->buffer); } *result = q->result; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index a9b53a0f2e..f81929f238 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -22,6 +22,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv50_context.h" @@ -165,8 +166,10 @@ nv50_draw_elements(struct pipe_context *pipe, struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct pipe_winsys *ws = pipe->winsys; - void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + struct pipe_screen *pscreen = pipe->screen; + void *map; + + map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); nv50_state_validate(nv50); @@ -193,6 +196,7 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + pipe_buffer_unmap(pscreen, indexBuffer); pipe->flush(pipe, 0, NULL); return TRUE; } diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile index 621ad2a807..54c3b26c75 100644 --- a/src/gallium/winsys/drm/nouveau/drm/Makefile +++ b/src/gallium/winsys/drm/nouveau/drm/Makefile @@ -3,8 +3,7 @@ include $(TOP)/configs/current LIBNAME = nouveaudrm -C_SOURCES = nouveau_drm_api.c \ - nouveau_winsys_pipe.c +C_SOURCES = nouveau_drm_api.c LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 22c53f6ea9..395b21ec7a 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -1,12 +1,16 @@ +#include "pipe/p_context.h" +#include "pipe/p_state.h" #include "util/u_memory.h" #include "nouveau_drm_api.h" -#include "nouveau_winsys_pipe.h" #include "nouveau_drmif.h" #include "nouveau_channel.h" #include "nouveau_bo.h" +#include "nouveau/nouveau_winsys.h" +#include "nouveau/nouveau_screen.h" + static struct pipe_surface * dri_surface_from_handle(struct pipe_screen *screen, unsigned handle, @@ -58,7 +62,7 @@ dri_surface_from_handle(struct pipe_screen *screen, static struct pipe_surface * nouveau_dri1_front_surface(struct pipe_context *pipe) { - return nouveau_screen(pipe->screen)->front; + return nouveau_winsys_screen(pipe->screen)->front; } static struct dri1_api nouveau_dri1_api = { @@ -69,6 +73,7 @@ static struct pipe_screen * nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct dri1_create_screen_arg *dri1 = (void *)arg; + struct nouveau_winsys *nvws; struct pipe_winsys *ws; struct nouveau_device *dev = NULL; struct pipe_screen *(*init)(struct pipe_winsys *, @@ -107,20 +112,20 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) return NULL; } - ws = nouveau_pipe_winsys_new(dev); - if (!ws) { + nvws = CALLOC_STRUCT(nouveau_winsys); + if (!nvws) { nouveau_device_close(&dev); return NULL; } + ws = &nvws->base; - nouveau_pipe_winsys(ws)->pscreen = init(ws, dev); - if (!nouveau_pipe_winsys(ws)->pscreen) { + nvws->pscreen = init(ws, dev); + if (!nvws->pscreen) { ws->destroy(ws); return NULL; } if (arg->mode == DRM_CREATE_DRI1) { - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); struct nouveau_dri *nvdri = dri1->ddx_info; enum pipe_format format; @@ -129,14 +134,14 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) else format = PIPE_FORMAT_A8R8G8B8_UNORM; - nvpws->front = dri_surface_from_handle(nvpws->pscreen, + nvws->front = dri_surface_from_handle(nvws->pscreen, nvdri->front_offset, format, nvdri->width, nvdri->height, nvdri->front_pitch * (nvdri->bpp / 8)); - if (!nvpws->front) { + if (!nvws->front) { debug_printf("%s: error referencing front buffer\n", __func__); ws->destroy(ws); @@ -146,15 +151,15 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) dri1->api = &nouveau_dri1_api; } - return nouveau_pipe_winsys(ws)->pscreen; + return nvws->pscreen; } static struct pipe_context * nouveau_drm_create_context(struct pipe_screen *pscreen) { - struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen); + struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen); struct pipe_context *(*init)(struct pipe_screen *, unsigned); - unsigned chipset = nvpws->channel->device->chipset; + unsigned chipset = nouveau_screen(pscreen)->device->chipset; int i; switch (chipset & 0xf0) { @@ -185,19 +190,19 @@ nouveau_drm_create_context(struct pipe_screen *pscreen) } /* Find a free slot for a pipe context, allocate a new one if needed */ - for (i = 0; i < nvpws->nr_pctx; i++) { - if (nvpws->pctx[i] == NULL) + for (i = 0; i < nvws->nr_pctx; i++) { + if (nvws->pctx[i] == NULL) break; } - if (i == nvpws->nr_pctx) { - nvpws->nr_pctx++; - nvpws->pctx = realloc(nvpws->pctx, - sizeof(*nvpws->pctx) * nvpws->nr_pctx); + if (i == nvws->nr_pctx) { + nvws->nr_pctx++; + nvws->pctx = realloc(nvws->pctx, + sizeof(*nvws->pctx) * nvws->nr_pctx); } - nvpws->pctx[i] = init(pscreen, i); - return nvpws->pctx[i]; + nvws->pctx[i] = init(pscreen, i); + return nvws->pctx[i]; } static boolean @@ -211,42 +216,41 @@ static struct pipe_buffer * nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name, unsigned handle) { - struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvpb; + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct pipe_buffer *pb; int ret; - nvpb = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvpb) + pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*)); + if (!pb) return NULL; - ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo); + ret = nouveau_bo_handle_ref(dev, handle, (struct nouveau_bo**)(pb+1)); if (ret) { debug_printf("%s: ref name 0x%08x failed with %d\n", __func__, handle, ret); - FREE(nvpb); + FREE(pb); return NULL; } - pipe_reference_init(&nvpb->base.reference, 1); - nvpb->base.screen = pscreen; - nvpb->base.alignment = 0; - nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | - PIPE_BUFFER_USAGE_CPU_READ_WRITE; - nvpb->base.size = nvpb->bo->size; - return &nvpb->base; + pipe_reference_init(&pb->reference, 1); + pb->screen = pscreen; + pb->alignment = 0; + pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | + PIPE_BUFFER_USAGE_CPU_READ_WRITE; + pb->size = nouveau_bo(pb)->size; + return pb; } static boolean nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned *handle) { - struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb); + struct nouveau_bo *bo = nouveau_bo(pb); - if (!nvpb) + if (!bo) return FALSE; - *handle = nvpb->bo->handle; + *handle = bo->handle; return TRUE; } @@ -254,12 +258,12 @@ static boolean nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned *handle) { - struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb); + struct nouveau_bo *bo = nouveau_bo(pb); - if (!nvpb) + if (!bo) return FALSE; - return nouveau_bo_handle_get(nvpb->bo, handle) == 0; + return nouveau_bo_handle_get(bo, handle) == 0; } struct drm_api drm_api_hooks = { diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h index cc237bfc13..e61e0e0957 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h @@ -1,7 +1,34 @@ #ifndef __NOUVEAU_DRM_API_H__ #define __NOUVEAU_DRM_API_H__ + #include "state_tracker/drm_api.h" #include "state_tracker/dri1_api.h" + +#include "pipe/internal/p_winsys_screen.h" + #include "nouveau_dri.h" +struct nouveau_winsys { + struct pipe_winsys base; + + struct pipe_screen *pscreen; + + unsigned nr_pctx; + struct pipe_context **pctx; + + struct pipe_surface *front; +}; + +static INLINE struct nouveau_winsys * +nouveau_winsys(struct pipe_winsys *ws) +{ + return (struct nouveau_winsys *)ws; +} + +static INLINE struct nouveau_winsys * +nouveau_winsys_screen(struct pipe_screen *pscreen) +{ + return nouveau_winsys(pscreen->winsys); +} + #endif diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c deleted file mode 100644 index 2dca8cd3a9..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c +++ /dev/null @@ -1,205 +0,0 @@ -#include "pipe/internal/p_winsys_screen.h" -#include -#include -#include - -#include "nouveau_winsys_pipe.h" - -#include "nouveau_drmif.h" -#include "nouveau_bo.h" - -static const char * -nouveau_get_name(struct pipe_winsys *pws) -{ - return "Nouveau/DRI"; -} - -static uint32_t -nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct pipe_screen *pscreen = nvpws->pscreen; - uint32_t flags = NOUVEAU_BO_LOCAL; - - if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER) - flags |= NOUVEAU_BO_GART; - - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE) - flags |= NOUVEAU_BO_GART; - if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE)) - flags |= NOUVEAU_BO_VRAM; - - switch (nvpws->channel->device->chipset & 0xf0) { - case 0x50: - case 0x80: - case 0x90: - flags |= NOUVEAU_BO_TILED; - if (usage & NOUVEAU_BUFFER_USAGE_ZETA) - flags |= NOUVEAU_BO_ZTILE; - break; - default: - break; - } - } - - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF)) - flags |= NOUVEAU_BO_GART; - } - - if (usage & PIPE_BUFFER_USAGE_INDEX) { - if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF)) - flags |= NOUVEAU_BO_GART; - } - - return flags; -} - -static struct pipe_buffer * -nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment, - unsigned usage, unsigned size) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvbuf; - uint32_t flags; - - nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvbuf) - return NULL; - pipe_reference_init(&nvbuf->base.reference, 1); - nvbuf->base.alignment = alignment; - nvbuf->base.usage = usage; - nvbuf->base.size = size; - - flags = nouveau_flags_from_usage(ws, usage); - flags |= NOUVEAU_BO_MAP; - if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) { - FREE(nvbuf); - return NULL; - } - - return &nvbuf->base; -} - -static struct pipe_buffer * -nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvbuf; - - nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvbuf) - return NULL; - pipe_reference_init(&nvbuf->base.reference, 1); - nvbuf->base.size = bytes; - - if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) { - FREE(nvbuf); - return NULL; - } - - return &nvbuf->base; -} - -static void -nouveau_pipe_bo_del(struct pipe_buffer *buf) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - - nouveau_bo_ref(NULL, &nvbuf->bo); - FREE(nvbuf); -} - -static void * -nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - uint32_t map_flags = 0; - - if (flags & PIPE_BUFFER_USAGE_CPU_READ) - map_flags |= NOUVEAU_BO_RD; - if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) - map_flags |= NOUVEAU_BO_WR; - - if (nouveau_bo_map(nvbuf->bo, map_flags)) - return NULL; - return nvbuf->bo->map; -} - -static void -nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - - nouveau_bo_unmap(nvbuf->bo); -} - -static void -nouveau_pipe_fence_reference(struct pipe_winsys *ws, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *pfence) -{ - *ptr = pfence; -} - -static int -nouveau_pipe_fence_signalled(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, unsigned flag) -{ - return 0; -} - -static int -nouveau_pipe_fence_finish(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, unsigned flag) -{ - return 0; -} - -static void -nouveau_destroy(struct pipe_winsys *ws) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - - nouveau_device_close(&nvpws->channel->device); - FREE(nvpws); -} - -struct pipe_winsys * -nouveau_pipe_winsys_new(struct nouveau_device *dev) -{ - struct nouveau_pipe_winsys *nvpws; - int ret; - - nvpws = CALLOC_STRUCT(nouveau_pipe_winsys); - if (!nvpws) - return NULL; - - ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202, - &nvpws->channel); - if (ret) { - debug_printf("%s: error opening GPU channel: %d\n", - __func__, ret); - FREE(nvpws); - return NULL; - } - nvpws->next_handle = 0x77000000; - - nvpws->base.buffer_create = nouveau_pipe_bo_create; - nvpws->base.buffer_destroy = nouveau_pipe_bo_del; - nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create; - nvpws->base.buffer_map = nouveau_pipe_bo_map; - nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap; - - nvpws->base.fence_reference = nouveau_pipe_fence_reference; - nvpws->base.fence_signalled = nouveau_pipe_fence_signalled; - nvpws->base.fence_finish = nouveau_pipe_fence_finish; - - nvpws->base.get_name = nouveau_get_name; - nvpws->base.destroy = nouveau_destroy; - return &nvpws->base; -} diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h deleted file mode 100644 index ec10f1e00c..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef NOUVEAU_PIPE_WINSYS_H -#define NOUVEAU_PIPE_WINSYS_H - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_context.h" - -#include "nouveau/nouveau_winsys.h" - -#include "nouveau_device.h" - -struct nouveau_pipe_buffer { - struct pipe_buffer base; - struct nouveau_bo *bo; -}; - -static INLINE struct nouveau_pipe_buffer * -nouveau_pipe_buffer(struct pipe_buffer *buf) -{ - return (struct nouveau_pipe_buffer *)buf; -} - -struct nouveau_pipe_winsys { - struct pipe_winsys base; - - struct pipe_screen *pscreen; - - struct nouveau_channel *channel; - uint32_t next_handle; - - unsigned nr_pctx; - struct pipe_context **pctx; - - struct pipe_surface *front; -}; - -static INLINE struct nouveau_pipe_winsys * -nouveau_pipe_winsys(struct pipe_winsys *ws) -{ - return (struct nouveau_pipe_winsys *)ws; -} - -static INLINE struct nouveau_pipe_winsys * -nouveau_screen(struct pipe_screen *pscreen) -{ - return nouveau_pipe_winsys(pscreen->winsys); -} - -struct pipe_winsys * -nouveau_pipe_winsys_new(struct nouveau_device *); - -struct nouveau_winsys * -nouveau_winsys_new(struct pipe_winsys *ws); - -#endif -- cgit v1.2.3 From 40ed44991851a526f0e2cafd5dab6149cb7a3342 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 12:27:42 +1000 Subject: nouveau: fix build with libdrm_nouveau 0.6 --- src/gallium/drivers/nouveau/nouveau_push.h | 2 +- src/gallium/drivers/nouveau/nouveau_screen.c | 9 ++++----- src/gallium/drivers/nouveau/nouveau_stateobj.h | 8 ++++---- src/gallium/drivers/nv50/nv50_surface.c | 4 ++-- src/gallium/drivers/nv50/nv50_tex.c | 2 +- src/gallium/drivers/nv50/nv50_transfer.c | 12 ++++++------ 6 files changed, 18 insertions(+), 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_push.h b/src/gallium/drivers/nouveau/nouveau_push.h index 0f2c42915b..9c235080a5 100644 --- a/src/gallium/drivers/nouveau/nouveau_push.h +++ b/src/gallium/drivers/nouveau/nouveau_push.h @@ -54,7 +54,7 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) NOUVEAU_PUSH_CONTEXT(pc); \ struct nouveau_channel *chan = pc->base.channel; \ nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, nouveau_bo(bo), \ - (data), (flags), (vor), (tor)); \ + (data), 0, (flags), (vor), (tor)); \ } while(0) /* Raw data + flags depending on FB/TT buffer */ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index ab522a124a..0ab1d82ebc 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -8,6 +8,8 @@ #include "nouveau_winsys.h" #include "nouveau_screen.h" +//#define ENABLE_BUFRANGE + static const char * nouveau_screen_get_name(struct pipe_screen *pscreen) { @@ -109,16 +111,13 @@ nouveau_screen_map_flags(unsigned pipe) flags |= NOUVEAU_BO_RD; if (pipe & PIPE_BUFFER_USAGE_CPU_WRITE) flags |= NOUVEAU_BO_WR; -#ifdef NOUVEAU_BO_NOWAIT if (pipe & PIPE_BUFFER_USAGE_DISCARD) flags |= NOUVEAU_BO_INVAL; - if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK) flags |= NOUVEAU_BO_NOWAIT; else if (pipe & 0 /*PIPE_BUFFER_USAGE_UNSYNCHRONIZED*/) flags |= NOUVEAU_BO_NOSYNC; -#endif return flags; } @@ -139,7 +138,7 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, return bo->map; } -#ifdef NOUVEAU_BO_NOWAIT +#ifdef ENABLE_BUFRANGE static void * nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned offset, unsigned length, unsigned usage) @@ -226,7 +225,7 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->buffer_create = nouveau_screen_bo_new; pscreen->user_buffer_create = nouveau_screen_bo_user; pscreen->buffer_map = nouveau_screen_bo_map; -#ifdef NOUVEAU_BO_NOWAIT +#ifdef ENABLE_BUFRANGE pscreen->buffer_map_range = nouveau_screen_bo_map_range; pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush; #endif diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index 8e818d9d38..b595405357 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -122,8 +122,8 @@ so_emit(struct nouveau_channel *chan, struct nouveau_stateobj *so) struct nouveau_stateobj_reloc *r = &so->reloc[i]; nouveau_pushbuf_emit_reloc(chan, pb->cur + r->offset, - r->bo, r->data, r->flags, r->vor, - r->tor); + r->bo, r->data, 0, r->flags, + r->vor, r->tor); } pb->cur += nr; } @@ -145,12 +145,12 @@ so_emit_reloc_markers(struct nouveau_channel *chan, struct nouveau_stateobj *so) for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->packet, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->packet, 0, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); - nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->data, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->data, 0, r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor); } diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index cd4e7ef690..936fe43561 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -62,7 +62,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) if (format < 0) return 1; - if (!bo->tiled) { + if (!bo->tile_flags) { BEGIN_RING(chan, eng2d, mthd, 2); OUT_RING (chan, format); OUT_RING (chan, 1); @@ -76,7 +76,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) BEGIN_RING(chan, eng2d, mthd, 5); OUT_RING (chan, format); OUT_RING (chan, 0); - OUT_RING (chan, 0); + OUT_RING (chan, bo->tile_mode << 4); OUT_RING (chan, 1); OUT_RING (chan, 0); BEGIN_RING(chan, eng2d, mthd + 0x18, 4); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 86947faee3..5539a796e8 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -122,7 +122,7 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, so_reloc(so, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); - so_data (so, 0xd0005000); + so_data (so, 0xd0005000 | bo->tile_mode << 22); so_data (so, 0x00300000); so_data (so, mt->base.width[0]); so_data (so, (mt->base.last_level << 28) | diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index a0a2099035..babb35a227 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -34,7 +34,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, WAIT_RING (chan, 14); - if (!src_bo->tiled) { + if (!src_bo->tile_flags) { BEGIN_RING(chan, m2mf, 0x0200, 1); OUT_RING (chan, 1); BEGIN_RING(chan, m2mf, 0x0314, 1); @@ -43,14 +43,14 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, } else { BEGIN_RING(chan, m2mf, 0x0200, 6); OUT_RING (chan, 0); - OUT_RING (chan, 0); + OUT_RING (chan, src_bo->tile_mode << 4); OUT_RING (chan, sw * cpp); OUT_RING (chan, sh); OUT_RING (chan, 1); OUT_RING (chan, 0); } - if (!dst_bo->tiled) { + if (!dst_bo->tile_flags) { BEGIN_RING(chan, m2mf, 0x021c, 1); OUT_RING (chan, 1); BEGIN_RING(chan, m2mf, 0x0318, 1); @@ -59,7 +59,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, } else { BEGIN_RING(chan, m2mf, 0x021c, 6); OUT_RING (chan, 0); - OUT_RING (chan, 0); + OUT_RING (chan, dst_bo->tile_mode << 4); OUT_RING (chan, dw * cpp); OUT_RING (chan, dh); OUT_RING (chan, 1); @@ -76,13 +76,13 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, BEGIN_RING(chan, m2mf, 0x030c, 2); OUT_RELOCl(chan, src_bo, src_offset, src_reloc); OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc); - if (src_bo->tiled) { + if (src_bo->tile_flags) { BEGIN_RING(chan, m2mf, 0x0218, 1); OUT_RING (chan, (dy << 16) | sx); } else { src_offset += (line_count * src_pitch); } - if (dst_bo->tiled) { + if (dst_bo->tile_flags) { BEGIN_RING(chan, m2mf, 0x0234, 1); OUT_RING (chan, (sy << 16) | dx); } else { -- cgit v1.2.3 From 36705ee044681da9899d0950c22ae7baa10c3d33 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 14:48:45 +1000 Subject: nouveau: plug in our map_buffer_range and friends --- src/gallium/drivers/nouveau/nouveau_screen.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 0ab1d82ebc..832366e646 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -8,8 +8,6 @@ #include "nouveau_winsys.h" #include "nouveau_screen.h" -//#define ENABLE_BUFRANGE - static const char * nouveau_screen_get_name(struct pipe_screen *pscreen) { @@ -138,7 +136,6 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, return bo->map; } -#ifdef ENABLE_BUFRANGE static void * nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned offset, unsigned length, unsigned usage) @@ -153,7 +150,7 @@ nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, return NULL; } - return bo->map; + return (char *)bo->map - offset; /* why gallium? why? */ } static void @@ -164,7 +161,6 @@ nouveau_screen_bo_map_flush(struct pipe_screen *pscreen, struct pipe_buffer *pb, nouveau_bo_map_flush(bo, offset, length); } -#endif static void nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct pipe_buffer *pb) @@ -225,10 +221,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->buffer_create = nouveau_screen_bo_new; pscreen->user_buffer_create = nouveau_screen_bo_user; pscreen->buffer_map = nouveau_screen_bo_map; -#ifdef ENABLE_BUFRANGE pscreen->buffer_map_range = nouveau_screen_bo_map_range; pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush; -#endif pscreen->buffer_unmap = nouveau_screen_bo_unmap; pscreen->buffer_destroy = nouveau_screen_bo_del; -- cgit v1.2.3 From fb7d1fb0f0ce4137b6cb84198997241d190d13a8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Jun 2009 21:38:33 -0700 Subject: r300: Moar vs debug. --- src/gallium/drivers/r300/r300_debug.c | 19 ++++++++++++++++--- src/gallium/drivers/r300/r300_debug.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index ffc93eb591..32fa739a1e 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -165,14 +165,27 @@ static void r300_vs_op_dump(uint32_t op) } } +void r300_vs_src_dump(uint32_t src) +{ + debug_printf(" %s/%s/%s/%s\n", + r300_vs_swiz_debug[(src >> 13) & 0x7], + r300_vs_swiz_debug[(src >> 16) & 0x7], + r300_vs_swiz_debug[(src >> 19) & 0x7], + r300_vs_swiz_debug[(src >> 22) & 0x7]); +} + void r300_vs_dump(struct r300_vertex_shader* vs) { int i; for (i = 0; i < vs->instruction_count; i++) { + debug_printf("%d: op: 0x%08x", i, vs->instructions[i].inst0); r300_vs_op_dump(vs->instructions[i].inst0); - debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1); - debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2); - debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3); + debug_printf(" src0: 0x%08x", vs->instructions[i].inst1); + r300_vs_src_dump(vs->instructions[i].inst1); + debug_printf(" src1: 0x%08x", vs->instructions[i].inst2); + r300_vs_src_dump(vs->instructions[i].inst2); + debug_printf(" src2: 0x%08x", vs->instructions[i].inst3); + r300_vs_src_dump(vs->instructions[i].inst3); } } diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h index 6306594099..3939d834c2 100644 --- a/src/gallium/drivers/r300/r300_debug.h +++ b/src/gallium/drivers/r300/r300_debug.h @@ -173,6 +173,18 @@ static char* r300_vs_me_ops[] = { " (reserved)", }; +/* XXX refactor to avoid clashing symbols */ +static char* r300_vs_swiz_debug[] = { + "X", + "Y", + "Z", + "W", + "0", + "1", + "U", + "U", +}; + void r500_fs_dump(struct r500_fragment_shader* fs); void r300_vs_dump(struct r300_vertex_shader* vs); -- cgit v1.2.3 From 31609acbe9d80daea49e98f026196023a20258a0 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Jun 2009 22:41:33 -0700 Subject: r300-gallium: vs: Add negation, SUB. Doesn't work. WTF. --- src/gallium/drivers/r300/r300_debug.c | 6 +++++- src/gallium/drivers/r300/r300_state_tcl.c | 17 +++++++++++++---- src/gallium/drivers/r300/r300_state_tcl.h | 7 +++++++ 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 32fa739a1e..1a8c17b28d 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -167,10 +167,14 @@ static void r300_vs_op_dump(uint32_t op) void r300_vs_src_dump(uint32_t src) { - debug_printf(" %s/%s/%s/%s\n", + debug_printf(" %s%s/%s%s/%s%s/%s%s\n", + src & (1 << 25) ? "-" : " ", r300_vs_swiz_debug[(src >> 13) & 0x7], + src & (1 << 26) ? "-" : " ", r300_vs_swiz_debug[(src >> 16) & 0x7], + src & (1 << 27) ? "-" : " ", r300_vs_swiz_debug[(src >> 19) & 0x7], + src & (1 << 28) ? "-" : " ", r300_vs_swiz_debug[(src >> 22) & 0x7]); } diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 32e61bc1d7..30a8dab307 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -144,6 +144,7 @@ static uint32_t r300_vs_op(unsigned op) return R300_VE_MULTIPLY; case TGSI_OPCODE_ADD: case TGSI_OPCODE_MOV: + case TGSI_OPCODE_SUB: case TGSI_OPCODE_SWZ: return R300_VE_ADD; case TGSI_OPCODE_MAX: @@ -163,12 +164,14 @@ static uint32_t r300_vs_op(unsigned op) static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) { if (reg->SrcRegister.Extended) { - return reg->SrcRegisterExtSwz.ExtSwizzleX | + return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + reg->SrcRegisterExtSwz.ExtSwizzleX | (reg->SrcRegisterExtSwz.ExtSwizzleY << 3) | (reg->SrcRegisterExtSwz.ExtSwizzleZ << 6) | (reg->SrcRegisterExtSwz.ExtSwizzleW << 9); } else { - return reg->SrcRegister.SwizzleX | + return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + reg->SrcRegister.SwizzleX | (reg->SrcRegister.SwizzleY << 3) | (reg->SrcRegister.SwizzleZ << 6) | (reg->SrcRegister.SwizzleW << 9); @@ -179,12 +182,14 @@ static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) static uint32_t r300_vs_scalar_swiz(struct tgsi_full_src_register* reg) { if (reg->SrcRegister.Extended) { - return reg->SrcRegisterExtSwz.ExtSwizzleX | + return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + reg->SrcRegisterExtSwz.ExtSwizzleX | (reg->SrcRegisterExtSwz.ExtSwizzleX << 3) | (reg->SrcRegisterExtSwz.ExtSwizzleX << 6) | (reg->SrcRegisterExtSwz.ExtSwizzleX << 9); } else { - return reg->SrcRegister.SwizzleX | + return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + reg->SrcRegister.SwizzleX | (reg->SrcRegister.SwizzleX << 3) | (reg->SrcRegister.SwizzleX << 6) | (reg->SrcRegister.SwizzleX << 9); @@ -246,6 +251,10 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs, &inst->FullDstRegisters[0], inst->Instruction.Opcode, 1, TRUE); break; + case TGSI_OPCODE_SUB: + inst->FullSrcRegisters[1].SrcRegister.Negate = + !inst->FullSrcRegisters[1].SrcRegister.Negate; + /* Fall through */ case TGSI_OPCODE_ADD: case TGSI_OPCODE_MUL: case TGSI_OPCODE_MAX: diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_state_tcl.h index d5d425e9d6..2c8b586c2f 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.h +++ b/src/gallium/drivers/r300/r300_state_tcl.h @@ -76,6 +76,13 @@ ((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) static const struct tgsi_full_src_register r300_constant_zero = { .SrcRegister.Extended = TRUE, -- cgit v1.2.3 From 8652ad68992a63a275bdc3816540c39776b143b2 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Jun 2009 23:25:46 -0700 Subject: r300-gallium: Improve vs debug more. Still not showing me why my stuff's failing, but getting there. --- src/gallium/drivers/r300/r300_debug.c | 5 ++++- src/gallium/drivers/r300/r300_debug.h | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 1a8c17b28d..678cd2b812 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -152,6 +152,8 @@ void r500_fs_dump(struct r500_fragment_shader* fs) static void r300_vs_op_dump(uint32_t op) { + debug_printf(" dst: %d%s op: ", + (op >> 13) & 0x7f, r300_vs_dst_debug[(op >> 8) & 0x7]); if (op & 0x80) { if (op & 0x1) { debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n"); @@ -167,7 +169,8 @@ static void r300_vs_op_dump(uint32_t op) void r300_vs_src_dump(uint32_t src) { - debug_printf(" %s%s/%s%s/%s%s/%s%s\n", + debug_printf(" reg: %d%s swiz: %s%s/%s%s/%s%s/%s%s\n", + (src >> 5) & 0x7f, r300_vs_src_debug[src & 0x3], src & (1 << 25) ? "-" : " ", r300_vs_swiz_debug[(src >> 13) & 0x7], src & (1 << 26) ? "-" : " ", diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h index 3939d834c2..c86410ec0a 100644 --- a/src/gallium/drivers/r300/r300_debug.h +++ b/src/gallium/drivers/r300/r300_debug.h @@ -174,6 +174,24 @@ static char* r300_vs_me_ops[] = { }; /* XXX refactor to avoid clashing symbols */ +static char* r300_vs_src_debug[] = { + "t", + "i", + "c", + "a", +}; + +static char* r300_vs_dst_debug[] = { + "t", + "a0", + "o", + "ox", + "a", + "i", + "u", + "u", +}; + static char* r300_vs_swiz_debug[] = { "X", "Y", -- cgit v1.2.3 From 571b36831bed3c8dd5691cad5b544667d07c60b0 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Jun 2009 23:56:08 -0700 Subject: r300-gallium: Fix pasta. Trivial but annoying. --- src/gallium/drivers/r300/r300_emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index caeb73a8ed..61b416663b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -374,7 +374,7 @@ void r300_emit_vertex_shader(struct r300_context* r300, if (constants->count) { BEGIN_CS(16 + (vs->instruction_count * 4) + (constants->count * 4)); } else { - BEGIN_CS(13 + (vs->instruction_count * 4) + (constants->count * 4)); + BEGIN_CS(13 + (vs->instruction_count * 4)); } OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) | -- cgit v1.2.3 From 4c66c5bf921357c94611e583d1a64f653e957765 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Jun 2009 23:56:32 -0700 Subject: r300-gallium: vs: Fix negation calculation. Still doesn't draw right, but at least it's the right numbers now. Thanks to taiu in #dri-devel. --- src/gallium/drivers/r300/r300_state_tcl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index 30a8dab307..8cf8250425 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -164,13 +164,13 @@ static uint32_t r300_vs_op(unsigned op) static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) { if (reg->SrcRegister.Extended) { - return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + return (reg->SrcRegister.Negate ? (0xf << 12) : 0) | reg->SrcRegisterExtSwz.ExtSwizzleX | (reg->SrcRegisterExtSwz.ExtSwizzleY << 3) | (reg->SrcRegisterExtSwz.ExtSwizzleZ << 6) | (reg->SrcRegisterExtSwz.ExtSwizzleW << 9); } else { - return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + return (reg->SrcRegister.Negate ? (0xf << 12) : 0) | reg->SrcRegister.SwizzleX | (reg->SrcRegister.SwizzleY << 3) | (reg->SrcRegister.SwizzleZ << 6) | @@ -182,13 +182,13 @@ static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg) static uint32_t r300_vs_scalar_swiz(struct tgsi_full_src_register* reg) { if (reg->SrcRegister.Extended) { - return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + return (reg->SrcRegister.Negate ? (0xf << 12) : 0) | reg->SrcRegisterExtSwz.ExtSwizzleX | (reg->SrcRegisterExtSwz.ExtSwizzleX << 3) | (reg->SrcRegisterExtSwz.ExtSwizzleX << 6) | (reg->SrcRegisterExtSwz.ExtSwizzleX << 9); } else { - return (reg->SrcRegister.Negate ? R300_PVS_NEGATE_XYZW : 0) | + return (reg->SrcRegister.Negate ? (0xf << 12) : 0) | reg->SrcRegister.SwizzleX | (reg->SrcRegister.SwizzleX << 3) | (reg->SrcRegister.SwizzleX << 6) | -- cgit v1.2.3 From 90bfff0a295ce28143ecde98ed91eb6d8cfba23c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 5 Jun 2009 00:12:26 -0700 Subject: r300-gallium: Mute some debug info. Most of it is no longer interesting. --- src/gallium/drivers/r300/r300_cs.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 2abf04d27e..71b142c0db 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -34,6 +34,7 @@ #define MAX_CS_SIZE 64 * 1024 / 4 +#define VERY_VERBOSE_CS 0 #define VERY_VERBOSE_REGISTERS 0 /* XXX stolen from radeon_drm.h */ @@ -56,8 +57,10 @@ #define BEGIN_CS(size) do { \ CHECK_CS(size); \ - debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \ - size, __FUNCTION__, __FILE__, __LINE__); \ + if (VERY_VERBOSE_CS) { \ + debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \ + size, __FUNCTION__, __FILE__, __LINE__); \ + } \ cs_winsys->begin_cs(cs_winsys, (size), \ __FILE__, __FUNCTION__, __LINE__); \ cs_count = size; \ @@ -103,16 +106,20 @@ } while (0) #define END_CS do { \ - debug_printf("r300: END_CS in %s (%s:%d)\n", __FUNCTION__, __FILE__, \ - __LINE__); \ + if (VERY_VERBOSE_CS) { \ + debug_printf("r300: END_CS in %s (%s:%d)\n", __FUNCTION__, \ + __FILE__, __LINE__); \ + } \ if (cs_count != 0) \ debug_printf("r300: Warning: cs_count off by %d\n", cs_count); \ cs_winsys->end_cs(cs_winsys, __FILE__, __FUNCTION__, __LINE__); \ } while (0) #define FLUSH_CS do { \ - debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, __FILE__, \ - __LINE__); \ + if (VERY_VERBOSE_CS) { \ + debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, \ + __FILE__, __LINE__); \ + } \ cs_winsys->flush_cs(cs_winsys); \ } while (0) -- cgit v1.2.3 From b04470b0bce6a24a74a0ec8cf16d9d3f03aff5f2 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 5 Jun 2009 14:32:31 +0200 Subject: util: Fix winsock include. --- src/gallium/auxiliary/util/u_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c index 465d50255e..07d804ecdb 100644 --- a/src/gallium/auxiliary/util/u_network.c +++ b/src/gallium/auxiliary/util/u_network.c @@ -4,8 +4,8 @@ #include "util/u_debug.h" #if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# include # include -# include #elif defined(PIPE_OS_LINUX) # include # include -- cgit v1.2.3 From 1a92c71a66dd9d785906cdb78c107e63dcf48672 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 20:32:32 +1000 Subject: nv50: create textures with nouveau_bo, for flexibility with tiling later --- src/gallium/drivers/nv50/nv50_context.h | 10 ++----- src/gallium/drivers/nv50/nv50_miptree.c | 22 ++++++++------ src/gallium/drivers/nv50/nv50_state_validate.c | 6 ++-- src/gallium/drivers/nv50/nv50_surface.c | 2 +- src/gallium/drivers/nv50/nv50_tex.c | 6 ++-- src/gallium/drivers/nv50/nv50_transfer.c | 41 +++++++++++++++----------- 6 files changed, 46 insertions(+), 41 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 7b67a75439..c3ffdcca9f 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -70,7 +70,8 @@ struct nv50_miptree_level { struct nv50_miptree { struct pipe_texture base; - struct pipe_buffer *buffer; + + struct nouveau_bo *bo; struct nv50_miptree_level level[PIPE_MAX_TEXTURE_LEVELS]; int image_nr; @@ -93,13 +94,6 @@ nv50_surface(struct pipe_surface *pt) return (struct nv50_surface *)pt; } -static INLINE struct pipe_buffer * -nv50_surface_buffer(struct pipe_surface *surface) -{ - struct nv50_miptree *mt = (struct nv50_miptree *)surface->texture; - return mt->buffer; -} - struct nv50_state { unsigned dirty; diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index f79a7ca86c..2fbedb6779 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -29,23 +29,25 @@ static struct pipe_texture * nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) { + struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree); struct pipe_texture *pt = &mt->base; - unsigned usage, width = tmp->width[0], height = tmp->height[0]; + unsigned width = tmp->width[0], height = tmp->height[0]; unsigned depth = tmp->depth[0]; - int i, l; + uint32_t tile_mode = 0, tile_flags = 0; + int ret, i, l; mt->base = *tmp; pipe_reference_init(&mt->base.reference, 1); mt->base.screen = pscreen; - usage = PIPE_BUFFER_USAGE_PIXEL; switch (pt->format) { case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z16_UNORM: - usage |= NOUVEAU_BUFFER_USAGE_ZETA; + tile_flags = 0x2800; break; default: + tile_flags = 0x7000; break; } @@ -93,12 +95,13 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) } } - mt->buffer = pscreen->buffer_create(pscreen, 256, usage, mt->total_size); - if (!mt->buffer) { + ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, mt->total_size, + tile_mode, tile_flags, &mt->bo); + if (ret) { FREE(mt); return NULL; } - + return &mt->base; } @@ -106,6 +109,7 @@ static struct pipe_texture * nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt, const unsigned *stride, struct pipe_buffer *pb) { + struct nouveau_bo *bo = nouveau_bo(pb); struct nv50_miptree *mt; /* Only supports 2D, non-mipmapped textures for the moment */ @@ -124,7 +128,7 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt, mt->level[0].pitch = *stride; mt->level[0].image_offset = CALLOC(1, sizeof(unsigned)); - pipe_buffer_reference(&mt->buffer, pb); + nouveau_bo_ref(bo, &mt->bo); return &mt->base; } @@ -133,7 +137,7 @@ nv50_miptree_destroy(struct pipe_texture *pt) { struct nv50_miptree *mt = nv50_miptree(pt); - pipe_buffer_reference(&mt->buffer, NULL); + nouveau_bo_ref(NULL, &mt->bo); FREE(mt); } diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 9e70d4b78d..1788f76456 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -32,7 +32,8 @@ nv50_state_validate_fb(struct nv50_context *nv50) unsigned i, w, h, gw = 0; for (i = 0; i < fb->nr_cbufs; i++) { - struct nouveau_bo *bo = nouveau_bo(nv50_surface_buffer(fb->cbufs[i])); + struct pipe_texture *pt = fb->cbufs[i]->texture; + struct nouveau_bo *bo = nv50_miptree(pt)->bo; if (!gw) { w = fb->cbufs[i]->width; @@ -73,7 +74,8 @@ nv50_state_validate_fb(struct nv50_context *nv50) } if (fb->zsbuf) { - struct nouveau_bo *bo = nouveau_bo(nv50_surface_buffer(fb->zsbuf)); + struct pipe_texture *pt = fb->zsbuf->texture; + struct nouveau_bo *bo = nv50_miptree(pt)->bo; if (!gw) { w = fb->zsbuf->width; diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 936fe43561..8db3b6d344 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -54,7 +54,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) struct nv50_miptree *mt = nv50_miptree(ps->texture); struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; - struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer); + struct nouveau_bo *bo = nv50_miptree(ps->texture)->bo; int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 5539a796e8..8bb81392fd 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -29,8 +29,6 @@ static int nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, struct nv50_miptree *mt) { - struct nouveau_bo *bo = nouveau_bo(mt->buffer); - switch (mt->base.format) { case PIPE_FORMAT_A8R8G8B8_UNORM: so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | @@ -120,9 +118,9 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, return 1; } - so_reloc(so, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | + so_reloc(so, mt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); - so_data (so, 0xd0005000 | bo->tile_mode << 22); + so_data (so, 0xd0005000 | mt->bo->tile_mode << 22); so_data (so, 0x00300000); so_data (so, mt->base.width[0]); so_data (so, (mt->base.last_level << 28) | diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index babb35a227..d0b7f0bef4 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -6,7 +6,7 @@ struct nv50_transfer { struct pipe_transfer base; - struct pipe_buffer *buffer; + struct nouveau_bo *bo; unsigned level_offset; int level_pitch; int level_width; @@ -16,9 +16,9 @@ struct nv50_transfer { }; static void -nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, +nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct nouveau_bo *src_bo, unsigned src_offset, int src_pitch, int sx, int sy, - int sw, int sh, struct pipe_buffer *dst, + int sw, int sh, struct nouveau_bo *dst_bo, unsigned dst_offset, int dst_pitch, int dx, int dy, int dw, int dh, int cpp, int width, int height, unsigned src_reloc, unsigned dst_reloc) @@ -26,8 +26,6 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, struct nv50_screen *screen = nv50_screen(pscreen); struct nouveau_channel *chan = screen->m2mf->channel; struct nouveau_grobj *m2mf = screen->m2mf; - struct nouveau_bo *src_bo = nouveau_bo(src); - struct nouveau_bo *dst_bo = nouveau_bo(dst); src_reloc |= NOUVEAU_BO_RD; dst_reloc |= NOUVEAU_BO_WR; @@ -107,10 +105,12 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { + struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct nv50_miptree *mt = nv50_miptree(pt); struct nv50_miptree_level *lvl = &mt->level[level]; struct nv50_transfer *tx; unsigned image = 0; + int ret; if (pt->target == PIPE_TEXTURE_CUBE) image = face; @@ -138,14 +138,17 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, tx->level_offset = lvl->image_offset[image]; tx->level_x = x; tx->level_y = y; - tx->buffer = - pipe_buffer_create(pscreen, 0, NOUVEAU_BUFFER_USAGE_TRANSFER, - w * tx->base.block.size * h); + ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, + w * pt->block.size * h, &tx->bo); + if (ret) { + FREE(tx); + return NULL; + } if (usage != PIPE_TRANSFER_WRITE) { - nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_offset, + nv50_transfer_rect_m2mf(pscreen, mt->bo, tx->level_offset, tx->level_pitch, x, y, tx->level_width, - tx->level_height, tx->buffer, 0, + tx->level_height, tx->bo, 0, tx->base.stride, 0, 0, tx->base.width, tx->base.height, tx->base.block.size, w, h, @@ -164,9 +167,9 @@ nv50_transfer_del(struct pipe_transfer *ptx) if (ptx->usage != PIPE_TRANSFER_READ) { struct pipe_screen *pscreen = ptx->texture->screen; - nv50_transfer_rect_m2mf(pscreen, tx->buffer, 0, tx->base.stride, + nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride, 0, 0, tx->base.width, tx->base.height, - mt->buffer, tx->level_offset, + mt->bo, tx->level_offset, tx->level_pitch, tx->level_x, tx->level_y, tx->level_width, tx->level_height, tx->base.block.size, @@ -175,7 +178,7 @@ nv50_transfer_del(struct pipe_transfer *ptx) NOUVEAU_BO_GART); } - pipe_buffer_reference(&tx->buffer, NULL); + nouveau_bo_ref(NULL, &tx->bo); pipe_texture_reference(&ptx->texture, NULL); FREE(ptx); } @@ -185,13 +188,17 @@ nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) { struct nv50_transfer *tx = (struct nv50_transfer *)ptx; unsigned flags = 0; + int ret; if (ptx->usage & PIPE_TRANSFER_WRITE) - flags |= PIPE_BUFFER_USAGE_CPU_WRITE; + flags |= NOUVEAU_BO_WR; if (ptx->usage & PIPE_TRANSFER_READ) - flags |= PIPE_BUFFER_USAGE_CPU_READ; + flags |= NOUVEAU_BO_RD; - return pipe_buffer_map(pscreen, tx->buffer, flags); + ret = nouveau_bo_map(tx->bo, flags); + if (ret) + return NULL; + return tx->bo->map; } static void @@ -199,7 +206,7 @@ nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) { struct nv50_transfer *tx = (struct nv50_transfer *)ptx; - pipe_buffer_unmap(pscreen, tx->buffer); + nouveau_bo_unmap(tx->bo); } void -- cgit v1.2.3 From a471497345bcd3aaaa52d3dc73f68367cb4af6a0 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 20:45:58 +1000 Subject: nv50: use nouveau_bo for query buffers --- src/gallium/drivers/nv50/nv50_query.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index f57540150a..940e04365f 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -26,7 +26,7 @@ #include "nv50_context.h" struct nv50_query { - struct pipe_buffer *buffer; + struct nouveau_bo *bo; unsigned type; boolean ready; uint64_t result; @@ -41,14 +41,16 @@ nv50_query(struct pipe_query *pipe) static struct pipe_query * nv50_query_create(struct pipe_context *pipe, unsigned type) { - struct pipe_screen *screen = pipe->screen; + struct nouveau_device *dev = nouveau_screen(pipe->screen)->device; struct nv50_query *q = CALLOC_STRUCT(nv50_query); + int ret; assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER); q->type = type; - q->buffer = screen->buffer_create(screen, 256, 0, 16); - if (!q->buffer) { + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 256, + 16, &q->bo); + if (ret) { FREE(q); return NULL; } @@ -62,7 +64,7 @@ nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) struct nv50_query *q = nv50_query(pq); if (q) { - pipe_buffer_reference(&q->buffer, NULL); + nouveau_bo_ref(NULL, &q->bo); FREE(q); } } @@ -90,12 +92,11 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); - struct nouveau_bo *bo = nouveau_bo(q->buffer); WAIT_RING (chan, 5); BEGIN_RING(chan, tesla, 0x1b00, 4); - OUT_RELOCh(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); OUT_RING (chan, 0x00000000); OUT_RING (chan, 0x0100f002); FIRE_RING (chan); @@ -105,7 +106,6 @@ static boolean nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, boolean wait, uint64_t *result) { - struct pipe_screen *pscreen = pipe->screen; struct nv50_query *q = nv50_query(pq); /*XXX: Want to be able to return FALSE here instead of blocking @@ -113,11 +113,10 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, */ if (!q->ready) { - uint32_t *map = pipe_buffer_map(pscreen, q->buffer, - PIPE_BUFFER_USAGE_CPU_READ); - q->result = map[1]; + nouveau_bo_map(q->bo, NOUVEAU_BO_RD); + q->result = ((uint32_t *)q->bo->map)[1]; q->ready = TRUE; - pipe_buffer_unmap(pscreen, q->buffer); + nouveau_bo_unmap(q->bo); } *result = q->result; -- cgit v1.2.3 From d06e380e022d938a61800cbbec0004ec9f1fecfd Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 22:04:07 +1000 Subject: nv50: use larger tile sizes --- src/gallium/drivers/nv50/nv50_miptree.c | 11 +++++++++-- src/gallium/drivers/nv50/nv50_state_validate.c | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index 2fbedb6779..6b605ba416 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -34,7 +34,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) struct pipe_texture *pt = &mt->base; unsigned width = tmp->width[0], height = tmp->height[0]; unsigned depth = tmp->depth[0]; - uint32_t tile_mode = 0, tile_flags = 0; + uint32_t tile_mode, tile_flags, tile_h; int ret, i, l; mt->base = *tmp; @@ -51,6 +51,13 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) break; } + if (pt->height[0] > 32) tile_mode = 4; + else if (pt->height[0] > 16) tile_mode = 3; + else if (pt->height[0] > 8) tile_mode = 2; + else if (pt->height[0] > 4) tile_mode = 1; + else tile_mode = 0; + tile_h = 1 << (tile_mode + 2); + switch (pt->target) { case PIPE_TEXTURE_3D: mt->image_nr = pt->depth[0]; @@ -87,7 +94,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) size = align(pt->width[l], 8) * pt->block.size; size = align(size, 64); - size *= align(pt->height[l], 8) * pt->block.size; + size *= align(pt->height[l], tile_h) * pt->block.size; lvl->image_offset[i] = mt->total_size; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 1788f76456..a0106fc339 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -66,7 +66,7 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_data(so, 0xe6); break; } - so_data(so, 0x00000000); + so_data(so, bo->tile_mode << 4); so_data(so, 0x00000000); so_method(so, tesla, 0x1224, 1); @@ -104,7 +104,7 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_data(so, 0x16); break; } - so_data(so, 0x00000000); + so_data(so, bo->tile_mode << 4); so_data(so, 0x00000000); so_method(so, tesla, 0x1538, 1); -- cgit v1.2.3 From 9e4590dff72b8739e787da7f0d86c7066f179186 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 5 Jun 2009 10:18:20 -0700 Subject: r300-gallium: Improve vs emit. --- src/gallium/drivers/r300/r300_emit.c | 20 ++++++++++++-------- src/gallium/drivers/r300/r300_reg.h | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 61b416663b..4a70f3afde 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -372,17 +372,22 @@ void r300_emit_vertex_shader(struct r300_context* r300, } if (constants->count) { - BEGIN_CS(16 + (vs->instruction_count * 4) + (constants->count * 4)); + BEGIN_CS(14 + (vs->instruction_count * 4) + (constants->count * 4)); } else { - BEGIN_CS(13 + (vs->instruction_count * 4)); + BEGIN_CS(11 + (vs->instruction_count * 4)); } - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) | + /* R300_VAP_PVS_CODE_CNTL_0 + * R300_VAP_PVS_CONST_CNTL + * R300_VAP_PVS_CODE_CNTL_1 + * See the r5xx docs for instructions on how to use these. + * XXX these could be optimized to select better values... */ + OUT_CS_REG_SEQ(R300_VAP_PVS_CODE_CNTL_0, 3); + OUT_CS(R300_PVS_FIRST_INST(0) | + R300_PVS_XYZW_VALID_INST(vs->instruction_count - 1) | R300_PVS_LAST_INST(vs->instruction_count - 1)); - OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, vs->instruction_count - 1); - - /* XXX */ - OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x0); + OUT_CS(R300_PVS_MAX_CONST_ADDR(constants->count - 1)); + OUT_CS(vs->instruction_count - 1); OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, vs->instruction_count * 4); @@ -412,7 +417,6 @@ void r300_emit_vertex_shader(struct r300_context* r300, R300_PVS_VF_MAX_VTX_NUM(12)); OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); END_CS; - } void r300_emit_viewport_state(struct r300_context* r300, diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 920584a59e..3bb9bc47b5 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -511,11 +511,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_PVS_XYZW_VALID_INST_SHIFT 10 # define R300_PVS_LAST_INST_SHIFT 20 # define R300_PVS_FIRST_INST(x) ((x) << 0) +# define R300_PVS_XYZW_VALID_INST(x) ((x) << 10) # define R300_PVS_LAST_INST(x) ((x) << 20) /* Addresses are relative the the vertex program parameters area. */ #define R300_VAP_PVS_CONST_CNTL 0x22D4 # define R300_PVS_CONST_BASE_OFFSET_SHIFT 0 # define R300_PVS_MAX_CONST_ADDR_SHIFT 16 +# define R300_PVS_MAX_CONST_ADDR(x) ((x) << 16) #define R300_VAP_PVS_CODE_CNTL_1 0x22D8 # define R300_PVS_LAST_VTX_SRC_INST_SHIFT 0 #define R300_VAP_PVS_FLOW_CNTL_OPC 0x22DC -- cgit v1.2.3 From 1a359d983512b39783ce9f4eb842d3ea4ec012a6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 5 Jun 2009 11:21:09 -0700 Subject: r300-gallium: Emit UCP. --- src/gallium/drivers/r300/r300_context.h | 37 ++++++++++++++++++--------------- src/gallium/drivers/r300/r300_emit.c | 26 +++++++++++++++++++++++ src/gallium/drivers/r300/r300_emit.h | 3 +++ src/gallium/drivers/r300/r300_state.c | 7 ++++--- 4 files changed, 53 insertions(+), 20 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index a9dd041e08..27bc7fd1a9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -117,23 +117,24 @@ struct r300_viewport_state { uint32_t vte_control; /* R300_VAP_VTE_CNTL: 0x20b0 */ }; -#define R300_NEW_BLEND 0x0000001 -#define R300_NEW_BLEND_COLOR 0x0000002 -#define R300_NEW_CONSTANTS 0x0000004 -#define R300_NEW_DSA 0x0000008 -#define R300_NEW_FRAMEBUFFERS 0x0000010 -#define R300_NEW_FRAGMENT_SHADER 0x0000020 -#define R300_NEW_RASTERIZER 0x0000040 -#define R300_NEW_RS_BLOCK 0x0000080 -#define R300_NEW_SAMPLER 0x0000100 -#define R300_ANY_NEW_SAMPLERS 0x000ff00 -#define R300_NEW_SCISSOR 0x0010000 -#define R300_NEW_TEXTURE 0x0020000 -#define R300_ANY_NEW_TEXTURES 0x1fe0000 -#define R300_NEW_VERTEX_FORMAT 0x2000000 -#define R300_NEW_VERTEX_SHADER 0x4000000 -#define R300_NEW_VIEWPORT 0x8000000 -#define R300_NEW_KITCHEN_SINK 0xfffffff +#define R300_NEW_BLEND 0x00000001 +#define R300_NEW_BLEND_COLOR 0x00000002 +#define R300_NEW_CLIP 0x00000004 +#define R300_NEW_CONSTANTS 0x00000008 +#define R300_NEW_DSA 0x00000010 +#define R300_NEW_FRAMEBUFFERS 0x00000020 +#define R300_NEW_FRAGMENT_SHADER 0x00000040 +#define R300_NEW_RASTERIZER 0x00000080 +#define R300_NEW_RS_BLOCK 0x00000100 +#define R300_NEW_SAMPLER 0x00000200 +#define R300_ANY_NEW_SAMPLERS 0x0001fe00 +#define R300_NEW_SCISSOR 0x00020000 +#define R300_NEW_TEXTURE 0x00040000 +#define R300_ANY_NEW_TEXTURES 0x03fc0000 +#define R300_NEW_VERTEX_FORMAT 0x04000000 +#define R300_NEW_VERTEX_SHADER 0x08000000 +#define R300_NEW_VIEWPORT 0x10000000 +#define R300_NEW_KITCHEN_SINK 0x1fffffff /* The next several objects are not pure Radeon state; they inherit from * various Gallium classes. */ @@ -292,6 +293,8 @@ struct r300_context { struct r300_blend_state* blend_state; /* Blend color state. */ struct r300_blend_color_state* blend_color_state; + /* User clip planes. */ + struct pipe_clip_state clip_state; /* Shader constants. */ struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES]; /* Depth, stencil, and alpha state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 4a70f3afde..4c7370eee7 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -56,6 +56,27 @@ void r300_emit_blend_color_state(struct r300_context* r300, } } +void r300_emit_clip_state(struct r300_context* r300, + struct pipe_clip_state* clip) +{ + int i; + struct r300_screen* r300screen = r300_screen(r300->context.screen); + CS_LOCALS(r300); + + BEGIN_CS(3 + (6 * 4)); + OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, + (r300screen->caps->is_r500 ? + R500_PVS_UCP_START : R300_PVS_UCP_START)); + OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4); + for (i = 0; i < 6; i++) { + OUT_CS_32F(clip->ucp[i][0]); + OUT_CS_32F(clip->ucp[i][1]); + OUT_CS_32F(clip->ucp[i][2]); + OUT_CS_32F(clip->ucp[i][3]); + } + END_CS; +} + void r300_emit_dsa_state(struct r300_context* r300, struct r300_dsa_state* dsa) { @@ -527,6 +548,11 @@ validate: r300->dirty_state &= ~R300_NEW_BLEND_COLOR; } + if (r300->dirty_state & R300_NEW_CLIP) { + r300_emit_clip_state(r300, &r300->clip_state); + r300->dirty_state &= ~R300_NEW_CLIP; + } + if (r300->dirty_state & R300_NEW_DSA) { r300_emit_dsa_state(r300, r300->dsa_state); r300->dirty_state &= ~R300_NEW_DSA; diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 36e14f69f7..946f625bd8 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -36,6 +36,9 @@ void r300_emit_blend_state(struct r300_context* r300, void r300_emit_blend_color_state(struct r300_context* r300, struct r300_blend_color_state* bc); +void r300_emit_clip_state(struct r300_context* r300, + struct pipe_clip_state* clip); + void r300_emit_dsa_state(struct r300_context* r300, struct r300_dsa_state* dsa); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 0461ffd681..29e721984f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -119,9 +119,10 @@ static void r300_set_clip_state(struct pipe_context* pipe, const struct pipe_clip_state* state) { struct r300_context* r300 = r300_context(pipe); - /* XXX add HW TCL clipping setup */ - draw_flush(r300->draw); - draw_set_clip_state(r300->draw, state); + + r300->clip_state = *state; + + r300->dirty_state |= R300_NEW_CLIP; } static void -- cgit v1.2.3 From b7aa5b1d10cbe2fd0b796538426f1f2910a4832c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 5 Jun 2009 13:46:59 -0700 Subject: r300-gallium: Use VAP_CLIP_CNTL. Makes tri-userclip work with HW TCL. --- src/gallium/drivers/r300/r300_emit.c | 5 ++++- src/gallium/drivers/r300/r300_state_invariant.c | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 4c7370eee7..d81abe4d0b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -63,7 +63,7 @@ void r300_emit_clip_state(struct r300_context* r300, struct r300_screen* r300screen = r300_screen(r300->context.screen); CS_LOCALS(r300); - BEGIN_CS(3 + (6 * 4)); + BEGIN_CS(5 + (6 * 4)); OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300screen->caps->is_r500 ? R500_PVS_UCP_START : R300_PVS_UCP_START)); @@ -74,6 +74,9 @@ void r300_emit_clip_state(struct r300_context* r300, OUT_CS_32F(clip->ucp[i][2]); OUT_CS_32F(clip->ucp[i][3]); } + + OUT_CS_REG(R300_VAP_CLIP_CNTL, ((1 << clip->nr) - 1) | + R300_PS_UCP_MODE_CLIP_AS_TRIFAN); END_CS; } diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 9dde662802..60eff08f2e 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -69,7 +69,7 @@ void r300_emit_invariant_state(struct r300_context* r300) END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(77 + (caps->has_tcl ? 7 : 0)); + BEGIN_CS(75 + (caps->has_tcl ? 7 : 0)); /* Flush PVS. */ OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); @@ -80,8 +80,6 @@ void r300_emit_invariant_state(struct r300_context* r300) /* XXX endian */ if (caps->has_tcl) { OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP); - OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE | - R300_PS_UCP_MODE_CLIP_AS_TRIFAN); OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4); OUT_CS_32F(1.0); OUT_CS_32F(1.0); -- cgit v1.2.3 From 6c1627a51c237428a79613fcda1412c4660780de Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sat, 6 Jun 2009 10:57:19 +1000 Subject: nv50: support non-normalized texture coords --- src/gallium/drivers/nv50/nv50_context.h | 7 ++++++- src/gallium/drivers/nv50/nv50_state.c | 6 ++++-- src/gallium/drivers/nv50/nv50_state_validate.c | 4 ++-- src/gallium/drivers/nv50/nv50_tex.c | 9 ++++++--- 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index c3ffdcca9f..1a72baf305 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -63,6 +63,11 @@ struct nv50_rasterizer_stateobj { struct nouveau_stateobj *so; }; +struct nv50_sampler_stateobj { + bool normalized; + unsigned tsc[8]; +}; + struct nv50_miptree_level { int *image_offset; unsigned pitch; @@ -141,7 +146,7 @@ struct nv50_context { unsigned vtxbuf_nr; struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; unsigned vtxelt_nr; - unsigned *sampler[PIPE_MAX_SAMPLERS]; + struct nv50_sampler_stateobj *sampler[PIPE_MAX_SAMPLERS]; unsigned sampler_nr; struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS]; unsigned miptree_nr; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 9d41ef55b0..116866a8e7 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -136,7 +136,8 @@ static void * nv50_sampler_state_create(struct pipe_context *pipe, const struct pipe_sampler_state *cso) { - unsigned *tsc = CALLOC(8, sizeof(unsigned)); + struct nv50_sampler_stateobj *sso = CALLOC(1, sizeof(*sso)); + unsigned *tsc = sso->tsc; float limit; tsc[0] = (0x00026000 | @@ -209,7 +210,8 @@ nv50_sampler_state_create(struct pipe_context *pipe, tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) | ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8); - return (void *)tsc; + sso->normalized = cso->normalized_coords; + return (void *)sso; } static void diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index a0106fc339..0caf4b4e91 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -295,12 +295,12 @@ viewport_uptodate: so_data (so, NV50_CB_TSC); so_method(so, tesla, 0x40000f04, nv50->sampler_nr * 8); for (i = 0; i < nv50->sampler_nr; i++) - so_datap (so, nv50->sampler[i], 8); + so_datap (so, nv50->sampler[i]->tsc, 8); so_ref(so, &nv50->state.tsc_upload); so_ref(NULL, &so); } - if (nv50->dirty & NV50_NEW_TEXTURE) + if (nv50->dirty & (NV50_NEW_TEXTURE | NV50_NEW_SAMPLER)) nv50_tex_validate(nv50); if (nv50->dirty & NV50_NEW_ARRAYS) diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 8bb81392fd..8f553f5346 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -27,7 +27,7 @@ static int nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, - struct nv50_miptree *mt) + struct nv50_miptree *mt, int unit) { switch (mt->base.format) { case PIPE_FORMAT_A8R8G8B8_UNORM: @@ -120,7 +120,10 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, so_reloc(so, mt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); - so_data (so, 0xd0005000 | mt->bo->tile_mode << 22); + if (nv50->sampler[unit]->normalized) + so_data (so, 0xd0005000 | mt->bo->tile_mode << 22); + else + so_data (so, 0x5001d000 | mt->bo->tile_mode << 22); so_data (so, 0x00300000); so_data (so, mt->base.width[0]); so_data (so, (mt->base.last_level << 28) | @@ -145,7 +148,7 @@ nv50_tex_validate(struct nv50_context *nv50) for (unit = 0; unit < nv50->miptree_nr; unit++) { struct nv50_miptree *mt = nv50->miptree[unit]; - if (nv50_tex_construct(nv50, so, mt)) { + if (nv50_tex_construct(nv50, so, mt, unit)) { NOUVEAU_ERR("failed tex validate\n"); so_ref(NULL, &so); return; -- cgit v1.2.3 From f1edfa09ea50e8833ddbf241da4d36fd38685e9d Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sat, 6 Jun 2009 14:00:45 +1000 Subject: nv50: fix multi-texturing --- src/gallium/drivers/nv50/nv50_context.h | 1 + src/gallium/drivers/nv50/nv50_screen.c | 2 -- src/gallium/drivers/nv50/nv50_tex.c | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 1a72baf305..9b8cc4d37d 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -114,6 +114,7 @@ struct nv50_state { unsigned viewport_bypass; struct nouveau_stateobj *tsc_upload; struct nouveau_stateobj *tic_upload; + unsigned miptree_nr; struct nouveau_stateobj *vertprog; struct nouveau_stateobj *fragprog; struct nouveau_stateobj *vtxfmt; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 7904b51f77..fd39fa738b 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -404,8 +404,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_method(so, screen->tesla, 0x1234, 1); so_data (so, 1); - so_method(so, screen->tesla, 0x1458, 1); - so_data (so, 1); so_emit(chan, so); so_ref (so, &screen->static_init); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 8f553f5346..ff40c2ad81 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -139,23 +139,35 @@ nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *so; - int unit; + int unit, push; - so = so_new(nv50->miptree_nr * 8 + 3, nv50->miptree_nr * 2); + push = nv50->miptree_nr * 9 + 2; + push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2; + + so = so_new(push, nv50->miptree_nr * 2); so_method(so, tesla, 0x0f00, 1); so_data (so, NV50_CB_TIC); - so_method(so, tesla, 0x40000f04, nv50->miptree_nr * 8); for (unit = 0; unit < nv50->miptree_nr; unit++) { struct nv50_miptree *mt = nv50->miptree[unit]; + so_method(so, tesla, 0x40000f04, 8); if (nv50_tex_construct(nv50, so, mt, unit)) { NOUVEAU_ERR("failed tex validate\n"); so_ref(NULL, &so); return; } + + so_method(so, tesla, 0x1458, 1); + so_data (so, (unit << 9) | (unit << 1) | 1); + } + + for (; unit < nv50->state.miptree_nr; unit++) { + so_method(so, tesla, 0x1458, 1); + so_data (so, (unit << 1) | 0); } so_ref(so, &nv50->state.tic_upload); so_ref(NULL, &so); + nv50->state.miptree_nr = nv50->miptree_nr; } -- cgit v1.2.3