From 08e62a147618ac796f5e548bdaa3380342ec2a78 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 28 Mar 2006 17:22:57 +0000 Subject: fix missing *_STATECHANGE in *UpdateViewportOffset for radeon, r200 and r300 (reported by Jim Duchek). Fix some potential problems with strict-aliasing with r200 and radeon drivers in *UpdateViewportOffset, *PolygonOffset and *UpdateWindow functions (some compiler warnings about strict-aliasing remain in the codegen vertex code, and there may be more problems unnoticed by the compiler). --- src/mesa/drivers/dri/radeon/radeon_state.c | 50 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/mesa/drivers/dri/radeon/radeon_state.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 89250673cb..447619b56d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -624,11 +624,12 @@ static void radeonPolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units ) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLfloat constant = units * rmesa->state.depth.scale; + float_ui32_type constant = { units * rmesa->state.depth.scale }; + float_ui32_type factoru = { factor }; RADEON_STATECHANGE( rmesa, zbs ); - rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_FACTOR] = *(GLuint *)&factor; - rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = *(GLuint *)&constant; + rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_FACTOR] = factoru.ui32; + rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = constant.ui32; } static void radeonPolygonStipple( GLcontext *ctx, const GLubyte *mask ) @@ -1486,21 +1487,22 @@ void radeonUpdateWindow( GLcontext *ctx ) GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h; const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat sx = v[MAT_SX]; - GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X; - GLfloat sy = - v[MAT_SY]; - GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y; - GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale; - GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale; + float_ui32_type sx = { v[MAT_SX] }; + float_ui32_type tx = { v[MAT_TX] + xoffset + SUBPIXEL_X }; + float_ui32_type sy = { - v[MAT_SY] }; + float_ui32_type ty = { (- v[MAT_TY]) + yoffset + SUBPIXEL_Y }; + float_ui32_type sz = { v[MAT_SZ] * rmesa->state.depth.scale }; + float_ui32_type tz = { v[MAT_TZ] * rmesa->state.depth.scale }; + RADEON_FIREVERTICES( rmesa ); RADEON_STATECHANGE( rmesa, vpt ); - rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = *(GLuint *)&sx; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = *(GLuint *)&sy; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = *(GLuint *)&sz; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = *(GLuint *)&tz; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = sx.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = tx.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = sy.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = ty.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = sz.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = tz.ui32; } @@ -1528,18 +1530,22 @@ void radeonUpdateViewportOffset( GLcontext *ctx ) GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h; const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X; - GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y; + float_ui32_type tx; + float_ui32_type ty; + + tx.f = v[MAT_TX] + xoffset + SUBPIXEL_X; + ty.f = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y; - if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != *(GLuint *)&tx || - rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != *(GLuint *)&ty ) + if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != tx.ui32 || + rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != ty.ui32 ) { /* Note: this should also modify whatever data the context reset * code uses... */ - rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx; - rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty; - + RADEON_STATECHANGE( rmesa, vpt ); + rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = tx.ui32; + rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = ty.ui32; + /* update polygon stipple x/y screen offset */ { GLuint stx, sty; -- cgit v1.2.3