当前位置: 首页>>代码示例>>C++>>正文


C++ pipe_transfer_map函数代码示例

本文整理汇总了C++中pipe_transfer_map函数的典型用法代码示例。如果您正苦于以下问题:C++ pipe_transfer_map函数的具体用法?C++ pipe_transfer_map怎么用?C++ pipe_transfer_map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pipe_transfer_map函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ExaUploadToScreen

static Bool
ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
		  int src_pitch)
{
    ScreenPtr pScreen = pPix->drawable.pScreen;
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
    struct pipe_transfer *transfer;
    void *map;

    if (!priv || !priv->tex)
	return FALSE;

    map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
                            PIPE_TRANSFER_WRITE, x, y, w, h, &transfer);
    if (!map)
	return FALSE;

    exa_debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
                 x, y, w, h, src_pitch);

    util_copy_rect(map,
		   priv->tex->format, transfer->stride, 0, 0, w, h,
		   (unsigned char*)src, src_pitch, 0, 0);

    exa->pipe->transfer_unmap(exa->pipe, transfer);

    return TRUE;
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:31,代码来源:xorg_exa.c

示例2: memset

static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx,
                                                     const VGuint *color_data,
                                                     const VGint color_data_len)
{
   struct pipe_context *pipe = ctx->pipe;
   struct pipe_screen *screen = pipe->screen;
   struct pipe_resource *tex = 0;
   struct pipe_resource templ;

   memset(&templ, 0, sizeof(templ));
   templ.target = PIPE_TEXTURE_1D;
   templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;
   templ.last_level = 0;
   templ.width0 = color_data_len;
   templ.height0 = 1;
   templ.depth0 = 1;
   templ.array_size = 1;
   templ.bind = PIPE_BIND_SAMPLER_VIEW;

   tex = screen->resource_create(screen, &templ);

   { /* upload color_data */
      struct pipe_transfer *transfer;
      void *map =
         pipe_transfer_map(pipe, tex,
                           0, 0,
                           PIPE_TRANSFER_READ_WRITE ,
                           0, 0, tex->width0, tex->height0,
                           &transfer);
      memcpy(map, color_data, sizeof(VGint)*color_data_len);
      pipe->transfer_unmap(pipe, transfer);
   }

   return tex;
}
开发者ID:Forzaferrarileo,项目名称:mesa,代码行数:35,代码来源:api_filters.c

示例3: util_clear_render_target

/**
 * Fallback for pipe->clear_render_target() function.
 * XXX this looks too hackish to be really useful.
 * cpp > 4 looks like a gross hack at best...
 * Plus can't use these transfer fallbacks when clearing
 * multisampled surfaces for instance.
 */
void
util_clear_render_target(struct pipe_context *pipe,
                         struct pipe_surface *dst,
                         const union pipe_color_union *color,
                         unsigned dstx, unsigned dsty,
                         unsigned width, unsigned height)
{
   struct pipe_transfer *dst_trans;
   void *dst_map;
   union util_color uc;

   assert(dst->texture);
   if (!dst->texture)
      return;
   /* XXX: should handle multiple layers */
   dst_map = pipe_transfer_map(pipe,
                               dst->texture,
                               dst->u.tex.level,
                               dst->u.tex.first_layer,
                               PIPE_TRANSFER_WRITE,
                               dstx, dsty, width, height, &dst_trans);

   assert(dst_map);

   if (dst_map) {
      assert(dst_trans->stride > 0);

      util_pack_color(color->f, dst->texture->format, &uc);
      util_fill_rect(dst_map, dst->texture->format,
                     dst_trans->stride,
                     0, 0, width, height, &uc);

      pipe->transfer_unmap(pipe, dst_trans);
   }
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:42,代码来源:u_surface.c

示例4: sp_tile_cache_set_surface

/**
 * Specify the surface to cache.
 */
void
sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
                          struct pipe_surface *ps)
{
   struct pipe_context *pipe = tc->pipe;

   if (tc->transfer_map) {
      if (ps == tc->surface)
         return;

      pipe->transfer_unmap(pipe, tc->transfer);
      tc->transfer = NULL;
      tc->transfer_map = NULL;
   }

   tc->surface = ps;

