コード例 #1
0
ファイル: intel_mipmap_tree.c プロジェクト: toastpp/toastpp
/* 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 dst_offset = intel_miptree_image_offset(dst, face, level);
   GLuint src_offset = intel_miptree_image_offset(src, face, level);
   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
   const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
   GLuint i;

   if (dst->compressed) {
       GLuint alignment = intel_compressed_alignment(dst->internal_format);
       height = (height + 3) / 4;
       width = ((width + alignment - 1) & ~(alignment - 1));
   }

   for (i = 0; i < depth; i++) {
      intel_region_copy(intel,
                        dst->region, dst_offset + dst_depth_offset[i],
                        0,
                        0,
                        src->region, src_offset + src_depth_offset[i],
                        0, 0, width, height);
   }

}
コード例 #2
0
ファイル: intel_mipmap_tree.c プロジェクト: beligit/psx4m
/* 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 dst_offset = intel_miptree_image_offset(dst, face, level);
   GLuint src_offset = intel_miptree_image_offset(src, face, level);
   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
   const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
   GLuint i;

   if (dst->compressed)
      height /= 4;
   for (i = 0; i < depth; i++) {
      intel_region_copy(intel->intelScreen,
                        dst->region, dst_offset + dst_depth_offset[i],
                        0,
                        0,
                        src->region, src_offset + src_depth_offset[i],
                        0, 0, width, height);
   }

}
コード例 #3
0
ファイル: intel_mipmap_tree.c プロジェクト: B-Rich/chromium
/**
 * 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);
        }
    }
}
コード例 #4
0
ファイル: intel_pixel_copy.c プロジェクト: nikai3d/mesa
/**
 * CopyPixels with the blitter.  Don't support zooming, pixel transfer, etc.
 */
static GLboolean
do_blit_copypixels(struct gl_context * ctx,
                   GLint srcx, GLint srcy,
                   GLsizei width, GLsizei height,
                   GLint dstx, GLint dsty, GLenum type)
{
   struct intel_context *intel = intel_context(ctx);
   struct gl_framebuffer *fb = ctx->DrawBuffer;
   struct gl_framebuffer *read_fb = ctx->ReadBuffer;
   GLint orig_dstx;
   GLint orig_dsty;
   GLint orig_srcx;
   GLint orig_srcy;
   GLboolean flip = GL_FALSE;
   struct intel_renderbuffer *draw_irb = NULL;
   struct intel_renderbuffer *read_irb = NULL;

   /* Update draw buffer bounds */
   _mesa_update_state(ctx);

   switch (type) {
   case GL_COLOR:
      if (fb->_NumColorDrawBuffers != 1) {
	 fallback_debug("glCopyPixels() fallback: MRT\n");
	 return GL_FALSE;
      }

      draw_irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
      read_irb = intel_renderbuffer(read_fb->_ColorReadBuffer);
      break;
   case GL_DEPTH_STENCIL_EXT:
      draw_irb = intel_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
      read_irb =
	 intel_renderbuffer(read_fb->Attachment[BUFFER_DEPTH].Renderbuffer);
      break;
   case GL_DEPTH:
      fallback_debug("glCopyPixels() fallback: GL_DEPTH\n");
      return GL_FALSE;
   case GL_STENCIL:
      fallback_debug("glCopyPixels() fallback: GL_STENCIL\n");
      return GL_FALSE;
   default:
      fallback_debug("glCopyPixels(): Unknown type\n");
      return GL_FALSE;
   }

   if (!draw_irb) {
      fallback_debug("glCopyPixels() fallback: missing draw buffer\n");
      return GL_FALSE;
   }

   if (!read_irb) {
      fallback_debug("glCopyPixels() fallback: missing read buffer\n");
      return GL_FALSE;
   }

   if (draw_irb->Base.Format != read_irb->Base.Format &&
       !(draw_irb->Base.Format == MESA_FORMAT_XRGB8888 &&
	 read_irb->Base.Format == MESA_FORMAT_ARGB8888)) {
      fallback_debug("glCopyPixels() fallback: mismatched formats (%s -> %s\n",
		     _mesa_get_format_name(read_irb->Base.Format),
		     _mesa_get_format_name(draw_irb->Base.Format));
      return GL_FALSE;
   }

   /* Copypixels can be more than a straight copy.  Ensure all the
    * extra operations are disabled:
    */
   if (!intel_check_copypixel_blit_fragment_ops(ctx) ||
       ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
      return GL_FALSE;

   intel_prepare_render(intel);

   intel_flush(&intel->ctx);

   /* Clip to destination buffer. */
   orig_dstx = dstx;
   orig_dsty = dsty;
   if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
			     fb->_Xmax, fb->_Ymax,
			     &dstx, &dsty, &width, &height))
      goto out;
   /* Adjust src coords for our post-clipped destination origin */
   srcx += dstx - orig_dstx;
   srcy += dsty - orig_dsty;

   /* Clip to source buffer. */
   orig_srcx = srcx;
   orig_srcy = srcy;
   if (!_mesa_clip_to_region(0, 0,
			     read_fb->Width, read_fb->Height,
			     &srcx, &srcy, &width, &height))
      goto out;
   /* Adjust dst coords for our post-clipped source origin */
   dstx += srcx - orig_srcx;
   dsty += srcy - orig_srcy;

   /* Flip dest Y if it's a window system framebuffer. */
   if (fb->Name == 0) {
      /* copypixels to a window system framebuffer */
      dsty = fb->Height - dsty - height;
      flip = !flip;
   }

   /* Flip source Y if it's a window system framebuffer. */
   if (read_fb->Name == 0) {
      srcy = read_fb->Height - srcy - height;
      flip = !flip;
   }

   srcx += read_irb->draw_x;
   srcy += read_irb->draw_y;
   dstx += draw_irb->draw_x;
   dsty += draw_irb->draw_y;

   if (!intel_region_copy(intel,
			  draw_irb->region, 0, dstx, dsty,
			  read_irb->region, 0, srcx, srcy,
			  width, height, flip,
			  ctx->Color.ColorLogicOpEnabled ?
			  ctx->Color.LogicOp : GL_COPY)) {
      DBG("%s: blit failure\n", __FUNCTION__);
      return GL_FALSE;
   }

out:
   intel_check_front_buffer_rendering(intel);

   DBG("%s: success\n", __FUNCTION__);
   return GL_TRUE;
}