From 516334b7fff5e0167d3f3fbcd15de08b5ca89747 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:52:06 -0700 Subject: i965: Stop abusing ctx->NewState flags for storing driver internal changes. We're still abusing the flags by putting them where our driver stores ctx->NewState changes. Making them into more restricted state change flags would be a project for later. Fixes a failure where calling intel_draw_buffer() too often would trip up Mesa assertions about when Mesa state could get changed, when it hadn't. Bug #27034. --- src/mesa/drivers/dri/intel/intel_buffers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index b10693050a9..0480770ba1d 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -226,7 +226,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) * only changes with _NEW_STENCIL (which seems sensible). So flag it * here since this is the _NEW_BUFFERS path. */ - ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL); + intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL); } intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, @@ -236,7 +236,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) #ifdef I915 intelCalcViewport(ctx); #else - ctx->NewState |= _NEW_VIEWPORT; + intel->NewGLState |= _NEW_VIEWPORT; #endif /* Set state we know depends on drawable parameters: */ @@ -256,7 +256,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) if (ctx->Driver.FrontFace) ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); else - ctx->NewState |= _NEW_POLYGON; + intel->NewGLState |= _NEW_POLYGON; } -- cgit v1.2.3 From 70929f4505d5cb1b9848a02e8359e9f7a8ef598c Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 11:19:02 +0100 Subject: r300: clean fog_attr/wpos_attr if code accessing these attributes has been removed FP during compilation --- src/mesa/drivers/dri/r300/r300_fragprog_common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index 61ea5e4d9a3..0646da46249 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -256,6 +256,19 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog fp->InputsRead = compiler.Base.Program.InputsRead; + /* Clear the fog/wpos_attr if code accessing these + * attributes has been removed during compilation + */ + if (fp->fog_attr != FRAG_ATTRIB_MAX) { + if (!(fp->InputsRead & (1 << fp->fog_attr))) + fp->fog_attr = FRAG_ATTRIB_MAX; + } + + if (fp->wpos_attr != FRAG_ATTRIB_MAX) { + if (!(fp->InputsRead & (1 << fp->wpos_attr))) + fp->wpos_attr = FRAG_ATTRIB_MAX; + } + rc_destroy(&compiler.Base); } -- cgit v1.2.3 From bed7d88708eba69118fe3805f95b104194872f3a Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 11:34:19 +0100 Subject: r300: fix wpos/fog handling It may happen that the vertex attribute we were going to stuff the wpos/fog attrs in was already written by vertex program. In such cases we need to remove instruction accessing these attributes, so they don't overwrite the wpos/fog related instructions. This fixes non-textured models in many wine games. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 129004fee78..e77cd611f7a 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -263,15 +263,25 @@ static struct r300_vertex_program *build_program(GLcontext *ctx, rc_move_output(&compiler.Base, VERT_RESULT_PSIZ, VERT_RESULT_PSIZ, WRITEMASK_X); if (vp->key.WPosAttr != FRAG_ATTRIB_MAX) { - rc_copy_output(&compiler.Base, - VERT_RESULT_HPOS, - vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0); + unsigned int vp_wpos_attr = vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0; + + /* Set empty writemask for instructions writing to vp_wpos_attr + * before moving the wpos attr there. + * Such instructions will be removed by DCE. + */ + rc_move_output(&compiler.Base, vp_wpos_attr, vp->key.WPosAttr, 0); + rc_copy_output(&compiler.Base, VERT_RESULT_HPOS, vp_wpos_attr); } if (vp->key.FogAttr != FRAG_ATTRIB_MAX) { - rc_move_output(&compiler.Base, - VERT_RESULT_FOGC, - vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0, WRITEMASK_X); + unsigned int vp_fog_attr = vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0; + + /* Set empty writemask for instructions writing to vp_fog_attr + * before moving the fog attr there. + * Such instructions will be removed by DCE. + */ + rc_move_output(&compiler.Base, vp_fog_attr, vp->key.FogAttr, 0); + rc_move_output(&compiler.Base, VERT_RESULT_FOGC, vp_fog_attr, WRITEMASK_X); } r3xx_compile_vertex_program(&compiler); -- cgit v1.2.3 From 7a77effb0b7eeefd5eb350aa9a487e10f62eb7ed Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:10:06 +0100 Subject: r300: fix vertex programs with big number of params (>255) under KMS UMS will probably require some kernel work --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 40 ++++++++++++++++++++++++++----- src/mesa/drivers/dri/r300/r300_vertprog.c | 6 ++++- 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 6cfa5686f4a..8eb596d1c5a 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -83,6 +83,23 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom) return cnt ? (cnt * 4) + extra : 0; } +static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom) +{ + r300ContextPtr r300 = R300_CONTEXT(ctx); + int cnt; + int extra = 1; + + if (r300->radeon.radeonScreen->kernel_mm) { + cnt = r300->selected_vp->code.constants.Count * 4; + extra = 5; + } else { + cnt = vpu_count(atom->cmd); + extra = 1; + } + + return cnt ? (cnt * 4) + extra : 0; +} + void r300_emit_vpu(struct r300_context *r300, uint32_t *data, unsigned len, @@ -101,15 +118,26 @@ static void emit_vpu_state(GLcontext *ctx, struct radeon_state_atom * atom) { r300ContextPtr r300 = R300_CONTEXT(ctx); drm_r300_cmd_header_t cmd; - uint32_t addr, ndw; + uint32_t addr; cmd.u = atom->cmd[0]; addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo; - ndw = atom->check(ctx, atom); r300_emit_vpu(r300, &atom->cmd[1], vpu_count(atom->cmd) * 4, addr); } +static void emit_vpp_state(GLcontext *ctx, struct radeon_state_atom * atom) +{ + r300ContextPtr r300 = R300_CONTEXT(ctx); + drm_r300_cmd_header_t cmd; + uint32_t addr; + + cmd.u = atom->cmd[0]; + addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo; + + r300_emit_vpu(r300, &atom->cmd[1], r300->selected_vp->code.constants.Count * 4, addr); +} + void r500_emit_fp(struct r300_context *r300, uint32_t *data, unsigned len, @@ -784,11 +812,11 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.vpi.emit = emit_vpu_state; if (is_r500) { - ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0); + ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0); r300->hw.vpp.cmd[0] = cmdvpu(r300->radeon.radeonScreen, R500_PVS_CONST_START, 0); if (r300->radeon.radeonScreen->kernel_mm) - r300->hw.vpp.emit = emit_vpu_state; + r300->hw.vpp.emit = emit_vpp_state; ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0); r300->hw.vps.cmd[0] = @@ -805,11 +833,11 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.vpucp[i].emit = emit_vpu_state; } } else { - ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0); + ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0); r300->hw.vpp.cmd[0] = cmdvpu(r300->radeon.radeonScreen, R300_PVS_CONST_START, 0); if (r300->radeon.radeonScreen->kernel_mm) - r300->hw.vpp.emit = emit_vpu_state; + r300->hw.vpp.emit = emit_vpp_state; ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0); r300->hw.vps.cmd[0] = diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index e77cd611f7a..53fe948ab98 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -392,7 +392,11 @@ void r300SetupVertexProgram(r300ContextPtr rmesa) R300_STATECHANGE(rmesa, vap_cntl); R300_STATECHANGE(rmesa, vpp); param_count = r300VertexProgUpdateParams(ctx, prog, (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]); - bump_vpu_count(rmesa->hw.vpp.cmd, param_count); + if (!rmesa->radeon.radeonScreen->kernel_mm && param_count > 255 * 4) { + WARN_ONCE("Too many VP params, expect rendering errors\n"); + } + /* Prevent the overflow (vpu.count is u8) */ + bump_vpu_count(rmesa->hw.vpp.cmd, MIN2(255 * 4, param_count)); param_count /= 4; r300EmitVertexProgram(rmesa, R300_PVS_CODE_START, &(prog->code)); -- cgit v1.2.3 From 88f785935e43701a1ac56dae3952a915a9dd201b Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:12:05 +0100 Subject: r300: fix off by one R300_PVS_MAX_CONST_ADDR field holds highest const addr, not const count. Fixes missing models and others rendering errors for vertex program using 256 params. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 53fe948ab98..a1fe3780294 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -409,6 +409,6 @@ void r300SetupVertexProgram(r300ContextPtr rmesa) rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = (0 << R300_PVS_FIRST_INST_SHIFT) | (inst_count << R300_PVS_XYZW_VALID_INST_SHIFT) | (inst_count << R300_PVS_LAST_INST_SHIFT); - rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT); + rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | ((param_count - 1) << R300_PVS_MAX_CONST_ADDR_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT); } -- cgit v1.2.3 From fabc744999bf282e80baf44c45c58cab8a67d604 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:43:38 +0100 Subject: r300: report correct state atom size Spotted by Pauli Nieminen --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 8eb596d1c5a..788dc2f16e9 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -77,7 +77,7 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom) cnt = vpu_count(atom->cmd); if (r300->radeon.radeonScreen->kernel_mm) { - extra = 5; + extra = 3; } return cnt ? (cnt * 4) + extra : 0; @@ -91,7 +91,7 @@ static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom) if (r300->radeon.radeonScreen->kernel_mm) { cnt = r300->selected_vp->code.constants.Count * 4; - extra = 5; + extra = 3; } else { cnt = vpu_count(atom->cmd); extra = 1; -- cgit v1.2.3 From 80f5f7d17afac7b4cbaaad27a43dbf902ca3826e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Mar 2010 12:58:36 -0700 Subject: glslcompiler: Fix build. --- src/mesa/drivers/glslcompiler/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index d3404988d52..7dcf9a6541a 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -9,13 +9,9 @@ PROGRAM = glslcompiler OBJECTS = \ glslcompiler.o \ - ../../glapi/glapi.o \ - ../../glapi/glapi_getproc.o \ - ../../glapi/glapi_dispatch.o \ - ../../glapi/glapi_nop.o \ - ../../glapi/glthread.o \ ../common/driverfuncs.o \ - ../../libmesa.a + ../../libmesa.a \ + ../../libglapi.a INCLUDES = \ -I$(TOP)/include \ -- cgit v1.2.3 From 59258498dc6fa51573b176d071644bd3e750b5ac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Mar 2010 16:03:13 -0600 Subject: glapi: return int = 0 from NoOpGeneric() If a GL function is called w/out a current rendering context, this stub gets called. It should return 0 so that non-void-valued functions return 0/NULL instead of a random number. --- src/mesa/glapi/glapi_nop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c index b1a718a5f0a..df9c5872842 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mesa/glapi/glapi_nop.c @@ -93,7 +93,7 @@ NoOpUnused(void) #else -static void +static int NoOpGeneric(void) { #if !defined(_WIN32_WCE) @@ -101,6 +101,7 @@ NoOpGeneric(void) fprintf(stderr, "GL User Error: calling GL function without a rendering context\n"); } #endif + return 0; } #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric -- cgit v1.2.3