/** * Called when done softare rendering. Unmap the buffers we mapped in * the above function. */ void intelSpanRenderFinish(GLcontext * ctx) { struct intel_context *intel = intel_context(ctx); GLuint i; _swrast_flush(ctx); /* Now unmap the framebuffer: */ #if 0 intel_region_unmap(intel, intel->front_region); intel_region_unmap(intel, intel->back_region); intel_region_unmap(intel, intel->intelScreen->depth_region); #endif for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) { struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; intel_tex_unmap_images(intel, intel_texture_object(texObj)); } } intel_map_unmap_buffers(intel, GL_FALSE); UNLOCK_HARDWARE(intel); }
/** * Copy mipmap image between trees */ void intel_miptree_image_copy(struct intel_context *intel, struct intel_mipmap_tree *dst, GLuint face, GLuint level, struct intel_mipmap_tree *src) { GLuint width = src->level[level].width; GLuint height = src->level[level].height; GLuint depth = src->level[level].depth; GLuint src_x, src_y, dst_x, dst_y; GLuint i; GLboolean success; if (dst->compressed) { GLuint align_w, align_h; intel_get_texture_alignment_unit(dst->internal_format, &align_w, &align_h); height = (height + 3) / 4; width = ALIGN(width, align_w); } intel_prepare_render(intel); for (i = 0; i < depth; i++) { intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y); intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); success = intel_region_copy(intel, dst->region, 0, dst_x, dst_y, src->region, 0, src_x, src_y, width, height, GL_FALSE, GL_COPY); if (!success) { GLubyte *src_ptr, *dst_ptr; src_ptr = intel_region_map(intel, src->region); dst_ptr = intel_region_map(intel, dst->region); _mesa_copy_rect(dst_ptr, dst->cpp, dst->region->pitch, dst_x, dst_y, width, height, src_ptr, src->region->pitch, src_x, src_y); intel_region_unmap(intel, src->region); intel_region_unmap(intel, dst->region); } } }
void intel_miptree_image_unmap(struct intel_context *intel, struct intel_mipmap_tree *mt) { DBG("%s\n", __FUNCTION__); intel_region_unmap(intel, mt->region); }
/* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination * - upload data as new buffer and blit * * Currently always memcpy. */ void intel_region_data(struct intel_context *intel, struct intel_region *dst, GLuint dst_offset, GLuint dstx, GLuint dsty, const void *src, GLuint src_pitch, GLuint srcx, GLuint srcy, GLuint width, GLuint height) { _DBG("%s\n", __FUNCTION__); if (intel == NULL) return; if (dst->pbo) { if (dstx == 0 && dsty == 0 && width == dst->pitch && height == dst->height) intel_region_release_pbo(intel, dst); else intel_region_cow(intel, dst); } LOCK_HARDWARE(intel); _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset, dst->cpp, dst->pitch, dstx, dsty, width, height, src, src_pitch, srcx, srcy); intel_region_unmap(intel, dst); UNLOCK_HARDWARE(intel); }
static void unmap_regions(GLcontext * ctx, struct intel_renderbuffer *depthRb, struct intel_renderbuffer *stencilRb) { struct intel_context *intel = intel_context(ctx); if (depthRb && depthRb->region) { intel_region_unmap(intel->intelScreen, depthRb->region); depthRb->pfMap = NULL; depthRb->pfPitch = 0; } if (stencilRb && stencilRb->region) { intel_region_unmap(intel->intelScreen, stencilRb->region); stencilRb->pfMap = NULL; stencilRb->pfPitch = 0; } }
static void intel_tex_unmap_image_for_swrast(struct intel_context *intel, struct intel_texture_image *intel_image) { if (intel_image && intel_image->mt) { intel_region_unmap(intel, intel_image->mt->region); intel_image->base.Map = NULL; } }
/** * Map or unmap all the renderbuffers which we may need during * software rendering. * XXX in the future, we could probably convey extra information to * reduce the number of mappings needed. I.e. if doing a glReadPixels * from the depth buffer, we really only need one mapping. * * XXX Rewrite this function someday. * We can probably just loop over all the renderbuffer attachments, * map/unmap all of them, and not worry about the _ColorDrawBuffers * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields. */ static void intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) { GLcontext *ctx = &intel->ctx; GLuint i, j; struct intel_renderbuffer *irb; /* color draw buffers */ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers[i]; j++) { struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i][j]; irb = intel_renderbuffer(rb); if (irb) { /* this is a user-created intel_renderbuffer */ if (irb->region) { if (map) intel_region_map(intel->intelScreen, irb->region); else intel_region_unmap(intel->intelScreen, irb->region); } irb->pfMap = irb->region->map; irb->pfPitch = irb->region->pitch; } } } /* check for render to textures */ for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment + i; struct gl_texture_object *tex = att->Texture; if (tex) { /* render to texture */ ASSERT(att->Renderbuffer); if (map) { struct gl_texture_image *texImg; texImg = tex->Image[att->CubeMapFace][att->TextureLevel]; intel_tex_map_images(intel, intel_texture_object(tex)); } else { intel_tex_unmap_images(intel, intel_texture_object(tex)); } } } /* color read buffers */ irb = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); if (irb && irb->region) { if (map) intel_region_map(intel->intelScreen, irb->region); else intel_region_unmap(intel->intelScreen, irb->region); irb->pfMap = irb->region->map; irb->pfPitch = irb->region->pitch; } /* Account for front/back color page flipping. * The span routines use the pfMap and pfPitch fields which will * swap the front/back region map/pitch if we're page flipped. * Do this after mapping, above, so the map field is valid. */ #if 0 if (map && ctx->DrawBuffer->Name == 0) { struct intel_renderbuffer *irbFront = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_FRONT_LEFT); struct intel_renderbuffer *irbBack = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_BACK_LEFT); if (irbBack) { /* double buffered */ if (intel->sarea->pf_current_page == 0) { irbFront->pfMap = irbFront->region->map; irbFront->pfPitch = irbFront->region->pitch; irbBack->pfMap = irbBack->region->map; irbBack->pfPitch = irbBack->region->pitch; } else { irbFront->pfMap = irbBack->region->map; irbFront->pfPitch = irbBack->region->pitch; irbBack->pfMap = irbFront->region->map; irbBack->pfPitch = irbFront->region->pitch; } } } #endif /* depth buffer (Note wrapper!) */ if (ctx->DrawBuffer->_DepthBuffer) { irb = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped); if (irb && irb->region && irb->Base.Name != 0) { if (map) { intel_region_map(intel->intelScreen, irb->region); irb->pfMap = irb->region->map; irb->pfPitch = irb->region->pitch; } else { intel_region_unmap(intel->intelScreen, irb->region); irb->pfMap = NULL; irb->pfPitch = 0; } } } /* stencil buffer (Note wrapper!) */ if (ctx->DrawBuffer->_StencilBuffer) { irb = intel_renderbuffer(ctx->DrawBuffer->_StencilBuffer->Wrapped); if (irb && irb->region && irb->Base.Name != 0) { if (map) { intel_region_map(intel->intelScreen, irb->region); irb->pfMap = irb->region->map; irb->pfPitch = irb->region->pitch; } else { intel_region_unmap(intel->intelScreen, irb->region); irb->pfMap = NULL; irb->pfPitch = 0; } } } }