/* ============================================================= * Hardware clipping */ static void i830Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { i830ContextPtr i830 = I830_CONTEXT(ctx); intelScreenPrivate *screen = i830->intel.intelScreen; int x1, y1, x2, y2; if (!i830->intel.driDrawable) return; x1 = x; y1 = i830->intel.driDrawable->h - (y + h); x2 = x + w - 1; y2 = y1 + h - 1; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__, x, y, w, h); if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0; if (x2 < 0) x2 = 0; if (y2 < 0) y2 = 0; if (x2 >= screen->width) x2 = screen->width-1; if (y2 >= screen->height) y2 = screen->height-1; if (x1 >= screen->width) x1 = screen->width-1; if (y1 >= screen->height) y1 = screen->height-1; I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); i830->state.Buffer[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff); i830->state.Buffer[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff); }
static void i830StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask) { i830ContextPtr i830 = I830_CONTEXT(ctx); int test = intel_translate_compare_func(func); mask = mask & 0xff; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__, _mesa_lookup_enum_by_nr(func), ref, mask); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(mask)); i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK | ENABLE_STENCIL_TEST_FUNC_MASK); i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE | ENABLE_STENCIL_TEST_FUNC | STENCIL_REF_VALUE(ref) | STENCIL_TEST_FUNC(test)); }
/* Move locking out to get reasonable span performance. */ void i830SpanRenderStart( GLcontext *ctx ) { i830ContextPtr imesa = I830_CONTEXT(ctx); I830_FIREVERTICES(imesa); LOCK_HARDWARE(imesa); i830RegetLockQuiescent( imesa ); }
static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused) { i830ContextPtr i830 = I830_CONTEXT(ctx); GLuint mode; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); if (!ctx->Polygon.CullFlag) { mode = CULLMODE_NONE; } else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) { mode = CULLMODE_CW; if (ctx->Polygon.CullFaceMode == GL_FRONT) mode ^= (CULLMODE_CW ^ CULLMODE_CCW); if (ctx->Polygon.FrontFace != GL_CCW) mode ^= (CULLMODE_CW ^ CULLMODE_CCW); } else { mode = CULLMODE_BOTH; } I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK; i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode; }
void i830_emit_contiguous_verts( GLcontext *ctx, GLuint start, GLuint count ) { i830ContextPtr imesa = I830_CONTEXT(ctx); GLuint vertex_size = imesa->vertex_size * 4; GLuint *dest = i830AllocDmaLow( imesa, (count-start) * vertex_size); setup_tab[imesa->SetupIndex].emit( ctx, start, count, dest, vertex_size ); }
static void i830LogicOp(GLcontext *ctx, GLenum opcode) { i830ContextPtr i830 = I830_CONTEXT(ctx); int tmp = intel_translate_logic_op( opcode ); if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~LOGICOP_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp); }
static void update_specular( GLcontext *ctx ) { i830ContextPtr i830 = I830_CONTEXT( ctx ); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; if (NEED_SECONDARY_COLOR(ctx)) i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD; else i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD; }
static void i830DepthFunc(GLcontext *ctx, GLenum func) { i830ContextPtr i830 = I830_CONTEXT(ctx); int test = intel_translate_compare_func(func); if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK; i830->state.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC | DEPTH_TEST_FUNC(test)); }
void i830BuildVertices( GLcontext *ctx, GLuint start, GLuint count, GLuint newinputs ) { i830ContextPtr imesa = I830_CONTEXT( ctx ); GLubyte *v = ((GLubyte *) imesa->verts + (start<<imesa->vertex_stride_shift)); GLuint stride = 1<<imesa->vertex_stride_shift; if (0) fprintf(stderr, "%s\n", __FUNCTION__); newinputs |= imesa->SetupNewInputs; imesa->SetupNewInputs = 0; if (!newinputs) return; if (newinputs & VERT_CLIP) { setup_tab[imesa->SetupIndex].emit( ctx, start, count, v, stride ); } else { GLuint ind = 0; if (newinputs & VERT_RGBA) ind |= I830_RGBA_BIT; if (newinputs & VERT_SPEC_RGB) ind |= I830_SPEC_BIT; if (newinputs & VERT_TEX0) ind |= I830_TEX0_BIT; if (newinputs & VERT_TEX1) ind |= I830_TEX1_BIT; if (newinputs & VERT_FOG_COORD) ind |= I830_FOG_BIT; #if 0 if (imesa->SetupIndex & I830_PTEX_BIT) ind = ~0; #endif ind &= imesa->SetupIndex; if (ind) { setup_tab[ind].emit( ctx, start, count, v, stride ); } } }
static void i830PointSize(GLcontext *ctx, GLfloat size) { i830ContextPtr i830 = I830_CONTEXT(ctx); GLint point_size = (int)size; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); CLAMP_SELF(point_size, 1, 256); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK; i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH | FIXED_POINT_WIDTH(point_size)); }
void i830InitVB( GLcontext *ctx ) { i830ContextPtr imesa = I830_CONTEXT(ctx); GLuint size = TNL_CONTEXT(ctx)->vb.Size; imesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32); { static int firsttime = 1; if (firsttime) { init_setup_tab(); firsttime = 0; } } }
/* Determine the rasterized primitive when not drawing unfilled * polygons. * * Used only for the default render stage which always decomposes * primitives to trianges/lines/points. For the accelerated stage, * which renders strips as strips, the equivalent calculations are * performed in i810render.c. */ static void i830RenderPrimitive( GLcontext *ctx, GLenum prim ) { i830ContextPtr imesa = I830_CONTEXT(ctx); GLuint rprim = reduced_prim[prim]; imesa->render_primitive = prim; if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) return; if (imesa->reduced_primitive != rprim || hw_prim[prim] != imesa->hw_primitive) { i830RasterPrimitive( ctx, rprim, hw_prim[prim] ); } }
static void i830StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask) { i830ContextPtr i830 = I830_CONTEXT(ctx); if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask); mask = mask & 0xff; I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(mask)); }
/* ============================================================= * Fog */ static void i830Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) { i830ContextPtr i830 = I830_CONTEXT(ctx); if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); if (pname == GL_FOG_COLOR) { GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) | ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) | ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0)); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD | color); } }
static void i830BlendColor(GLcontext *ctx, const GLfloat color[4]) { i830ContextPtr i830 = I830_CONTEXT(ctx); GLubyte r, g, b, a; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(g, color[GCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(b, color[BCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b; }
static void i830DepthMask(GLcontext *ctx, GLboolean flag) { i830ContextPtr i830 = I830_CONTEXT(ctx); if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK; if (flag && ctx->Depth.Test) i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE; else i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE; }
/* ============================================================= * Polygon stipple * * The i830 supports a 4x4 stipple natively, GL wants 32x32. * Fortunately stipple is usually a repeating pattern. */ static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask ) { i830ContextPtr i830 = I830_CONTEXT(ctx); const GLubyte *m = mask; GLubyte p[4]; int i,j,k; int active = (ctx->Polygon.StippleFlag && i830->intel.reduced_primitive == GL_TRIANGLES); GLuint newMask; if (active) { I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; } p[0] = mask[12] & 0xf; p[0] |= p[0] << 4; p[1] = mask[8] & 0xf; p[1] |= p[1] << 4; p[2] = mask[4] & 0xf; p[2] |= p[2] << 4; p[3] = mask[0] & 0xf; p[3] |= p[3] << 4; for (k = 0 ; k < 8 ; k++) for (j = 3 ; j >= 0; j--) for (i = 0 ; i < 4 ; i++, m++) if (*m != p[j]) { i830->intel.hw_stipple = 0; return; } newMask = (((p[0] & 0xf) << 0) | ((p[1] & 0xf) << 4) | ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12)); if (newMask == 0xffff || newMask == 0x0) { /* this is needed to make conform pass */ i830->intel.hw_stipple = 0; return; } i830->state.Stipple[I830_STPREG_ST1] &= ~0xffff; i830->state.Stipple[I830_STPREG_ST1] |= newMask; i830->intel.hw_stipple = 1; if (active) i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE; }
static void i830FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ) { i830ContextPtr imesa = I830_CONTEXT( ctx ); GLuint vertsize = imesa->vertex_size; GLuint *vb = i830AllocDmaLow( imesa, (n-2) * 3 * 4 * vertsize ); GLubyte *vertptr = (GLubyte *)imesa->verts; const GLuint vertshift = imesa->vertex_stride_shift; const GLuint *start = (const GLuint *)V(elts[0]); int i,j; for (i = 2 ; i < n ; i++) { COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) ); COPY_DWORDS( j, vb, vertsize, V(elts[i]) ); COPY_DWORDS( j, vb, vertsize, start ); } }
static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) { i830ContextPtr i830 = I830_CONTEXT(ctx); int test = intel_translate_compare_func(func); GLubyte refByte; GLuint refInt; UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref); refInt = (GLuint)refByte; I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE2] &= ~ALPHA_TEST_REF_MASK; i830->state.Ctx[I830_CTXREG_STATE2] |= (ENABLE_ALPHA_TEST_FUNC | ENABLE_ALPHA_REF_VALUE | ALPHA_TEST_FUNC(test) | ALPHA_REF_VALUE(refInt)); }
void i830CheckTexSizes( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); i830ContextPtr imesa = I830_CONTEXT( ctx ); if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) { int ind = imesa->SetupIndex |= I830_PTEX_BIT; if(setup_tab[ind].vertex_format != imesa->vertex_format) { int vfmt = setup_tab[ind].vertex_format; I830_STATECHANGE(imesa, I830_UPLOAD_CTX); imesa->Setup[I830_CTXREG_VF] = ~(1<<31) & vfmt; if (vfmt & (1<<31)) { /* Proj texturing */ imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD | VRTX_TEX_SET_0_FMT(TEXCOORDFMT_3D) | VRTX_TEX_SET_1_FMT(TEXCOORDFMT_3D) | VRTX_TEX_SET_2_FMT(TEXCOORDFMT_3D) | VRTX_TEX_SET_3_FMT(TEXCOORDFMT_3D)); i830UpdateTexUnitProj( ctx, 0, GL_TRUE ); i830UpdateTexUnitProj( ctx, 1, GL_TRUE ); } else { /* Normal texturing */ imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD | VRTX_TEX_SET_0_FMT(TEXCOORDFMT_2D) | VRTX_TEX_SET_1_FMT(TEXCOORDFMT_2D) | VRTX_TEX_SET_2_FMT(TEXCOORDFMT_2D) | VRTX_TEX_SET_3_FMT(TEXCOORDFMT_2D)); i830UpdateTexUnitProj( ctx, 0, GL_FALSE ); i830UpdateTexUnitProj( ctx, 1, GL_FALSE ); } imesa->vertex_format = vfmt; imesa->vertex_size = setup_tab[ind].vertex_size; imesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift; } if (!imesa->Fallback && !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { tnl->Driver.Render.Interp = setup_tab[imesa->SetupIndex].interp; tnl->Driver.Render.CopyPV = setup_tab[imesa->SetupIndex].copy_pv; } } }
void i830FreeVB( GLcontext *ctx ) { i830ContextPtr imesa = I830_CONTEXT(ctx); if (imesa->verts) { ALIGN_FREE(imesa->verts); imesa->verts = 0; } if (imesa->UbyteSecondaryColor.Ptr) { ALIGN_FREE(imesa->UbyteSecondaryColor.Ptr); imesa->UbyteSecondaryColor.Ptr = 0; } if (imesa->UbyteColor.Ptr) { ALIGN_FREE(imesa->UbyteColor.Ptr); imesa->UbyteColor.Ptr = 0; } }
static void i830LineWidth( GLcontext *ctx, GLfloat widthf ) { i830ContextPtr i830 = I830_CONTEXT( ctx ); int width; int state5; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s\n", __FUNCTION__); width = (int)(widthf * 2); CLAMP_SELF(width, 1, 15); state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK; state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width)); if (state5 != i830->state.Ctx[I830_CTXREG_STATE5]) { I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE5] = state5; } }
/* * This function is called to specify which buffer to read and write * for software rasterization (swrast) fallbacks. This doesn't necessarily * correspond to glDrawBuffer() or glReadBuffer() calls. */ static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, GLuint bufferBit) { i830ContextPtr imesa = I830_CONTEXT(ctx); assert( (colorBuffer == imesa->driDrawable->driverPrivate) || (colorBuffer == imesa->driReadable->driverPrivate) ); imesa->mesa_drawable = (colorBuffer == imesa->driDrawable->driverPrivate) ? imesa->driDrawable : imesa->driReadable; if (bufferBit == BUFFER_BIT_FRONT_LEFT) { imesa->drawMap = (char *)imesa->driScreen->pFB; imesa->readMap = (char *)imesa->driScreen->pFB; } else if (bufferBit == BUFFER_BIT_BACK_LEFT) { imesa->drawMap = imesa->i830Screen->back.map; imesa->readMap = imesa->i830Screen->back.map; } else { ASSERT(0); } }
/* In Mesa 3.5 we can reliably do native flatshading. */ static void i830ShadeModel(GLcontext *ctx, GLenum mode) { i830ContextPtr i830 = I830_CONTEXT(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX); #define SHADE_MODE_MASK ((1<<10)|(1<<8)|(1<<6)|(1<<4)) i830->state.Ctx[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK; if (mode == GL_FLAT) { i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) | FOG_SHADE_MODE(SHADE_MODE_FLAT) | SPEC_SHADE_MODE(SHADE_MODE_FLAT) | COLOR_SHADE_MODE(SHADE_MODE_FLAT)); } else { i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) | FOG_SHADE_MODE(SHADE_MODE_LINEAR) | SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | COLOR_SHADE_MODE(SHADE_MODE_LINEAR)); } }
static void i830SetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, GLenum mode) { i830ContextPtr imesa = I830_CONTEXT(ctx); switch( mode ) { case GL_FRONT_LEFT: if ( imesa->sarea->pf_current_page == 1 ) imesa->readMap = imesa->i830Screen->back.map; else imesa->readMap = (char*)imesa->driScreen->pFB; break; case GL_BACK_LEFT: if ( imesa->sarea->pf_current_page == 1 ) imesa->readMap = (char*)imesa->driScreen->pFB; else imesa->readMap = imesa->i830Screen->back.map; break; default: ASSERT(0); break; } }
static void i830ColorMask(GLcontext *ctx, GLboolean r, GLboolean g, GLboolean b, GLboolean a) { i830ContextPtr i830 = I830_CONTEXT( ctx ); GLuint tmp = 0; if (INTEL_DEBUG&DEBUG_DRI) fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a); tmp = ((i830->state.Ctx[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) | ENABLE_COLOR_MASK | ENABLE_COLOR_WRITE | ((!r) << WRITEMASK_RED_SHIFT) | ((!g) << WRITEMASK_GREEN_SHIFT) | ((!b) << WRITEMASK_BLUE_SHIFT) | ((!a) << WRITEMASK_ALPHA_SHIFT)); if (tmp != i830->state.Ctx[I830_CTXREG_ENABLES_2]) { I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_2] = tmp; } }
/** * Makes sure that the proper enables are set for LogicOp, Independant Alpha * Blend, and Blending. It needs to be called from numerous places where we * could change the LogicOp or Independant Alpha Blend without subsequent * calls to glEnable. * * \todo * This function is substantially different from the old i830-specific driver. * I'm not sure which is correct. */ static void i830EvalLogicOpBlendState(GLcontext *ctx) { i830ContextPtr i830 = I830_CONTEXT(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX); if (RGBA_LOGICOP_ENABLED(ctx)) { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND | ENABLE_LOGIC_OP); } else if (ctx->Color.BlendEnabled) { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND | DISABLE_LOGIC_OP); } else { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND | DISABLE_LOGIC_OP); } }
static void i830RunPipeline( GLcontext *ctx ) { i830ContextPtr imesa = I830_CONTEXT(ctx); if (imesa->NewGLState) { if (imesa->NewGLState & _NEW_TEXTURE) { I830_FIREVERTICES( imesa ); i830UpdateTextureState( ctx ); /* may modify imesa->NewGLState */ } if (!imesa->Fallback) { if (imesa->NewGLState & _I830_NEW_VERTEX) i830ChooseVertexState( ctx ); if (imesa->NewGLState & _I830_NEW_RENDERSTATE) i830ChooseRenderState( ctx ); } imesa->NewGLState = 0; } _tnl_run_pipeline( ctx ); }
static void i830RenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ) { i830ContextPtr imesa = I830_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLuint prim = imesa->render_primitive; /* Render the new vertices as an unclipped polygon. */ { GLuint *tmp = VB->Elts; VB->Elts = (GLuint *)elts; tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); VB->Elts = tmp; } /* Restore the render primitive */ if (prim != GL_POLYGON) tnl->Driver.Render.PrimitiveNotify( ctx, prim ); }
/** * Copy the window contents named by dPriv to the rotated (or reflected) * color buffer. * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source. */ void i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv, GLuint srcBuf) { i830ContextPtr i830 = I830_CONTEXT( intel ); intelScreenPrivate *screen = intel->intelScreen; const GLuint cpp = screen->cpp; drm_clip_rect_t fullRect; GLuint textureFormat, srcOffset, srcPitch; const drm_clip_rect_t *clipRects; int numClipRects; int i; int xOrig, yOrig; int origNumClipRects; drm_clip_rect_t *origRects; /* * set up hardware state */ intelFlush( &intel->ctx ); SET_STATE( i830, meta ); set_initial_state( i830 ); set_no_texture( i830 ); set_vertex_format( i830 ); set_no_depth_stencil_write( i830 ); set_color_mask( i830, GL_FALSE ); LOCK_HARDWARE(intel); /* save current drawing origin and cliprects (restored at end) */ xOrig = intel->drawX; yOrig = intel->drawY; origNumClipRects = intel->numClipRects; origRects = intel->pClipRects; if (!intel->numClipRects) goto done; /* * set drawing origin, cliprects for full-screen access to rotated screen */ fullRect.x1 = 0; fullRect.y1 = 0; fullRect.x2 = screen->rotatedWidth; fullRect.y2 = screen->rotatedHeight; intel->drawX = 0; intel->drawY = 0; intel->numClipRects = 1; intel->pClipRects = &fullRect; set_draw_region( i830, &screen->rotated ); if (cpp == 4) textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888; else textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565; if (srcBuf == BUFFER_BIT_FRONT_LEFT) { srcPitch = screen->front.pitch; /* in bytes */ srcOffset = screen->front.offset; /* bytes */ clipRects = dPriv->pClipRects; numClipRects = dPriv->numClipRects; } else { srcPitch = screen->back.pitch; /* in bytes */ srcOffset = screen->back.offset; /* bytes */ clipRects = dPriv->pBackClipRects; numClipRects = dPriv->numBackClipRects; } /* set the whole screen up as a texture to avoid alignment issues */ set_tex_rect_source(i830, srcOffset, screen->width, screen->height, srcPitch, textureFormat); enable_texture_blend_replace(i830); /* * loop over the source window's cliprects */ for (i = 0; i < numClipRects; i++) { int srcX0 = clipRects[i].x1; int srcY0 = clipRects[i].y1; int srcX1 = clipRects[i].x2; int srcY1 = clipRects[i].y2; GLfloat verts[4][2], tex[4][2]; int j; /* build vertices for four corners of clip rect */ verts[0][0] = srcX0; verts[0][1] = srcY0; verts[1][0] = srcX1; verts[1][1] = srcY0; verts[2][0] = srcX1; verts[2][1] = srcY1; verts[3][0] = srcX0; verts[3][1] = srcY1; /* .. and texcoords */ tex[0][0] = srcX0; tex[0][1] = srcY0; tex[1][0] = srcX1; tex[1][1] = srcY0; tex[2][0] = srcX1; tex[2][1] = srcY1; tex[3][0] = srcX0; tex[3][1] = srcY1; /* transform coords to rotated screen coords */ for (j = 0; j < 4; j++) { matrix23TransformCoordf(&screen->rotMatrix, &verts[j][0], &verts[j][1]); } /* draw polygon to map source image to dest region */ draw_poly(i830, 255, 255, 255, 255, 4, verts, tex); } /* cliprect loop */ assert(!intel->prim.flush); intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE ); done: /* restore original drawing origin and cliprects */ intel->drawX = xOrig; intel->drawY = yOrig; intel->numClipRects = origNumClipRects; intel->pClipRects = origRects; UNLOCK_HARDWARE(intel); SET_STATE( i830, state ); }