📄 intel_batchbuffer.c
字号:
{ const intelScreenPrivate *intelScreen = intel->intelScreen; const __DRIdrawablePrivate *dPriv = intel->driDrawable; const int nbox = dPriv->numClipRects; const drm_clip_rect_t *pbox = dPriv->pClipRects; drm_clip_rect_t box; const int cpp = intelScreen->cpp; const int pitch = intelScreen->front.pitch; /* in bytes */ int i; GLuint CMD, BR13; BATCH_LOCALS; switch(cpp) { case 2: BR13 = (pitch) | (0xCC << 16) | (1<<24); CMD = XY_SRC_COPY_BLT_CMD; break; case 4: BR13 = (pitch) | (0xCC << 16) | (1<<24) | (1<<25); CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB); break; default: BR13 = (pitch) | (0xCC << 16) | (1<<24); CMD = XY_SRC_COPY_BLT_CMD; break; } if (0) intel_draw_performance_boxes( intel ); for (i = 0 ; i < nbox; i++, pbox++) { if (pbox->x1 > pbox->x2 || pbox->y1 > pbox->y2 || pbox->x2 > intelScreen->width || pbox->y2 > intelScreen->height) { _mesa_warning(&intel->ctx, "Bad cliprect in intelCopyBuffer()"); continue; } box = *pbox; if (rect) { if (rect->x1 > box.x1) box.x1 = rect->x1; if (rect->y1 > box.y1) box.y1 = rect->y1; if (rect->x2 < box.x2) box.x2 = rect->x2; if (rect->y2 < box.y2) box.y2 = rect->y2; if (box.x1 > box.x2 || box.y1 > box.y2) continue; } BEGIN_BATCH( 8); OUT_BATCH( CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (box.y1 << 16) | box.x1 ); OUT_BATCH( (box.y2 << 16) | box.x2 ); if (intel->sarea->pf_current_page == 0) OUT_BATCH( intelScreen->front.offset ); else OUT_BATCH( intelScreen->back.offset ); OUT_BATCH( (box.y1 << 16) | box.x1 ); OUT_BATCH( BR13 & 0xffff ); if (intel->sarea->pf_current_page == 0) OUT_BATCH( intelScreen->back.offset ); else OUT_BATCH( intelScreen->front.offset ); ADVANCE_BATCH(); } } intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE ); UNLOCK_HARDWARE( intel ); if (!rect) { intel->swap_count++; (*dri_interface->getUST)(&ust); if (missed_target) { intel->swap_missed_count++; intel->swap_missed_ust = ust - intel->swap_ust; } intel->swap_ust = ust; }}void intelEmitFillBlitLocked( intelContextPtr intel, GLuint cpp, GLshort dst_pitch, /* in bytes */ GLuint dst_offset, GLshort x, GLshort y, GLshort w, GLshort h, GLuint color ){ GLuint BR13, CMD; BATCH_LOCALS; switch(cpp) { case 1: case 2: case 3: BR13 = dst_pitch | (0xF0 << 16) | (1<<24); CMD = XY_COLOR_BLT_CMD; break; case 4: BR13 = dst_pitch | (0xF0 << 16) | (1<<24) | (1<<25); CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); break; default: return; } BEGIN_BATCH( 6); OUT_BATCH( CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (y << 16) | x ); OUT_BATCH( ((y+h) << 16) | (x+w) ); OUT_BATCH( dst_offset ); OUT_BATCH( color ); ADVANCE_BATCH();}/* Copy BitBlt */void intelEmitCopyBlitLocked( intelContextPtr intel, GLuint cpp, GLshort src_pitch, GLuint src_offset, GLshort dst_pitch, GLuint dst_offset, GLshort src_x, GLshort src_y, GLshort dst_x, GLshort dst_y, GLshort w, GLshort h ){ GLuint CMD, BR13; int dst_y2 = dst_y + h; int dst_x2 = dst_x + w; BATCH_LOCALS; src_pitch *= cpp; dst_pitch *= cpp; switch(cpp) { case 1: case 2: case 3: BR13 = dst_pitch | (0xCC << 16) | (1<<24); CMD = XY_SRC_COPY_BLT_CMD; break; case 4: BR13 = dst_pitch | (0xCC << 16) | (1<<24) | (1<<25); CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB); break; default: return; } if (dst_y2 < dst_y || dst_x2 < dst_x) { return; } BEGIN_BATCH( 12); OUT_BATCH( CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (dst_y << 16) | dst_x ); OUT_BATCH( (dst_y2 << 16) | dst_x2 ); OUT_BATCH( dst_offset ); OUT_BATCH( (src_y << 16) | src_x ); OUT_BATCH( src_pitch ); OUT_BATCH( src_offset ); ADVANCE_BATCH();}void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all, GLint cx1, GLint cy1, GLint cw, GLint ch){ intelContextPtr intel = INTEL_CONTEXT( ctx ); intelScreenPrivate *intelScreen = intel->intelScreen; GLuint clear_depth, clear_color; GLint cx, cy; GLint pitch; GLint cpp = intelScreen->cpp; GLint i; GLuint BR13, CMD, D_CMD; BATCH_LOCALS; intelFlush( &intel->ctx ); LOCK_HARDWARE( intel ); pitch = intelScreen->front.pitch; clear_color = intel->ClearColor; clear_depth = 0; if (flags & BUFFER_BIT_DEPTH) { clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth); } if (flags & BUFFER_BIT_STENCIL) { clear_depth |= (ctx->Stencil.Clear & 0xff) << 24; } switch(cpp) { case 2: BR13 = (0xF0 << 16) | (pitch) | (1<<24); D_CMD = CMD = XY_COLOR_BLT_CMD; break; case 4: BR13 = (0xF0 << 16) | (pitch) | (1<<24) | (1<<25); CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); D_CMD = XY_COLOR_BLT_CMD; if (flags & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB; if (flags & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA; break; default: BR13 = (0xF0 << 16) | (pitch) | (1<<24); D_CMD = CMD = XY_COLOR_BLT_CMD; break; } { /* flip top to bottom */ cy = intel->driDrawable->h-cy1-ch; cx = cx1 + intel->drawX; cy += intel->drawY; /* adjust for page flipping */ if ( intel->sarea->pf_current_page == 1 ) { GLuint tmp = flags; flags &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); if ( tmp & BUFFER_BIT_FRONT_LEFT ) flags |= BUFFER_BIT_BACK_LEFT; if ( tmp & BUFFER_BIT_BACK_LEFT ) flags |= BUFFER_BIT_FRONT_LEFT; } for (i = 0 ; i < intel->numClipRects ; i++) { drm_clip_rect_t *box = &intel->pClipRects[i]; drm_clip_rect_t b; if (!all) { GLint x = box->x1; GLint y = box->y1; GLint w = box->x2 - x; GLint h = box->y2 - y; if (x < cx) w -= cx - x, x = cx; if (y < cy) h -= cy - y, y = cy; if (x + w > cx + cw) w = cx + cw - x; if (y + h > cy + ch) h = cy + ch - y; if (w <= 0) continue; if (h <= 0) continue; b.x1 = x; b.y1 = y; b.x2 = x + w; b.y2 = y + h; } else { b = *box; } if (b.x1 > b.x2 || b.y1 > b.y2 || b.x2 > intelScreen->width || b.y2 > intelScreen->height) continue; if ( flags & BUFFER_BIT_FRONT_LEFT ) { BEGIN_BATCH( 6); OUT_BATCH( CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (b.y1 << 16) | b.x1 ); OUT_BATCH( (b.y2 << 16) | b.x2 ); OUT_BATCH( intelScreen->front.offset ); OUT_BATCH( clear_color ); ADVANCE_BATCH(); } if ( flags & BUFFER_BIT_BACK_LEFT ) { BEGIN_BATCH( 6); OUT_BATCH( CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (b.y1 << 16) | b.x1 ); OUT_BATCH( (b.y2 << 16) | b.x2 ); OUT_BATCH( intelScreen->back.offset ); OUT_BATCH( clear_color ); ADVANCE_BATCH(); } if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) { BEGIN_BATCH( 6); OUT_BATCH( D_CMD ); OUT_BATCH( BR13 ); OUT_BATCH( (b.y1 << 16) | b.x1 ); OUT_BATCH( (b.y2 << 16) | b.x2 ); OUT_BATCH( intelScreen->depth.offset ); OUT_BATCH( clear_depth ); ADVANCE_BATCH(); } } } intelFlushBatchLocked( intel, GL_TRUE, GL_FALSE, GL_TRUE ); UNLOCK_HARDWARE( intel );}void intelDestroyBatchBuffer( GLcontext *ctx ){ intelContextPtr intel = INTEL_CONTEXT(ctx); if (intel->alloc.offset) { intelFreeAGP( intel, intel->alloc.ptr ); intel->alloc.ptr = NULL; intel->alloc.offset = 0; } else if (intel->alloc.ptr) { free(intel->alloc.ptr); intel->alloc.ptr = NULL; } memset(&intel->batch, 0, sizeof(intel->batch));}void intelInitBatchBuffer( GLcontext *ctx ){ intelContextPtr intel = INTEL_CONTEXT(ctx); /* This path isn't really safe with rotate: */ if (getenv("INTEL_BATCH") && intel->intelScreen->allow_batchbuffer) { switch (intel->intelScreen->deviceID) { case PCI_CHIP_I865_G: /* HW bug? Seems to crash if batchbuffer crosses 4k boundary. */ intel->alloc.size = 8 * 1024; break; default: /* This is the smallest amount of memory the kernel deals with. * We'd ideally like to make this smaller. */ intel->alloc.size = 1 << intel->intelScreen->logTextureGranularity; break; } /* KW: temporary - this make crashes & lockups more frequent, so * leave in until they are solved. */ intel->alloc.size = 8 * 1024; intel->alloc.ptr = intelAllocateAGP( intel, intel->alloc.size ); if (intel->alloc.ptr) intel->alloc.offset = intelAgpOffsetFromVirtual( intel, intel->alloc.ptr ); else intel->alloc.offset = 0; /* OK? */ } /* The default is now to use a local buffer and pass that to the * kernel. This is also a fallback if allocation fails on the * above path: */ if (!intel->alloc.ptr) { intel->alloc.size = 8 * 1024; intel->alloc.ptr = malloc( intel->alloc.size ); intel->alloc.offset = 0; } assert(intel->alloc.ptr);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -