这篇教程C++ util_format_get_nblocksx函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中util_format_get_nblocksx函数的典型用法代码示例。如果您正苦于以下问题:C++ util_format_get_nblocksx函数的具体用法?C++ util_format_get_nblocksx怎么用?C++ util_format_get_nblocksx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了util_format_get_nblocksx函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: r600_compressed_to_blittablestatic void r600_compressed_to_blittable(struct pipe_resource *tex, unsigned level, struct texture_orig_info *orig){ struct r600_resource_texture *rtex = (struct r600_resource_texture*)tex; struct r600_screen *rscreen = (struct r600_screen *)tex->screen; unsigned pixsize = util_format_get_blocksize(rtex->real_format); int new_format; int new_height, new_width; orig->format = tex->format; orig->width0 = tex->width0; orig->height0 = tex->height0; orig->npix0_x = rtex->surface.level[0].npix_x; orig->npix0_y = rtex->surface.level[0].npix_y; orig->npix_x = rtex->surface.level[level].npix_x; orig->npix_y = rtex->surface.level[level].npix_y; if (pixsize == 8) new_format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */ else new_format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */ new_width = util_format_get_nblocksx(tex->format, orig->width0); new_height = util_format_get_nblocksy(tex->format, orig->height0); tex->width0 = new_width; tex->height0 = new_height; tex->format = new_format; rtex->surface.level[0].npix_x = util_format_get_nblocksx(orig->format, orig->npix0_x); rtex->surface.level[0].npix_y = util_format_get_nblocksy(orig->format, orig->npix0_y); rtex->surface.level[level].npix_x = util_format_get_nblocksx(orig->format, orig->npix_x); rtex->surface.level[level].npix_y = util_format_get_nblocksy(orig->format, orig->npix_y);}
开发者ID:FASTCHIP,项目名称:kernel_3.4.67_lenovo_s939_mtk6592,代码行数:34,
示例2: define_rectstatic INLINE voiddefine_rect(struct pipe_resource *pt, unsigned level, unsigned z, unsigned x, unsigned y, unsigned w, unsigned h, struct nv30_rect *rect){ struct nv30_miptree *mt = nv30_miptree(pt); struct nv30_miptree_level *lvl = &mt->level[level]; rect->w = u_minify(pt->width0, level) << mt->ms_x; rect->w = util_format_get_nblocksx(pt->format, rect->w); rect->h = u_minify(pt->height0, level) << mt->ms_y; rect->h = util_format_get_nblocksy(pt->format, rect->h); rect->d = 1; rect->z = 0; if (mt->swizzled) { if (pt->target == PIPE_TEXTURE_3D) { rect->d = u_minify(pt->depth0, level); rect->z = z; z = 0; } rect->pitch = 0; } else { rect->pitch = lvl->pitch; } rect->bo = mt->base.bo; rect->domain = NOUVEAU_BO_VRAM; rect->offset = layer_offset(pt, level, z); rect->cpp = util_format_get_blocksize(pt->format); rect->x0 = util_format_get_nblocksx(pt->format, x) << mt->ms_x; rect->y0 = util_format_get_nblocksy(pt->format, y) << mt->ms_y; rect->x1 = rect->x0 + (w << mt->ms_x); rect->y1 = rect->y0 + (h << mt->ms_y);}
开发者ID:anupamkaul,项目名称:mesa,代码行数:34,
示例3: r600_resource_copy_regionstatic void r600_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct r600_resource_texture *rsrc = (struct r600_resource_texture*)src; struct texture_orig_info orig_info[2]; struct pipe_box sbox; const struct pipe_box *psbox; boolean restore_orig[2]; memset(orig_info, 0, sizeof(orig_info)); /* Fallback for buffers. */ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { util_resource_copy_region(ctx, dst, dst_level, dstx, dsty, dstz, src, src_level, src_box); return; } if (rsrc->depth && !rsrc->is_flushing_texture) r600_texture_depth_flush(ctx, src, FALSE); restore_orig[0] = restore_orig[1] = FALSE; if (util_format_is_compressed(src->format)) { r600_compressed_to_blittable(src, src_level, &orig_info[0]); restore_orig[0] = TRUE; sbox.x = util_format_get_nblocksx(orig_info[0].format, src_box->x); sbox.y = util_format_get_nblocksy(orig_info[0].format, src_box->y); sbox.z = src_box->z; sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width); sbox.height = util_format_get_nblocksy(orig_info[0].format, src_box->height); sbox.depth = src_box->depth; psbox=&sbox; } else psbox=src_box; if (util_format_is_compressed(dst->format)) { r600_compressed_to_blittable(dst, dst_level, &orig_info[1]); restore_orig[1] = TRUE; /* translate the dst box as well */ dstx = util_format_get_nblocksx(orig_info[1].format, dstx); dsty = util_format_get_nblocksy(orig_info[1].format, dsty); } r600_hw_copy_region(ctx, dst, dst_level, dstx, dsty, dstz, src, src_level, psbox); if (restore_orig[0]) r600_reset_blittable_to_compressed(src, src_level, &orig_info[0]); if (restore_orig[1]) r600_reset_blittable_to_compressed(dst, dst_level, &orig_info[1]);}
开发者ID:FASTCHIP,项目名称:kernel_3.4.67_lenovo_s939_mtk6592,代码行数:58,
示例4: nv30_miptree_transfer_newstatic struct pipe_transfer *nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt, unsigned level, unsigned usage, const struct pipe_box *box){ struct nv30_context *nv30 = nv30_context(pipe); struct nouveau_device *dev = nv30->screen->base.device; struct nv30_transfer *tx; int ret; tx = CALLOC_STRUCT(nv30_transfer); if (!tx) return NULL; pipe_resource_reference(&tx->base.resource, pt); tx->base.level = level; tx->base.usage = usage; tx->base.box = *box; tx->base.stride = util_format_get_nblocksx(pt->format, box->width) * util_format_get_blocksize(pt->format); tx->base.layer_stride = util_format_get_nblocksy(pt->format, box->height) * tx->base.stride; tx->nblocksx = util_format_get_nblocksx(pt->format, box->width); tx->nblocksy = util_format_get_nblocksy(pt->format, box->height); define_rect(pt, level, box->z, box->x, box->y, tx->nblocksx, tx->nblocksy, &tx->img); ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, tx->base.layer_stride, NULL, &tx->tmp.bo); if (ret) { pipe_resource_reference(&tx->base.resource, NULL); FREE(tx); return NULL; } tx->tmp.domain = NOUVEAU_BO_GART; tx->tmp.offset = 0; tx->tmp.pitch = tx->base.stride; tx->tmp.cpp = tx->img.cpp; tx->tmp.w = tx->nblocksx; tx->tmp.h = tx->nblocksy; tx->tmp.d = 1; tx->tmp.x0 = 0; tx->tmp.y0 = 0; tx->tmp.x1 = tx->tmp.w; tx->tmp.y1 = tx->tmp.h; tx->tmp.z = 0; if (usage & PIPE_TRANSFER_READ) nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp); return &tx->base;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:54,
示例5: si_compressed_to_blittablestatic void si_compressed_to_blittable(struct pipe_resource *tex, unsigned level, struct texture_orig_info *orig){ struct r600_texture *rtex = (struct r600_texture*)tex; unsigned pixsize = util_format_get_blocksize(rtex->resource.b.b.format); int new_format; int new_height, new_width; orig->format = tex->format; orig->width0 = tex->width0; orig->height0 = tex->height0; orig->npix0_x = rtex->surface.level[0].npix_x; orig->npix0_y = rtex->surface.level[0].npix_y; orig->npix_x = rtex->surface.level[level].npix_x; orig->npix_y = rtex->surface.level[level].npix_y; if (pixsize == 8) new_format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */ else new_format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */ new_width = util_format_get_nblocksx(tex->format, orig->width0); new_height = util_format_get_nblocksy(tex->format, orig->height0); tex->width0 = new_width; tex->height0 = new_height; tex->format = new_format; rtex->surface.level[0].npix_x = util_format_get_nblocksx(orig->format, orig->npix0_x); rtex->surface.level[0].npix_y = util_format_get_nblocksy(orig->format, orig->npix0_y); rtex->surface.level[level].npix_x = util_format_get_nblocksx(orig->format, orig->npix_x); rtex->surface.level[level].npix_y = util_format_get_nblocksy(orig->format, orig->npix_y); /* By dividing the dimensions by 4, we effectively decrement * last_level by 2, therefore the last 2 mipmap levels disappear and * aren't blittable. Note that the last 3 mipmap levels (4x4, 2x2, * 1x1) have equal slice sizes, which is an important assumption * for this to work. * * In order to make the last 2 mipmap levels blittable, we have to * add the slice size of the last mipmap level to the texture * address, so that even though the hw thinks it reads last_level-2, * it will actually read last_level-1, and if we add the slice size*2, * it will read last_level. That's how this workaround works. */ if (level > rtex->resource.b.b.last_level-2) rtex->mipmap_shift = level - (rtex->resource.b.b.last_level-2);}
开发者ID:Thermionix,项目名称:Mesa-3D,代码行数:48,
示例6: fd3_pipe2nblocksxunsignedfd3_pipe2nblocksx(enum pipe_format format, unsigned width){ if (util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_RGTC) format = PIPE_FORMAT_R8G8B8A8_UNORM; return util_format_get_nblocksx(format, width);}
开发者ID:Unr34ler,项目名称:mesa,代码行数:7,
示例7: i9x5_texture_layout_cube/** * Cube layout used on i915 and for non-compressed textures on i945. */static voidi9x5_texture_layout_cube(struct i915_texture *tex){ struct pipe_resource *pt = &tex->b.b; unsigned width = util_next_power_of_two(pt->width0); const unsigned nblocks = util_format_get_nblocksx(pt->format, width); unsigned level; unsigned face; assert(pt->width0 == pt->height0); /* cubemap images are square */ /* double pitch for cube layouts */ tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4); tex->total_nblocksy = nblocks * 4; for (level = 0; level <= pt->last_level; level++) i915_texture_set_level_info(tex, level, 6); for (face = 0; face < 6; face++) { unsigned x = initial_offsets[face][0] * nblocks; unsigned y = initial_offsets[face][1] * nblocks; unsigned d = nblocks; for (level = 0; level <= pt->last_level; level++) { i915_texture_set_image_offset(tex, level, face, x, y); d >>= 1; x += step_offsets[face][0] * d; y += step_offsets[face][1] * d; } }}
开发者ID:freedesktop-unofficial-mirror,项目名称:openchrome__mesa-openchrome,代码行数:34,
示例8: nv50_miptree_transfer_delvoidnv50_miptree_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx){ struct nv50_transfer *tx = (struct nv50_transfer *)ptx; struct nv50_miptree *mt = nv50_miptree(ptx->resource); struct pipe_resource *pt = ptx->resource; unsigned nx = util_format_get_nblocksx(pt->format, tx->base.box.width); unsigned ny = util_format_get_nblocksy(pt->format, tx->base.box.height); if (ptx->usage & PIPE_TRANSFER_WRITE) { struct pipe_screen *pscreen = pcontext->screen; nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride, tx->bo->tile_mode, 0, 0, 0, tx->nblocksx, tx->nblocksy, 1, mt->base.bo, tx->level_offset, tx->level_pitch, tx->level_tiling, tx->level_x, tx->level_y, tx->level_z, tx->nblocksx, tx->nblocksy, tx->level_depth, util_format_get_blocksize(pt->format), nx, ny, NOUVEAU_BO_GART, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART); } nouveau_bo_ref(NULL, &tx->bo); pipe_resource_reference(&ptx->resource, NULL); FREE(ptx);}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:32,
示例9: trace_dump_box_bytesvoid trace_dump_box_bytes(const void *data, struct pipe_resource *resource, const struct pipe_box *box, unsigned stride, unsigned slice_stride){ size_t size; /* * Only dump buffer transfers to avoid huge files. * TODO: Make this run-time configurable */ if (resource->target != PIPE_BUFFER) { size = 0; } else { enum pipe_format format = resource->format; if (slice_stride) size = box->depth * slice_stride; else if (stride) size = util_format_get_nblocksy(format, box->height) * stride; else { size = util_format_get_nblocksx(format, box->width) * util_format_get_blocksize(format); } } trace_dump_bytes(data, size);}
开发者ID:Distrotech,项目名称:Mesa,代码行数:27,
示例10: i915_miptree_layout_cubestatic voidi915_miptree_layout_cube(struct i915_texture *tex){ struct pipe_texture *pt = &tex->base; unsigned width = pt->width0, height = pt->height0; const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0); unsigned level; unsigned face; assert(width == height); /* cubemap images are square */ /* double pitch for cube layouts */ tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4); tex->total_nblocksy = nblocks * 4; for (level = 0; level <= pt->last_level; level++) { i915_miptree_set_level_info(tex, level, 6, width, height, 1); width /= 2; height /= 2; } for (face = 0; face < 6; face++) { unsigned x = initial_offsets[face][0] * nblocks; unsigned y = initial_offsets[face][1] * nblocks; unsigned d = nblocks; for (level = 0; level <= pt->last_level; level++) { i915_miptree_set_image_offset(tex, level, face, x, y); d >>= 1; x += step_offsets[face][0] * d; y += step_offsets[face][1] * d; } }}
开发者ID:aosm,项目名称:X11libs,代码行数:34,
示例11: debug_dump_surfacevoid debug_dump_surface(const char *prefix, struct pipe_surface *surface) { struct pipe_texture *texture; struct pipe_screen *screen; struct pipe_transfer *transfer; void *data; if (!surface) return; texture = surface->texture; screen = texture->screen; transfer = screen->get_tex_transfer(screen, texture, surface->face, surface->level, surface->zslice, PIPE_TRANSFER_READ, 0, 0, surface->width, surface->height); data = screen->transfer_map(screen, transfer); if(!data) goto error; debug_dump_image(prefix, texture->format, util_format_get_blocksize(texture->format), util_format_get_nblocksx(texture->format, transfer->width), util_format_get_nblocksy(texture->format, transfer->height), transfer->stride, data); screen->transfer_unmap(screen, transfer);error: screen->tex_transfer_destroy(transfer);}
开发者ID:CPFDSoftware-Tony,项目名称:gmv,代码行数:35,
示例12: r600_subsampled_2x1_32bpp_to_blittablestatic void r600_subsampled_2x1_32bpp_to_blittable(struct pipe_resource *tex, unsigned level, struct texture_orig_info *orig){ struct r600_texture *rtex = (struct r600_texture*)tex; orig->format = tex->format; orig->width0 = tex->width0; orig->height0 = tex->height0; orig->npix0_x = rtex->surface.level[0].npix_x; orig->npix0_y = rtex->surface.level[0].npix_y; orig->npix_x = rtex->surface.level[level].npix_x; orig->npix_y = rtex->surface.level[level].npix_y; tex->width0 = util_format_get_nblocksx(orig->format, orig->width0); tex->format = PIPE_FORMAT_R8G8B8A8_UINT; rtex->surface.level[0].npix_x = util_format_get_nblocksx(orig->format, orig->npix0_x); rtex->surface.level[level].npix_x = util_format_get_nblocksx(orig->format, orig->npix_x);}
开发者ID:dezelin,项目名称:mesa,代码行数:19,
示例13: svga_texture_get_handlestatic booleansvga_texture_get_handle(struct pipe_screen *screen, struct pipe_resource *texture, struct winsys_handle *whandle){ struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen); unsigned stride; assert(svga_texture(texture)->key.cachable == 0); svga_texture(texture)->key.cachable = 0; stride = util_format_get_nblocksx(texture->format, texture->width0) * util_format_get_blocksize(texture->format); return sws->surface_get_handle(sws, svga_texture(texture)->handle, stride, whandle);}
开发者ID:nikai3d,项目名称:mesa,代码行数:14,
示例14: trace_dump_box_bytesvoid trace_dump_box_bytes(const void *data, enum pipe_format format, const struct pipe_box *box, unsigned stride, unsigned slice_stride){ size_t size; if (slice_stride) size = box->depth * slice_stride; else if (stride) size = util_format_get_nblocksy(format, box->height) * stride; else { size = util_format_get_nblocksx(format, box->width) * util_format_get_blocksize(format); } trace_dump_bytes(data, size);}
开发者ID:SfietKonstantin,项目名称:radeon-mesa-x86-radeon,代码行数:18,
示例15: r600_texture_get_nblocksxstatic unsigned r600_texture_get_nblocksx(struct pipe_screen *screen, struct r600_resource_texture *rtex, unsigned level){ struct pipe_resource *ptex = &rtex->resource.b.b; unsigned nblocksx, block_align, width; unsigned blocksize = util_format_get_blocksize(rtex->real_format); if (rtex->pitch_override) return rtex->pitch_override / blocksize; width = mip_minify(ptex->width0, level); nblocksx = util_format_get_nblocksx(rtex->real_format, width); block_align = r600_get_block_alignment(screen, rtex->real_format, rtex->array_mode[level]); nblocksx = align(nblocksx, block_align); return nblocksx;}
开发者ID:mslusarz,项目名称:mesa,代码行数:19,
示例16: debug_dump_surface/* FIXME: dump resources, not surfaces... */void debug_dump_surface(struct pipe_context *pipe, const char *prefix, struct pipe_surface *surface){ struct pipe_resource *texture; struct pipe_transfer *transfer; void *data; if (!surface) return; /* XXX: this doesn't necessarily work, as the driver may be using * temporary storage for the surface which hasn't been propagated * back into the texture. Need to nail down the semantics of views * and transfers a bit better before we can say if extra work needs * to be done here: */ texture = surface->texture; transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level, surface->u.tex.first_layer, PIPE_TRANSFER_READ, 0, 0, surface->width, surface->height); data = pipe->transfer_map(pipe, transfer); if(!data) goto error; debug_dump_image(prefix, texture->format, util_format_get_blocksize(texture->format), util_format_get_nblocksx(texture->format, surface->width), util_format_get_nblocksy(texture->format, surface->height), transfer->stride, data); pipe->transfer_unmap(pipe, transfer);error: pipe->transfer_destroy(pipe, transfer);}
开发者ID:GunioRobot,项目名称:mesa-7.10.2-PS3,代码行数:41,
示例17: svga_texture_get_transfer/* XXX: Still implementing this as if it was a screen function, but * can now modify it to queue transfers on the context. */static struct pipe_transfer *svga_texture_get_transfer(struct pipe_context *pipe, struct pipe_resource *texture, unsigned level, unsigned usage, const struct pipe_box *box){ struct svga_context *svga = svga_context(pipe); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st; unsigned nblocksx = util_format_get_nblocksx(texture->format, box->width); unsigned nblocksy = util_format_get_nblocksy(texture->format, box->height); /* We can't map texture storage directly */ if (usage & PIPE_TRANSFER_MAP_DIRECTLY) return NULL; assert(box->depth == 1); st = CALLOC_STRUCT(svga_transfer); if (!st) return NULL; pipe_resource_reference(&st->base.resource, texture); st->base.level = level; st->base.usage = usage; st->base.box = *box; st->base.stride = nblocksx*util_format_get_blocksize(texture->format); st->base.layer_stride = 0; st->hw_nblocksy = nblocksy; st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); while(!st->hwbuf && (st->hw_nblocksy /= 2)) { st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy*st->base.stride); } if(!st->hwbuf) goto no_hwbuf; if(st->hw_nblocksy < nblocksy) { /* We couldn't allocate a hardware buffer big enough for the transfer, * so allocate regular malloc memory instead */ if (0) { debug_printf("%s: failed to allocate %u KB of DMA, " "splitting into %u x %u KB DMA transfers/n", __FUNCTION__, (nblocksy*st->base.stride + 1023)/1024, (nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy, (st->hw_nblocksy*st->base.stride + 1023)/1024); } st->swbuf = MALLOC(nblocksy*st->base.stride); if(!st->swbuf) goto no_swbuf; } if (usage & PIPE_TRANSFER_READ) { SVGA3dSurfaceDMAFlags flags; memset(&flags, 0, sizeof flags); svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM, flags); } return &st->base;no_swbuf: sws->buffer_destroy(sws, st->hwbuf);no_hwbuf: FREE(st); return NULL;}
开发者ID:nikai3d,项目名称:mesa,代码行数:80,
示例18: r600_resource_copy_regionstatic void r600_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct r600_context *rctx = (struct r600_context *)ctx; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; unsigned dst_width, dst_height, src_width0, src_height0, src_widthFL, src_heightFL; unsigned src_force_level = 0; struct pipe_box sbox, dstbox; /* Handle buffers first. */ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { if ((src->bind & PIPE_BIND_GLOBAL) || (dst->bind & PIPE_BIND_GLOBAL)) { r600_copy_global_buffer(ctx, dst, dstx, src, src_box); } else { r600_copy_buffer(ctx, dst, dstx, src, src_box); } return; } assert(u_max_sample(dst) == u_max_sample(src)); /* The driver doesn't decompress resources automatically while * u_blitter is rendering. */ if (!r600_decompress_subresource(ctx, src, src_level, src_box->z, src_box->z + src_box->depth - 1)) { return; /* error */ } dst_width = u_minify(dst->width0, dst_level); dst_height = u_minify(dst->height0, dst_level); src_width0 = src->width0; src_height0 = src->height0; src_widthFL = u_minify(src->width0, src_level); src_heightFL = u_minify(src->height0, src_level); util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz); util_blitter_default_src_texture(&src_templ, src, src_level); if (util_format_is_compressed(src->format)) { unsigned blocksize = util_format_get_blocksize(src->format); if (blocksize == 8) src_templ.format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */ else src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */ dst_templ.format = src_templ.format; dst_width = util_format_get_nblocksx(dst->format, dst_width); dst_height = util_format_get_nblocksy(dst->format, dst_height); src_width0 = util_format_get_nblocksx(src->format, src_width0); src_height0 = util_format_get_nblocksy(src->format, src_height0); src_widthFL = util_format_get_nblocksx(src->format, src_widthFL); src_heightFL = util_format_get_nblocksy(src->format, src_heightFL); dstx = util_format_get_nblocksx(dst->format, dstx); dsty = util_format_get_nblocksy(dst->format, dsty); sbox.x = util_format_get_nblocksx(src->format, src_box->x); sbox.y = util_format_get_nblocksy(src->format, src_box->y); sbox.z = src_box->z; sbox.width = util_format_get_nblocksx(src->format, src_box->width); sbox.height = util_format_get_nblocksy(src->format, src_box->height); sbox.depth = src_box->depth; src_box = &sbox; src_force_level = src_level; } else if (!util_blitter_is_copy_supported(rctx->blitter, dst, src)) { if (util_format_is_subsampled_422(src->format)) { src_templ.format = PIPE_FORMAT_R8G8B8A8_UINT; dst_templ.format = PIPE_FORMAT_R8G8B8A8_UINT; dst_width = util_format_get_nblocksx(dst->format, dst_width); src_width0 = util_format_get_nblocksx(src->format, src_width0); src_widthFL = util_format_get_nblocksx(src->format, src_widthFL); dstx = util_format_get_nblocksx(dst->format, dstx); sbox = *src_box; sbox.x = util_format_get_nblocksx(src->format, src_box->x); sbox.width = util_format_get_nblocksx(src->format, src_box->width); src_box = &sbox; } else { unsigned blocksize = util_format_get_blocksize(src->format); switch (blocksize) { case 1: dst_templ.format = PIPE_FORMAT_R8_UNORM; src_templ.format = PIPE_FORMAT_R8_UNORM; break; case 2: dst_templ.format = PIPE_FORMAT_R8G8_UNORM; src_templ.format = PIPE_FORMAT_R8G8_UNORM;//.........这里部分代码省略.........
开发者ID:iquiw,项目名称:xsrc,代码行数:101,
示例19: r600_resource_copy_regionstatic void r600_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct r600_context *rctx = (struct r600_context *)ctx; struct r600_resource_texture *rsrc = (struct r600_resource_texture*)src; struct texture_orig_info orig_info[2]; struct pipe_box sbox; const struct pipe_box *psbox = src_box; boolean restore_orig[2]; memset(orig_info, 0, sizeof(orig_info)); /* Fallback for buffers. */ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { util_resource_copy_region(ctx, dst, dst_level, dstx, dsty, dstz, src, src_level, src_box); return; } /* This must be done before entering u_blitter to avoid recursion. */ if (rsrc->is_depth && !rsrc->is_flushing_texture) { si_blit_decompress_depth_in_place(rctx, rsrc, src_level, src_level, src_box->z, src_box->z + src_box->depth - 1); } restore_orig[0] = restore_orig[1] = FALSE; if (util_format_is_compressed(src->format) && util_format_is_compressed(dst->format)) { r600_compressed_to_blittable(src, src_level, &orig_info[0]); restore_orig[0] = TRUE; sbox.x = util_format_get_nblocksx(orig_info[0].format, src_box->x); sbox.y = util_format_get_nblocksy(orig_info[0].format, src_box->y); sbox.z = src_box->z; sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width); sbox.height = util_format_get_nblocksy(orig_info[0].format, src_box->height); sbox.depth = src_box->depth; psbox=&sbox; r600_compressed_to_blittable(dst, dst_level, &orig_info[1]); restore_orig[1] = TRUE; /* translate the dst box as well */ dstx = util_format_get_nblocksx(orig_info[1].format, dstx); dsty = util_format_get_nblocksy(orig_info[1].format, dsty); } else if (!util_blitter_is_copy_supported(rctx->blitter, dst, src, PIPE_MASK_RGBAZS)) { unsigned blocksize = util_format_get_blocksize(src->format); switch (blocksize) { case 1: r600_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8_UNORM); r600_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8_UNORM); break; case 4: r600_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8G8B8A8_UNORM); r600_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8G8B8A8_UNORM); break; default: fprintf(stderr, "Unhandled format %s with blocksize %u/n", util_format_short_name(src->format), blocksize); assert(0); } restore_orig[0] = TRUE; restore_orig[1] = TRUE; } r600_blitter_begin(ctx, R600_COPY); util_blitter_copy_texture(rctx->blitter, dst, dst_level, dstx, dsty, dstz, src, src_level, psbox, PIPE_MASK_RGBAZS, TRUE); r600_blitter_end(ctx); if (restore_orig[0]) r600_reset_blittable_to_orig(src, src_level, &orig_info[0]); if (restore_orig[1]) r600_reset_blittable_to_orig(dst, dst_level, &orig_info[1]);}
开发者ID:NSinopoli,项目名称:mesa,代码行数:87,
示例20: llvmpipe_texture_layout/** * Conventional allocation path for non-display textures: * Just compute row strides here. Storage is allocated on demand later. */static booleanllvmpipe_texture_layout(struct llvmpipe_screen *screen, struct llvmpipe_resource *lpr){ struct pipe_resource *pt = &lpr->base; unsigned level; unsigned width = pt->width0; unsigned height = pt->height0; unsigned depth = pt->depth0; size_t total_size = 0; assert(LP_MAX_TEXTURE_2D_LEVELS <= LP_MAX_TEXTURE_LEVELS); assert(LP_MAX_TEXTURE_3D_LEVELS <= LP_MAX_TEXTURE_LEVELS); for (level = 0; level <= pt->last_level; level++) { /* Row stride and image stride (for linear layout) */ { unsigned alignment, nblocksx, nblocksy, block_size; /* For non-compressed formats we need to align the texture size * to the tile size to facilitate render-to-texture. */ if (util_format_is_compressed(pt->format)) alignment = 1; else alignment = TILE_SIZE; nblocksx = util_format_get_nblocksx(pt->format, align(width, alignment)); nblocksy = util_format_get_nblocksy(pt->format, align(height, alignment)); block_size = util_format_get_blocksize(pt->format); lpr->row_stride[level] = align(nblocksx * block_size, 16); lpr->img_stride[level] = lpr->row_stride[level] * nblocksy; } /* Size of the image in tiles (for tiled layout) */ { const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; lpr->tiles_per_row[level] = width_t; lpr->tiles_per_image[level] = width_t * height_t; } /* Number of 3D image slices or cube faces */ { unsigned num_slices; if (lpr->base.target == PIPE_TEXTURE_CUBE) num_slices = 6; else if (lpr->base.target == PIPE_TEXTURE_3D) num_slices = depth; else num_slices = 1; lpr->num_slices_faces[level] = num_slices; lpr->layout[level] = alloc_layout_array(num_slices, width, height); if (!lpr->layout[level]) { goto fail; } } total_size += lpr->num_slices_faces[level] * lpr->img_stride[level]; if (total_size > LP_MAX_TEXTURE_SIZE) { goto fail; } /* Compute size of next mipmap level */ width = u_minify(width, 1); height = u_minify(height, 1); depth = u_minify(depth, 1); } return TRUE;fail: for (level = 0; level <= pt->last_level; level++) { FREE(lpr->layout[level]); } return FALSE;}
开发者ID:ideak,项目名称:mesa,代码行数:90,
示例21: nvc0_resource_copy_regionstatic voidnvc0_resource_copy_region(struct pipe_context *pipe, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct nvc0_context *nvc0 = nvc0_context(pipe); int ret; boolean m2mf; unsigned dst_layer = dstz, src_layer = src_box->z; if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { nouveau_copy_buffer(&nvc0->base, nv04_resource(dst), dstx, nv04_resource(src), src_box->x, src_box->width); NOUVEAU_DRV_STAT(&nvc0->screen->base, buf_copy_bytes, src_box->width); return; } NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_copy_count, 1); /* 0 and 1 are equal, only supporting 0/1, 2, 4 and 8 */ assert((src->nr_samples | 1) == (dst->nr_samples | 1)); m2mf = (src->format == dst->format) || (util_format_get_blocksizebits(src->format) == util_format_get_blocksizebits(dst->format)); nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING; if (m2mf) { struct nv50_m2mf_rect drect, srect; unsigned i; unsigned nx = util_format_get_nblocksx(src->format, src_box->width); unsigned ny = util_format_get_nblocksy(src->format, src_box->height); nv50_m2mf_rect_setup(&drect, dst, dst_level, dstx, dsty, dstz); nv50_m2mf_rect_setup(&srect, src, src_level, src_box->x, src_box->y, src_box->z); for (i = 0; i < src_box->depth; ++i) { nvc0->m2mf_copy_rect(nvc0, &drect, &srect, nx, ny); if (nv50_miptree(dst)->layout_3d) drect.z++; else drect.base += nv50_miptree(dst)->layer_stride; if (nv50_miptree(src)->layout_3d) srect.z++; else srect.base += nv50_miptree(src)->layer_stride; } return; } assert(nv50_2d_dst_format_faithful(dst->format)); assert(nv50_2d_src_format_faithful(src->format)); BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(src), RD); BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(dst), WR); nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx); nouveau_pushbuf_validate(nvc0->base.pushbuf); for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { ret = nvc0_2d_texture_do_copy(nvc0->base.pushbuf, nv50_miptree(dst), dst_level, dstx, dsty, dst_layer, nv50_miptree(src), src_level, src_box->x, src_box->y, src_layer, src_box->width, src_box->height); if (ret) break; } nouveau_bufctx_reset(nvc0->bufctx, 0);}
开发者ID:rafalmiel,项目名称:mesa,代码行数:76,
示例22: i945_texture_layout_2dstatic voidi945_texture_layout_2d(struct i915_texture *tex){ struct pipe_resource *pt = &tex->b.b; int align_x = 4, align_y = 2; unsigned level; unsigned x = 0; unsigned y = 0; unsigned width = util_next_power_of_two(pt->width0); unsigned height = util_next_power_of_two(pt->height0); unsigned nblocksx = util_format_get_nblocksx(pt->format, width); unsigned nblocksy = util_format_get_nblocksy(pt->format, height); if (util_format_is_s3tc(pt->format)) { align_x = 1; align_y = 1; } tex->stride = align(util_format_get_stride(pt->format, width), 4); /* May need to adjust pitch to accomodate the placement of * the 2nd mipmap level. This occurs when the alignment * constraints of mipmap placement push the right edge of the * 2nd mipmap level out past the width of its parent. */ if (pt->last_level > 0) { unsigned mip1_nblocksx = align_nblocksx(pt->format, u_minify(width, 1), align_x) + util_format_get_nblocksx(pt->format, u_minify(width, 2)); if (mip1_nblocksx > nblocksx) tex->stride = mip1_nblocksx * util_format_get_blocksize(pt->format); } /* Pitch must be a whole number of dwords */ tex->stride = align(tex->stride, 64); tex->total_nblocksy = 0; for (level = 0; level <= pt->last_level; level++) { i915_texture_set_level_info(tex, level, 1); i915_texture_set_image_offset(tex, level, 0, x, y); /* Because the images are packed better, the final offset * might not be the maximal one: */ tex->total_nblocksy = MAX2(tex->total_nblocksy, y + nblocksy); /* Layout_below: step right after second mipmap level. */ if (level == 1) { x += nblocksx; } else { y += nblocksy; } width = u_minify(width, 1); height = u_minify(height, 1); nblocksx = align_nblocksx(pt->format, width, align_x); nblocksy = align_nblocksy(pt->format, height, align_y); }}
开发者ID:freedesktop-unofficial-mirror,项目名称:openchrome__mesa-openchrome,代码行数:62,
示例23: align_nblocksxstatic INLINE unsignedalign_nblocksx(enum pipe_format format, unsigned width, unsigned align_to){ return align(util_format_get_nblocksx(format, width), align_to);}
开发者ID:freedesktop-unofficial-mirror,项目名称:openchrome__mesa-openchrome,代码行数:5,
示例24: si_resource_copy_regionstatic void si_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct si_context *sctx = (struct si_context *)ctx; struct r600_texture *rdst = (struct r600_texture*)dst; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; struct texture_orig_info orig_info[2]; struct pipe_box sbox, dstbox; boolean restore_orig[2]; /* Fallback for buffers. */ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { si_copy_buffer(sctx, dst, src, dstx, src_box->x, src_box->width); return; } memset(orig_info, 0, sizeof(orig_info)); /* The driver doesn't decompress resources automatically while * u_blitter is rendering. */ si_decompress_subresource(ctx, src, src_level, src_box->z, src_box->z + src_box->depth - 1); restore_orig[0] = restore_orig[1] = FALSE; if (util_format_is_compressed(src->format) && util_format_is_compressed(dst->format)) { si_compressed_to_blittable(src, src_level, &orig_info[0]); restore_orig[0] = TRUE; sbox.x = util_format_get_nblocksx(orig_info[0].format, src_box->x); sbox.y = util_format_get_nblocksy(orig_info[0].format, src_box->y); sbox.z = src_box->z; sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width); sbox.height = util_format_get_nblocksy(orig_info[0].format, src_box->height); sbox.depth = src_box->depth; src_box = &sbox; si_compressed_to_blittable(dst, dst_level, &orig_info[1]); restore_orig[1] = TRUE; /* translate the dst box as well */ dstx = util_format_get_nblocksx(orig_info[1].format, dstx); dsty = util_format_get_nblocksy(orig_info[1].format, dsty); } else if (!util_blitter_is_copy_supported(sctx->blitter, dst, src)) { if (util_format_is_subsampled_422(src->format)) { /* XXX untested */ si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8G8B8A8_UINT); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8G8B8A8_UINT); sbox = *src_box; sbox.x = util_format_get_nblocksx(orig_info[0].format, src_box->x); sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width); src_box = &sbox; dstx = util_format_get_nblocksx(orig_info[1].format, dstx); restore_orig[0] = TRUE; restore_orig[1] = TRUE; } else { unsigned blocksize = util_format_get_blocksize(src->format); switch (blocksize) { case 1: si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8_UNORM); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8_UNORM); break; case 2: si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8G8_UNORM); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8G8_UNORM); break; case 4: si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R8G8B8A8_UNORM); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R8G8B8A8_UNORM); break; case 8: si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R16G16B16A16_UINT); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R16G16B16A16_UINT); break; case 16: si_change_format(src, src_level, &orig_info[0], PIPE_FORMAT_R32G32B32A32_UINT); si_change_format(dst, dst_level, &orig_info[1], PIPE_FORMAT_R32G32B32A32_UINT); break; default: fprintf(stderr, "Unhandled format %s with blocksize %u/n",//.........这里部分代码省略.........
开发者ID:Thermionix,项目名称:Mesa-3D,代码行数:101,
示例25: svga_texture_transfer_map_direct/** * Use direct map for the transfer request */static void *svga_texture_transfer_map_direct(struct svga_context *svga, struct svga_transfer *st){ struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws; struct pipe_transfer *transfer = &st->base; struct pipe_resource *texture = transfer->resource; struct svga_texture *tex = svga_texture(texture); struct svga_winsys_surface *surf = tex->handle; unsigned level = st->base.level; unsigned w, h, nblocksx, nblocksy, i; unsigned usage = st->base.usage; if (need_tex_readback(st)) { enum pipe_error ret; svga_surfaces_flush(svga); for (i = 0; i < st->box.d; i++) { if (svga_have_vgpu10(svga)) { ret = readback_image_vgpu10(svga, surf, st->slice + i, level, tex->b.b.last_level + 1); } else { ret = readback_image_vgpu9(svga, surf, st->slice + i, level); } } svga->hud.num_readbacks++; SVGA_STATS_COUNT_INC(sws, SVGA_STATS_COUNT_TEXREADBACK); assert(ret == PIPE_OK); (void) ret; svga_context_flush(svga, NULL); /* * Note: if PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE were specified * we could potentially clear the flag for all faces/layers/mips. */ svga_clear_texture_rendered_to(tex, st->slice, level); } else { assert(usage & PIPE_TRANSFER_WRITE); if ((usage & PIPE_TRANSFER_UNSYNCHRONIZED) == 0) { if (svga_is_texture_dirty(tex, st->slice, level)) { /* * do a surface flush if the subresource has been modified * in this command buffer. */ svga_surfaces_flush(svga); if (!sws->surface_is_flushed(sws, surf)) { svga->hud.surface_write_flushes++; SVGA_STATS_COUNT_INC(sws, SVGA_STATS_COUNT_SURFACEWRITEFLUSH); svga_context_flush(svga, NULL); } } } } /* we'll directly access the guest-backed surface */ w = u_minify(texture->width0, level); h = u_minify(texture->height0, level); nblocksx = util_format_get_nblocksx(texture->format, w); nblocksy = util_format_get_nblocksy(texture->format, h); st->hw_nblocksy = nblocksy; st->base.stride = nblocksx*util_format_get_blocksize(texture->format); st->base.layer_stride = st->base.stride * nblocksy; /* * Begin mapping code */ { SVGA3dSize baseLevelSize; uint8_t *map; boolean retry; unsigned offset, mip_width, mip_height; map = svga->swc->surface_map(svga->swc, surf, usage, &retry); if (map == NULL && retry) { /* * At this point, the svga_surfaces_flush() should already have * called in svga_texture_get_transfer(). */ svga->hud.surface_write_flushes++; svga_context_flush(svga, NULL); map = svga->swc->surface_map(svga->swc, surf, usage, &retry); } /* * Make sure we return NULL if the map fails */ if (!map) { return NULL; } /** * Compute the offset to the specific texture slice in the buffer. */ baseLevelSize.width = tex->b.b.width0;//.........这里部分代码省略.........
开发者ID:ChristophHaag,项目名称:mesa-mesa,代码行数:101,
示例26: svga_texture_transfer_map_dma/** * Use DMA for the transfer request */static void *svga_texture_transfer_map_dma(struct svga_context *svga, struct svga_transfer *st){ struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws; struct pipe_resource *texture = st->base.resource; unsigned nblocksx, nblocksy; unsigned d; unsigned usage = st->base.usage; /* we'll put the data into a tightly packed buffer */ nblocksx = util_format_get_nblocksx(texture->format, st->box.w); nblocksy = util_format_get_nblocksy(texture->format, st->box.h); d = st->box.d; st->base.stride = nblocksx*util_format_get_blocksize(texture->format); st->base.layer_stride = st->base.stride * nblocksy; st->hw_nblocksy = nblocksy; st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy * st->base.stride * d); while (!st->hwbuf && (st->hw_nblocksy /= 2)) { st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy * st->base.stride * d); } if (!st->hwbuf) return NULL; if (st->hw_nblocksy < nblocksy) { /* We couldn't allocate a hardware buffer big enough for the transfer, * so allocate regular malloc memory instead */ if (0) { debug_printf("%s: failed to allocate %u KB of DMA, " "splitting into %u x %u KB DMA transfers/n", __FUNCTION__, (nblocksy * st->base.stride + 1023) / 1024, (nblocksy + st->hw_nblocksy - 1) / st->hw_nblocksy, (st->hw_nblocksy * st->base.stride + 1023) / 1024); } st->swbuf = MALLOC(nblocksy * st->base.stride * d); if (!st->swbuf) { sws->buffer_destroy(sws, st->hwbuf); return NULL; } } if (usage & PIPE_TRANSFER_READ) { SVGA3dSurfaceDMAFlags flags; memset(&flags, 0, sizeof flags); svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM, flags); } if (st->swbuf) { return st->swbuf; } else { return sws->buffer_map(sws, st->hwbuf, usage); }}
开发者ID:ChristophHaag,项目名称:mesa-mesa,代码行数:67,
示例27: nv50_resource_copy_regionstatic voidnv50_resource_copy_region(struct pipe_context *pipe, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box){ struct nv50_screen *screen = nv50_context(pipe)->screen; int ret; boolean m2mf; unsigned dst_layer = dstz, src_layer = src_box->z; /* Fallback for buffers. */ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz, src, src_level, src_box); return; } assert(src->nr_samples == dst->nr_samples); m2mf = (src->format == dst->format) || (util_format_get_blocksizebits(src->format) == util_format_get_blocksizebits(dst->format)); nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING; if (m2mf) { struct nv50_m2mf_rect drect, srect; unsigned i; unsigned nx = util_format_get_nblocksx(src->format, src_box->width); unsigned ny = util_format_get_nblocksy(src->format, src_box->height); nv50_m2mf_rect_setup(&drect, dst, dst_level, dstx, dsty, dstz); nv50_m2mf_rect_setup(&srect, src, src_level, src_box->x, src_box->y, src_box->z); for (i = 0; i < src_box->depth; ++i) { nv50_m2mf_transfer_rect(&screen->base.base, &drect, &srect, nx, ny); if (nv50_miptree(dst)->layout_3d) drect.z++; else drect.base += nv50_miptree(dst)->layer_stride; if (nv50_miptree(src)->layout_3d) srect.z++; else srect.base += nv50_miptree(src)->layer_stride; } return; } assert((src->format == dst->format) || (nv50_2d_format_faithful(src->format) && nv50_2d_format_faithful(dst->format))); for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { ret = nv50_2d_texture_do_copy(screen->base.channel, nv50_miptree(dst), dst_level, dstx, dsty, dst_layer, nv50_miptree(src), src_level, src_box->x, src_box->y, src_layer, src_box->width, src_box->height); if (ret) return; }}
开发者ID:nikai3d,项目名称:mesa,代码行数:68,
示例28: nv30_miptree_createstruct pipe_resource *nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *tmpl){ struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct nv30_miptree *mt = CALLOC_STRUCT(nv30_miptree); struct pipe_resource *pt = &mt->base.base; unsigned blocksz, size; unsigned w, h, d, l; int ret; switch (tmpl->nr_samples) { case 4: mt->ms_mode = 0x00004000; mt->ms_x = 1; mt->ms_y = 1; break; case 2: mt->ms_mode = 0x00003000; mt->ms_x = 1; mt->ms_y = 0; break; default: mt->ms_mode = 0x00000000; mt->ms_x = 0; mt->ms_y = 0; break; } mt->base.vtbl = &nv30_miptree_vtbl; *pt = *tmpl; pipe_reference_init(&pt->reference, 1); pt->screen = pscreen; w = pt->width0 << mt->ms_x; h = pt->height0 << mt->ms_y; d = (pt->target == PIPE_TEXTURE_3D) ? pt->depth0 : 1; blocksz = util_format_get_blocksize(pt->format); if ((pt->target == PIPE_TEXTURE_RECT) || !util_is_power_of_two(pt->width0) || !util_is_power_of_two(pt->height0) || !util_is_power_of_two(pt->depth0) || util_format_is_compressed(pt->format) || util_format_is_float(pt->format) || mt->ms_mode) { mt->uniform_pitch = util_format_get_nblocksx(pt->format, w) * blocksz; mt->uniform_pitch = align(mt->uniform_pitch, 64); } if (!mt->uniform_pitch) mt->swizzled = TRUE; size = 0; for (l = 0; l <= pt->last_level; l++) { struct nv30_miptree_level *lvl = &mt->level[l]; unsigned nbx = util_format_get_nblocksx(pt->format, w); unsigned nby = util_format_get_nblocksx(pt->format, h); lvl->offset = size; lvl->pitch = mt->uniform_pitch; if (!lvl->pitch) lvl->pitch = nbx * blocksz; lvl->zslice_size = lvl->pitch * nby; size += lvl->zslice_size * d; w = u_minify(w, 1); h = u_minify(h, 1); d = u_minify(d, 1); } mt->layer_size = size; if (pt->target == PIPE_TEXTURE_CUBE) { if (!mt->uniform_pitch) mt->layer_size = align(mt->layer_size, 128); size = mt->layer_size * 6; } ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 256, size, NULL, &mt->base.bo); if (ret) { FREE(mt); return NULL; } mt->base.domain = NOUVEAU_BO_VRAM; return &mt->base.base;}
开发者ID:anupamkaul,项目名称:mesa,代码行数:87,
示例29: svga_texture_transfer_mapstatic void *svga_texture_transfer_map(struct pipe_context *pipe, struct pipe_resource *texture, unsigned level, unsigned usage, const struct pipe_box *box, struct pipe_transfer **ptransfer){ struct svga_context *svga = svga_context(pipe); struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_texture *tex = svga_texture(texture); struct svga_transfer *st; unsigned nblocksx, nblocksy; boolean use_direct_map = svga_have_gb_objects(svga) && !svga_have_gb_dma(svga); unsigned d; void *returnVal; int64_t begin = os_time_get(); /* We can't map texture storage directly unless we have GB objects */ if (usage & PIPE_TRANSFER_MAP_DIRECTLY) { if (svga_have_gb_objects(svga)) use_direct_map = TRUE; else return NULL; } st = CALLOC_STRUCT(svga_transfer); if (!st) return NULL; { unsigned w, h; if (use_direct_map) { /* we'll directly access the guest-backed surface */ w = u_minify(texture->width0, level); h = u_minify(texture->height0, level); d = u_minify(texture->depth0, level); } else { /* we'll put the data into a tightly packed buffer */ w = box->width; h = box->height; d = box->depth; } nblocksx = util_format_get_nblocksx(texture->format, w); nblocksy = util_format_get_nblocksy(texture->format, h); } pipe_resource_reference(&st->base.resource, texture); st->base.level = level; st->base.usage = usage; st->base.box = *box; st->base.stride = nblocksx*util_format_get_blocksize(texture->format); st->base.layer_stride = st->base.stride * nblocksy; switch (tex->b.b.target) { case PIPE_TEXTURE_CUBE: case PIPE_TEXTURE_2D_ARRAY: case PIPE_TEXTURE_1D_ARRAY: st->slice = st->base.box.z; st->base.box.z = 0; /* so we don't apply double offsets below */ break; default: st->slice = 0; break; } if (usage & PIPE_TRANSFER_WRITE) { /* record texture upload for HUD */ svga->hud.num_bytes_uploaded += nblocksx * nblocksy * d * util_format_get_blocksize(texture->format); } if (!use_direct_map) { /* Use a DMA buffer */ st->hw_nblocksy = nblocksy; st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy * st->base.stride * d); while(!st->hwbuf && (st->hw_nblocksy /= 2)) { st->hwbuf = svga_winsys_buffer_create(svga, 1, 0, st->hw_nblocksy * st->base.stride * d); } if (!st->hwbuf) { FREE(st); return NULL; } if (st->hw_nblocksy < nblocksy) { /* We couldn't allocate a hardware buffer big enough for the transfer, * so allocate regular malloc memory instead */ if (0) { debug_printf("%s: failed to allocate %u KB of DMA, " "splitting into %u x %u KB DMA transfers/n", __FUNCTION__, (nblocksy*st->base.stride + 1023)/1024,//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:Mesa,代码行数:101,
示例30: fd5_sampler_view_createstatic struct pipe_sampler_view *fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, const struct pipe_sampler_view *cso){ struct fd5_pipe_sampler_view *so = CALLOC_STRUCT(fd5_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); enum pipe_format format = cso->format; unsigned lvl, layers = 0; if (!so) return NULL; if (format == PIPE_FORMAT_X32_S8X24_UINT) { rsc = rsc->stencil; format = rsc->base.format; } so->base = *cso; pipe_reference(NULL, &prsc->reference); so->base.texture = prsc; so->base.reference.count = 1; so->base.context = pctx; so->texconst0 = A5XX_TEX_CONST_0_FMT(fd5_pipe2tex(format)) | A5XX_TEX_CONST_0_SAMPLES(fd_msaa_samples(prsc->nr_samples)) | fd5_tex_swiz(format, cso->swizzle_r, cso->swizzle_g, cso->swizzle_b, cso->swizzle_a); /* NOTE: since we sample z24s8 using 8888_UINT format, the swizzle * we get isn't quite right. Use SWAP(XYZW) as a cheap and cheerful * way to re-arrange things so stencil component is where the swiz * expects. * * Note that gallium expects stencil sampler to return (s,s,s,s) * which isn't quite true. To make that happen we'd have to massage * the swizzle. But in practice only the .x component is used. */ if (format == PIPE_FORMAT_X24S8_UINT) { so->texconst0 |= A5XX_TEX_CONST_0_SWAP(XYZW); } if (util_format_is_srgb(format)) { if (use_astc_srgb_workaround(pctx, format)) so->astc_srgb = true; so->texconst0 |= A5XX_TEX_CONST_0_SRGB; } if (cso->target == PIPE_BUFFER) { unsigned elements = cso->u.buf.size / util_format_get_blocksize(format); lvl = 0; so->texconst1 = A5XX_TEX_CONST_1_WIDTH(elements) | A5XX_TEX_CONST_1_HEIGHT(1); so->texconst2 = A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) | A5XX_TEX_CONST_2_PITCH(elements * rsc->cpp); so->offset = cso->u.buf.offset; } else { unsigned miplevels; lvl = fd_sampler_first_level(cso); miplevels = fd_sampler_last_level(cso) - lvl; layers = cso->u.tex.last_layer - cso->u.tex.first_layer + 1; so->texconst0 |= A5XX_TEX_CONST_0_MIPLVLS(miplevels); so->texconst1 = A5XX_TEX_CONST_1_WIDTH(u_minify(prsc->width0, lvl)) | A5XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl)); so->texconst2 = A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) | A5XX_TEX_CONST_2_PITCH( util_format_get_nblocksx( format, rsc->slices[lvl].pitch) * rsc->cpp); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); } so->texconst2 |= A5XX_TEX_CONST_2_TYPE(fd5_tex_type(cso->target)); switch (cso->target) { case PIPE_TEXTURE_RECT: case PIPE_TEXTURE_1D: case PIPE_TEXTURE_2D: so->texconst3 = A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size); so->texconst5 = A5XX_TEX_CONST_5_DEPTH(1); break; case PIPE_TEXTURE_1D_ARRAY: case PIPE_TEXTURE_2D_ARRAY: so->texconst3 = A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size); so->texconst5 = A5XX_TEX_CONST_5_DEPTH(layers); break; case PIPE_TEXTURE_CUBE: case PIPE_TEXTURE_CUBE_ARRAY: so->texconst3 = A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);//.........这里部分代码省略.........
开发者ID:FireBurn,项目名称:mesa,代码行数:101,
注:本文中的util_format_get_nblocksx函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ util_format_get_nblocksy函数代码示例 C++ util_format_get_blockwidth函数代码示例 |