   if (ps) {
      if (ps->texture->target != PIPE_BUFFER) {
         tc->transfer_map = pipe_transfer_map(pipe, ps->texture,
                                              ps->u.tex.level, ps->u.tex.first_layer,
                                              PIPE_TRANSFER_READ_WRITE |
                                              PIPE_TRANSFER_UNSYNCHRONIZED,
                                              0, 0, ps->width, ps->height,
                                              &tc->transfer);
      }
      else {
         /* can't render to buffers */
         assert(0);
      }

      tc->depth_stencil = util_format_is_depth_or_stencil(ps->format);
   }
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:37,代码来源:sp_tile_cache.c

示例5: xa_surface_map

void *
xa_surface_map(struct xa_context *ctx,
	       struct xa_surface *srf, unsigned int usage)
{
    void *map;
    unsigned int transfer_direction = 0;
    struct pipe_context *pipe = ctx->pipe;

    if (srf->transfer)
	return NULL;

    if (usage & XA_MAP_READ)
	transfer_direction = PIPE_TRANSFER_READ;
    if (usage & XA_MAP_WRITE)
	transfer_direction = PIPE_TRANSFER_WRITE;

    if (!transfer_direction)
	return NULL;

    srf->transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
				      transfer_direction, 0, 0,
				      srf->tex->width0, srf->tex->height0);
    if (!srf->transfer)
	return NULL;

    map = pipe_transfer_map(pipe, srf->transfer);
    if (!map)
	pipe->transfer_destroy(pipe, srf->transfer);

    srf->mapping_pipe = pipe;
    return map;
}
开发者ID:nikai3d,项目名称:mesa,代码行数:32,代码来源:xa_context.c

示例6: ExaPrepareAccess

static Bool
ExaPrepareAccess(PixmapPtr pPix, int index)
{
    ScreenPtr pScreen = pPix->drawable.pScreen;
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
    struct exa_pixmap_priv *priv;

    priv = exaGetPixmapDriverPrivate(pPix);

    if (!priv)
	return FALSE;

    if (!priv->tex)
	return FALSE;

    exa_debug_printf("ExaPrepareAccess %d\n", index);

    if (priv->map_count == 0)
    {
        assert(pPix->drawable.width <= priv->tex->width0);
        assert(pPix->drawable.height <= priv->tex->height0);

	pPix->devPrivate.ptr =
	   pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
#ifdef EXA_MIXED_PIXMAPS
                             PIPE_TRANSFER_MAP_DIRECTLY |
#endif
                             PIPE_TRANSFER_READ_WRITE,
                             0, 0,
                             pPix->drawable.width,
                             pPix->drawable.height,
                             &priv->map_transfer);
        if (!pPix->devPrivate.ptr)
#ifdef EXA_MIXED_PIXMAPS
	    return FALSE;
#else
	    FatalError("failed to create transfer\n");
#endif

	pPix->devKind = priv->map_transfer->stride;
    }

    priv->map_count++;

    exa_debug_printf("ExaPrepareAccess %d prepared\n", index);

    return TRUE;
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:50,代码来源:xorg_exa.c

示例7: util_probe_rect_rgba_multi

/**
 * Probe and test if the rectangle contains the expected color.
 *
 * If "num_expected_colors" > 1, at least one expected color must match
 * the probed color. "expected" should be an array of 4*num_expected_colors
 * floats.
 */
static bool
util_probe_rect_rgba_multi(struct pipe_context *ctx, struct pipe_resource *tex,
                           unsigned offx, unsigned offy, unsigned w,
                           unsigned h,
                           const float *expected,
                           unsigned num_expected_colors)
{
   struct pipe_transfer *transfer;
   void *map;
   float *pixels = malloc(w * h * 4 * sizeof(float));
   int x,y,e,c;
   bool pass = true;

   map = pipe_transfer_map(ctx, tex, 0, 0, PIPE_TRANSFER_READ,
                           offx, offy, w, h, &transfer);
   pipe_get_tile_rgba(transfer, map, 0, 0, w, h, pixels);
   pipe_transfer_unmap(ctx, transfer);

   for (e = 0; e < num_expected_colors; e++) {
      for (y = 0; y < h; y++) {
         for (x = 0; x < w; x++) {
            float *probe = &pixels[(y*w + x)*4];

            for (c = 0; c < 4; c++) {
               if (fabs(probe[c] - expected[e*4+c]) >= TOLERANCE) {
                  if (e < num_expected_colors-1)
                     goto next_color; /* test the next expected color */

                  printf("Probe color at (%i,%i),  ", offx+x, offy+y);
                  printf("Expected: %.3f, %.3f, %.3f, %.3f,  ",
                         expected[e*4], expected[e*4+1],
                         expected[e*4+2], expected[e*4+3]);
                  printf("Got: %.3f, %.3f, %.3f, %.3f\n",
                         probe[0], probe[1], probe[2], probe[2]);
                  pass = false;
                  goto done;
               }
            }
         }
      }
      break; /* this color was successful */

   next_color:;
   }
done:

   free(pixels);
   return pass;
}
开发者ID:Distrotech,项目名称:Mesa,代码行数:56,代码来源:u_tests.c

示例8: xa_surface_dma

int
xa_surface_dma(struct xa_context *ctx,
	       struct xa_surface *srf,
	       void *data,
	       unsigned int pitch,
	       int to_surface, struct xa_box *boxes, unsigned int num_boxes)
{
    struct pipe_transfer *transfer;
    void *map;
    int w, h, i;
    enum pipe_transfer_usage transfer_direction;
    struct pipe_context *pipe = ctx->pipe;

    transfer_direction = (to_surface ? PIPE_TRANSFER_WRITE :
			  PIPE_TRANSFER_READ);

    for (i = 0; i < num_boxes; ++i, ++boxes) {
	w = boxes->x2 - boxes->x1;
	h = boxes->y2 - boxes->y1;

	transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
				     transfer_direction, boxes->x1, boxes->y1,
				     w, h);
	if (!transfer)
	    return -XA_ERR_NORES;

	map = pipe_transfer_map(ctx->pipe, transfer);
	if (!map)
	    goto out_no_map;

	if (to_surface) {
	    util_copy_rect(map, srf->tex->format, transfer->stride,
			   0, 0, w, h, data, pitch, boxes->x1, boxes->y1);
	} else {
	    util_copy_rect(data, srf->tex->format, pitch,
			   boxes->x1, boxes->y1, w, h, map, transfer->stride, 0,
			   0);
	}
	pipe->transfer_unmap(pipe, transfer);
	pipe->transfer_destroy(pipe, transfer);
	if (to_surface)
	    pipe->flush(pipe, &ctx->last_fence);
    }
    return XA_ERR_NONE;
 out_no_map:
    pipe->transfer_destroy(pipe, transfer);
    return -XA_ERR_NORES;
}
开发者ID:nikai3d,项目名称:mesa,代码行数:48,代码来源:xa_context.c

示例9: make_bitmap_texture

/**
 * Create a texture which represents a bitmap image.
 */
static struct pipe_resource *
make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
                    const struct gl_pixelstore_attrib *unpack,
                    const GLubyte *bitmap)
{
   struct st_context *st = st_context(ctx);
   struct pipe_context *pipe = st->pipe;
   struct pipe_transfer *transfer;
   ubyte *dest;
   struct pipe_resource *pt;

   /* PBO source... */
   bitmap = _mesa_map_pbo_source(ctx, unpack, bitmap);
   if (!bitmap) {
      return NULL;
   }

   /**
    * Create texture to hold bitmap pattern.
    */
   pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format,
                          0, width, height, 1, 1,
                          PIPE_BIND_SAMPLER_VIEW);
   if (!pt) {
      _mesa_unmap_pbo_source(ctx, unpack);
      return NULL;
   }

   transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
                                PIPE_TRANSFER_WRITE,
                                0, 0, width, height);

   dest = pipe_transfer_map(pipe, transfer);

   /* Put image into texture transfer */
   memset(dest, 0xff, height * transfer->stride);
   unpack_bitmap(st, 0, 0, width, height, unpack, bitmap,
                 dest, transfer->stride);

   _mesa_unmap_pbo_source(ctx, unpack);

   /* Release transfer */
   pipe_transfer_unmap(pipe, transfer);
   pipe->transfer_destroy(pipe, transfer);

   return pt;
}
开发者ID:iquiw,项目名称:xsrc,代码行数:50,代码来源:st_cb_bitmap.c

示例10: debug_dump_surface_bmp

void
debug_dump_surface_bmp(struct pipe_context *pipe,
                       const char *filename,
                       struct pipe_surface *surface)
{
   struct pipe_transfer *transfer;
   struct pipe_resource *texture = surface->texture;
   void *ptr;

   ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level,
                           surface->u.tex.first_layer, PIPE_TRANSFER_READ,
                           0, 0, surface->width, surface->height, &transfer);

   debug_dump_transfer_bmp(pipe, filename, transfer, ptr);

   pipe->transfer_unmap(pipe, transfer);
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:17,代码来源:u_debug.c

示例11: pipe_map

