📄 r200_state.c
字号:
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;}static void r200Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ){ /* Don't pipeline viewport changes, conflict with window offset * setting below. Could apply deltas to rescue pipelined viewport * values, or keep the originals hanging around. */ r200UpdateWindow( ctx );}static void r200DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ){ r200UpdateWindow( ctx );}void r200UpdateViewportOffset( GLcontext *ctx ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; GLfloat xoffset = (GLfloat)dPriv->x; GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h; const GLfloat *v = ctx->Viewport._WindowMap.m; 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] != tx.ui32 || rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != ty.ui32 ) { /* Note: this should also modify whatever data the context reset * code uses... */ R200_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; GLuint m = rmesa->hw.msc.cmd[MSC_RE_MISC]; m &= ~(R200_STIPPLE_X_OFFSET_MASK | R200_STIPPLE_Y_OFFSET_MASK); /* add magic offsets, then invert */ stx = 31 - ((rmesa->dri.drawable->x - 1) & R200_STIPPLE_COORD_MASK); sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1) & R200_STIPPLE_COORD_MASK); m |= ((stx << R200_STIPPLE_X_OFFSET_SHIFT) | (sty << R200_STIPPLE_Y_OFFSET_SHIFT)); if ( rmesa->hw.msc.cmd[MSC_RE_MISC] != m ) { R200_STATECHANGE( rmesa, msc ); rmesa->hw.msc.cmd[MSC_RE_MISC] = m; } } } r200UpdateScissor( ctx );}/* ============================================================= * Miscellaneous */static void r200ClearColor( GLcontext *ctx, const GLfloat c[4] ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); GLubyte color[4]; CLAMPED_FLOAT_TO_UBYTE(color[0], c[0]); CLAMPED_FLOAT_TO_UBYTE(color[1], c[1]); CLAMPED_FLOAT_TO_UBYTE(color[2], c[2]); CLAMPED_FLOAT_TO_UBYTE(color[3], c[3]); rmesa->state.color.clear = r200PackColor( rmesa->r200Screen->cpp, color[0], color[1], color[2], color[3] );}static void r200RenderMode( GLcontext *ctx, GLenum mode ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); FALLBACK( rmesa, R200_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );}static GLuint r200_rop_tab[] = { R200_ROP_CLEAR, R200_ROP_AND, R200_ROP_AND_REVERSE, R200_ROP_COPY, R200_ROP_AND_INVERTED, R200_ROP_NOOP, R200_ROP_XOR, R200_ROP_OR, R200_ROP_NOR, R200_ROP_EQUIV, R200_ROP_INVERT, R200_ROP_OR_REVERSE, R200_ROP_COPY_INVERTED, R200_ROP_OR_INVERTED, R200_ROP_NAND, R200_ROP_SET,};static void r200LogicOpCode( GLcontext *ctx, GLenum opcode ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); GLuint rop = (GLuint)opcode - GL_CLEAR; ASSERT( rop < 16 ); R200_STATECHANGE( rmesa, msk ); rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = r200_rop_tab[rop];}/* * Set up the cliprects for either front or back-buffer drawing. */void r200SetCliprects( r200ContextPtr rmesa ){ __DRIdrawablePrivate *const drawable = rmesa->dri.drawable; __DRIdrawablePrivate *const readable = rmesa->dri.readable; GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate; GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate; if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BIT_BACK_LEFT) { /* Can't ignore 2d windows if we are page flipping. */ if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) { rmesa->numClipRects = drawable->numClipRects; rmesa->pClipRects = drawable->pClipRects; } else { rmesa->numClipRects = drawable->numBackClipRects; rmesa->pClipRects = drawable->pBackClipRects; } } else { /* front buffer (or none, or multiple buffers) */ rmesa->numClipRects = drawable->numClipRects; rmesa->pClipRects = drawable->pClipRects; } if ((draw_fb->Width != drawable->w) || (draw_fb->Height != drawable->h)) { _mesa_resize_framebuffer(rmesa->glCtx, draw_fb, drawable->w, drawable->h); draw_fb->Initialized = GL_TRUE; } if (drawable != readable) { if ((read_fb->Width != readable->w) || (read_fb->Height != readable->h)) { _mesa_resize_framebuffer(rmesa->glCtx, read_fb, readable->w, readable->h); read_fb->Initialized = GL_TRUE; } } if (rmesa->state.scissor.enabled) r200RecalcScissorRects( rmesa ); rmesa->lastStamp = drawable->lastStamp;}static void r200DrawBuffer( GLcontext *ctx, GLenum mode ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); if (R200_DEBUG & DEBUG_DRI) fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr( mode )); R200_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */ if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { /* 0 (GL_NONE) buffers or multiple color drawing buffers */ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { case BUFFER_FRONT_LEFT: case BUFFER_BACK_LEFT: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } r200SetCliprects( rmesa ); /* We'll set the drawing engine's offset/pitch parameters later * when we update other state. */}static void r200ReadBuffer( GLcontext *ctx, GLenum mode ){ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */}/* ============================================================= * State enable/disable */static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state ){ r200ContextPtr rmesa = R200_CONTEXT(ctx); GLuint p, flag; if ( R200_DEBUG & DEBUG_STATE ) fprintf( stderr, "%s( %s = %s )\n", __FUNCTION__, _mesa_lookup_enum_by_nr( cap ), state ? "GL_TRUE" : "GL_FALSE" ); switch ( cap ) { /* Fast track this one... */ case GL_TEXTURE_1D: case GL_TEXTURE_2D: case GL_TEXTURE_3D: break; case GL_ALPHA_TEST: R200_STATECHANGE( rmesa, ctx ); if (state) { rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_ALPHA_TEST_ENABLE; } else { rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_ALPHA_TEST_ENABLE; } break; case GL_BLEND: case GL_COLOR_LOGIC_OP: r200_set_blend_state( ctx ); break; case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: case GL_CLIP_PLANE3: case GL_CLIP_PLANE4: case GL_CLIP_PLANE5: p = cap-GL_CLIP_PLANE0; R200_STATECHANGE( rmesa, tcl ); if (state) { rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= (R200_UCP_ENABLE_0<<p); r200ClipPlane( ctx, cap, NULL ); } else { rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~(R200_UCP_ENABLE_0<<p); } break; case GL_COLOR_MATERIAL: r200ColorMaterial( ctx, 0, 0 ); r200UpdateMaterial( ctx ); break; case GL_CULL_FACE: r200CullFace( ctx, 0 ); break; case GL_DEPTH_TEST: R200_STATECHANGE(rmesa, ctx ); if ( state ) { rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_Z_ENABLE; } else { rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_Z_ENABLE; } break; case GL_DITHER: R200_STATECHANGE(rmesa, ctx ); if ( state ) { rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable; } else { rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_DITHER_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable; } break; case GL_FOG: R200_STATECHANGE(rmesa, ctx ); if ( state ) { rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_FOG_ENABLE; r200Fogfv( ctx, GL_FOG_MODE, NULL ); } else { rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_FOG_ENABLE; R200_STATECHANGE(rmesa, tcl); rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_TCL_FOG_MASK; } r200UpdateSpecular( ctx ); /* for PK_SPEC */ if (rmesa->TclFallback) r200ChooseVertexState( ctx ); _mesa_allow_light_in_model( ctx, !state ); break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: R200_STATECHANGE(rmesa, tcl); p = cap - GL_LIGHT0; if (p&1) flag = (R200_LIGHT_1_ENABLE | R200_LIGHT_1_ENABLE_AMBIENT | R200_LIGHT_1_ENABLE_SPECULAR); else flag = (R200_LIGHT_0_ENABLE | R200_LIGHT_0_ENABLE_AMBIENT | R200_LIGHT_0_ENABLE_SPECULAR); if (state) rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] |= flag; else rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] &= ~flag; /* */ update_light_colors( ctx, p ); break; case GL_LIGHTING: r200UpdateSpecular(ctx); /* for reflection map fixup - might set recheck_texgen for all units too */ rmesa->NewGLState |= _NEW_TEXTURE; break; case GL_LINE_SMOOTH: R200_STATECHANGE( rmesa, ctx ); if ( state ) { rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_ANTI_ALIAS_LINE; } else { rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_ANTI_ALIAS_LINE; } break; case GL_LINE_STIPPLE: R200_STATECHANGE( rmesa, set ); if ( state ) { rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PATTERN_ENABLE; } else { rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_PATTERN_ENABLE; } break; case GL_NORMALIZE: R200_STATECHANGE( rmesa, tcl ); if ( state ) { rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_NORMALIZE_NORMALS; } else { rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_NORMALIZE_NORMALS; } break; /* Pointsize registers on r200 only work for point sprites, and point smooth * doesn't work for point sprites (and isn't needed for 1.0 sized aa points). * In any case, setting pointmin == pointsizemax == 1.0 for aa points * is enough to satisfy conform. */ case GL_POINT_SMOOTH: break; /* These don't really do anything, as we don't use the 3vtx * primitives yet. */#if 0 case GL_POLYGON_OFFSET_POINT: R200_STATECHANGE( rmesa, set ); if ( state ) { rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_ZBIAS_ENABLE_POINT; } else { rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_ZBIAS_ENABLE_POINT; } break; case GL_POLYGON_OFFSET_LINE: R200_STATECHANGE( rmesa, set ); if ( state ) { rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_ZBIAS_ENABLE_LINE; } else { rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_ZBIAS_ENABLE_LINE; } break;#endif case GL_POINT_SPRITE_ARB: R200_STATECHANGE( rmesa, spr ); if ( state ) { int i; for (i = 0; i < 6; i++) { rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= ctx->Point.CoordReplace[i] << (R200_PS_GEN_TEX_0_SHIFT + i); } } else { rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= ~R200_PS_GEN_TEX_MASK; } break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -