Esempio n. 1
0
/* 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);
}
Esempio n. 2
0
/**
 * 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);
        }
    }
}