static int pipe_map(struct gralloc_drm_drv_t *drv,
		struct gralloc_drm_bo_t *bo, int x, int y, int w, int h,
		int enable_write, void **addr)
{
	struct pipe_manager *pm = (struct pipe_manager *) drv;
	struct pipe_buffer *buf = (struct pipe_buffer *) bo;
	int err = 0;

	pthread_mutex_lock(&pm->mutex);

	/* need a context to get transfer */
	if (!pm->context) {
		pm->context = pm->screen->context_create(pm->screen, NULL);
		if (!pm->context) {
			LOGE("failed to create pipe context");
			err = -ENOMEM;
		}
	}

	if (!err) {
		enum pipe_transfer_usage usage;

		usage = PIPE_TRANSFER_READ;
		if (enable_write)
			usage |= PIPE_TRANSFER_WRITE;

		assert(!buf->transfer);

		/*
		 * ignore x, y, w and h so that returned addr points at the
		 * start of the buffer
		 */
		buf->transfer = pipe_get_transfer(pm->context, buf->resource,
				0, 0, usage, 0, 0,
				buf->resource->width0, buf->resource->height0);
		if (buf->transfer)
			*addr = pipe_transfer_map(pm->context, buf->transfer);
		else
			err = -ENOMEM;
	}

	pthread_mutex_unlock(&pm->mutex);

	return err;
}
开发者ID:zlatinski,项目名称:android-omap-gralloc-drm-kms,代码行数:45,代码来源:gralloc_drm_pipe.c

示例12: st_texture_image_map

/**
 * Map a texture image and return the address for a particular 2D face/slice/
 * layer.  The stImage indicates the cube face and mipmap level.  The slice
 * of the 3D texture is passed in 'zoffset'.
 * \param usage  one of the PIPE_TRANSFER_x values
 * \param x, y, w, h  the region of interest of the 2D image.
 * \return address of mapping or NULL if any error
 */
GLubyte *
st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
		     GLuint zoffset, enum pipe_transfer_usage usage,
                     GLuint x, GLuint y, GLuint w, GLuint h)
{
   struct pipe_context *pipe = st->pipe;
   struct pipe_resource *pt = stImage->pt;

   DBG("%s \n", __FUNCTION__);

   stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face,
						    stImage->level, zoffset,
						    usage, x, y, w, h);

   if (stImage->transfer)
      return pipe_transfer_map(pipe, stImage->transfer);
   else
      return NULL;
}
开发者ID:AchironOS,项目名称:chromium.src,代码行数:27,代码来源:st_texture.c

示例13: create_cache_trans

/**
 * Create gallium pipe_transfer object for the bitmap cache.
 */
static void
create_cache_trans(struct st_context *st)
{
    struct pipe_context *pipe = st->pipe;
    struct bitmap_cache *cache = st->bitmap.cache;

    if (cache->trans)
        return;

    /* Map the texture transfer.
     * Subsequent glBitmap calls will write into the texture image.
     */
    cache->buffer = pipe_transfer_map(pipe, cache->texture, 0, 0,
                                      PIPE_TRANSFER_WRITE, 0, 0,
                                      BITMAP_CACHE_WIDTH,
                                      BITMAP_CACHE_HEIGHT, &cache->trans);

    /* init image to all 0xff */
    memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
}
开发者ID:Kalamatee,项目名称:mesa,代码行数:23,代码来源:st_cb_bitmap.c

示例14: st_surface_data

/**
 * 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.
 */
static void
st_surface_data(struct pipe_context *pipe,
		struct pipe_transfer *dst,
		unsigned dstx, unsigned dsty,
		const void *src, unsigned src_stride,
		unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
   void *map = pipe_transfer_map(pipe, dst);

   assert(dst->resource);
   util_copy_rect(map,
                  dst->resource->format,
                  dst->stride,
                  dstx, dsty, 
                  width, height, 
                  src, src_stride, 
                  srcx, srcy);

   pipe_transfer_unmap(pipe, dst);
}
开发者ID:AchironOS,项目名称:chromium.src,代码行数:28,代码来源:st_texture.c

示例15: wsw_dt_get_stride

static boolean
wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
{
   struct pipe_context *pipe = wdt->winsys->pipe;
   struct pipe_resource *tex = wdt->tex;
   struct pipe_transfer *tr;
   void *map;

   map = pipe_transfer_map(pipe, tex, 0, 0,
                           PIPE_TRANSFER_READ_WRITE,
                           0, 0, wdt->tex->width0, wdt->tex->height0, &tr);
   if (!map)
      return FALSE;

   *stride = tr->stride;
   wdt->stride = tr->stride;

   pipe->transfer_unmap(pipe, tr);

   return TRUE;
}
开发者ID:Thermionix,项目名称:Mesa-3D,代码行数:21,代码来源:wrapper_sw_winsys.c


注:本文中的pipe_transfer_map函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。