本文整理汇总了C++中pipe_resource_reference函数的典型用法代码示例。如果您正苦于以下问题:C++ pipe_resource_reference函数的具体用法?C++ pipe_resource_reference怎么用?C++ pipe_resource_reference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pipe_resource_reference函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cso_destroy_context
/**
* Free the CSO context.
*/
void cso_destroy_context( struct cso_context *ctx )
{
unsigned i;
if (ctx->pipe) {
ctx->pipe->set_index_buffer(ctx->pipe, NULL);
ctx->pipe->bind_blend_state( ctx->pipe, NULL );
ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL );
{
static struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] = { NULL };
static void *zeros[PIPE_MAX_SAMPLERS] = { NULL };
struct pipe_screen *scr = ctx->pipe->screen;
unsigned sh;
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
int maxsam = scr->get_shader_param(scr, sh,
PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
int maxview = scr->get_shader_param(scr, sh,
PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS);
assert(maxsam <= PIPE_MAX_SAMPLERS);
assert(maxview <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
if (maxsam > 0) {
ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros);
}
if (maxview > 0) {
ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, views);
}
}
}
ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL );
ctx->pipe->bind_fs_state( ctx->pipe, NULL );
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, NULL);
ctx->pipe->bind_vs_state( ctx->pipe, NULL );
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, NULL);
if (ctx->has_geometry_shader) {
ctx->pipe->bind_gs_state(ctx->pipe, NULL);
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_GEOMETRY, 0, NULL);
}
if (ctx->has_tessellation) {
ctx->pipe->bind_tcs_state(ctx->pipe, NULL);
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_TESS_CTRL, 0, NULL);
ctx->pipe->bind_tes_state(ctx->pipe, NULL);
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_TESS_EVAL, 0, NULL);
}
ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL );
if (ctx->has_streamout)
ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, NULL);
}
for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
pipe_sampler_view_reference(&ctx->fragment_views[i], NULL);
pipe_sampler_view_reference(&ctx->fragment_views_saved[i], NULL);
}
util_unreference_framebuffer_state(&ctx->fb);
util_unreference_framebuffer_state(&ctx->fb_saved);
pipe_resource_reference(&ctx->aux_vertex_buffer_current.buffer, NULL);
pipe_resource_reference(&ctx->aux_vertex_buffer_saved.buffer, NULL);
for (i = 0; i < PIPE_SHADER_TYPES; i++) {
pipe_resource_reference(&ctx->aux_constbuf_current[i].buffer, NULL);
pipe_resource_reference(&ctx->aux_constbuf_saved[i].buffer, NULL);
}
for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) {
pipe_so_target_reference(&ctx->so_targets[i], NULL);
pipe_so_target_reference(&ctx->so_targets_saved[i], NULL);
}
if (ctx->cache) {
cso_cache_delete( ctx->cache );
ctx->cache = NULL;
}
if (ctx->vbuf)
u_vbuf_destroy(ctx->vbuf);
FREE( ctx );
}
开发者ID:Distrotech,项目名称:Mesa,代码行数:85,代码来源:cso_context.c
示例2: st_context_teximage
static boolean
st_context_teximage(struct st_context_iface *stctxi,
enum st_texture_type tex_type,
int level, enum pipe_format pipe_format,
struct pipe_resource *tex, boolean mipmap)
{
struct st_context *st = (struct st_context *) stctxi;
struct gl_context *ctx = st->ctx;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
struct st_texture_object *stObj;
struct st_texture_image *stImage;
GLenum internalFormat;
GLuint width, height, depth;
GLenum target;
switch (tex_type) {
case ST_TEXTURE_1D:
target = GL_TEXTURE_1D;
break;
case ST_TEXTURE_2D:
target = GL_TEXTURE_2D;
break;
case ST_TEXTURE_3D:
target = GL_TEXTURE_3D;
break;
case ST_TEXTURE_RECT:
target = GL_TEXTURE_RECTANGLE_ARB;
break;
default:
return FALSE;
}
texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
stObj = st_texture_object(texObj);
/* switch to surface based */
if (!stObj->surface_based) {
_mesa_clear_texture_object(ctx, texObj);
stObj->surface_based = GL_TRUE;
}
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
stImage = st_texture_image(texImage);
if (tex) {
mesa_format texFormat = st_pipe_format_to_mesa_format(pipe_format);
if (util_format_has_alpha(tex->format))
internalFormat = GL_RGBA;
else
internalFormat = GL_RGB;
_mesa_init_teximage_fields(ctx, texImage,
tex->width0, tex->height0, 1, 0,
internalFormat, texFormat);
width = tex->width0;
height = tex->height0;
depth = tex->depth0;
/* grow the image size until we hit level = 0 */
while (level > 0) {
if (width != 1)
width <<= 1;
if (height != 1)
height <<= 1;
if (depth != 1)
depth <<= 1;
level--;
}
}
else {
_mesa_clear_texture_image(ctx, texImage);
width = height = depth = 0;
}
pipe_resource_reference(&stImage->pt, tex);
stObj->width0 = width;
stObj->height0 = height;
stObj->depth0 = depth;
stObj->surface_format = pipe_format;
_mesa_dirty_texobj(ctx, texObj);
_mesa_unlock_texture(ctx, texObj);
return TRUE;
}
开发者ID:maurossi,项目名称:mesa-mesa,代码行数:89,代码来源:st_manager.c
示例3: r300_get_tex_surface
/* Not required to implement u_resource_vtbl, consider moving to another file:
*/
struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
struct pipe_resource* texture,
unsigned face,
unsigned level,
unsigned zslice,
unsigned flags)
{
struct r300_texture* tex = r300_texture(texture);
struct r300_surface* surface = CALLOC_STRUCT(r300_surface);
if (surface) {
uint32_t offset, tile_height;
pipe_reference_init(&surface->base.reference, 1);
pipe_resource_reference(&surface->base.texture, texture);
surface->base.format = texture->format;
surface->base.width = u_minify(texture->width0, level);
surface->base.height = u_minify(texture->height0, level);
surface->base.usage = flags;
surface->base.zslice = zslice;
surface->base.face = face;
surface->base.level = level;
surface->buffer = tex->buffer;
/* Prefer VRAM if there are multiple domains to choose from. */
surface->domain = tex->domain;
if (surface->domain & R300_DOMAIN_VRAM)
surface->domain &= ~R300_DOMAIN_GTT;
surface->offset = r300_texture_get_offset(&tex->desc,
level, zslice, face);
surface->pitch = tex->fb_state.pitch[level];
surface->format = tex->fb_state.format;
/* Parameters for the CBZB clear. */
surface->cbzb_allowed = tex->desc.cbzb_allowed[level];
surface->cbzb_width = align(surface->base.width, 64);
/* Height must be aligned to the size of a tile. */
tile_height = r300_get_pixel_alignment(tex->desc.b.b.format,
tex->desc.b.b.nr_samples,
tex->desc.microtile,
tex->desc.macrotile[level],
DIM_HEIGHT, 0);
surface->cbzb_height = align((surface->base.height + 1) / 2,
tile_height);
/* Offset must be aligned to 2K and must point at the beginning
* of a scanline. */
offset = surface->offset +
tex->desc.stride_in_bytes[level] * surface->cbzb_height;
surface->cbzb_midpoint_offset = offset & ~2047;
surface->cbzb_pitch = surface->pitch & 0x1ffffc;
if (util_format_get_blocksizebits(surface->base.format) == 32)
surface->cbzb_format = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
else
surface->cbzb_format = R300_DEPTHFORMAT_16BIT_INT_Z;
SCREEN_DBG(r300_screen(screen), DBG_CBZB,
"CBZB Allowed: %s, Dim: %ix%i, Misalignment: %i, Micro: %s, Macro: %s\n",
surface->cbzb_allowed ? "YES" : " NO",
surface->cbzb_width, surface->cbzb_height,
offset & 2047,
tex->desc.microtile ? "YES" : " NO",
tex->desc.macrotile[level] ? "YES" : " NO");
}
return &surface->base;
}
开发者ID:EMGD-Community,项目名称:mesa,代码行数:75,代码来源:r300_texture.c
示例4: 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,代码来源:svga_resource_texture.c
示例5: lp_setup_set_fragment_sampler_views
/**
* Called during state validation when LP_NEW_SAMPLER_VIEW is set.
*/
void
lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
unsigned num,
struct pipe_sampler_view **views)
{
unsigned i;
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
struct pipe_sampler_view *view = i < num ? views[i] : NULL;
if (view) {
struct pipe_resource *res = view->texture;
struct llvmpipe_resource *lp_tex = llvmpipe_resource(res);
struct lp_jit_texture *jit_tex;
jit_tex = &setup->fs.current.jit_context.textures[i];
/* We're referencing the texture's internal data, so save a
* reference to it.
*/
pipe_resource_reference(&setup->fs.current_tex[i], res);
if (!lp_tex->dt) {
/* regular texture - setup array of mipmap level offsets */
int j;
unsigned first_level = 0;
unsigned last_level = 0;
if (llvmpipe_resource_is_texture(res)) {
first_level = view->u.tex.first_level;
last_level = view->u.tex.last_level;
assert(first_level <= last_level);
assert(last_level <= res->last_level);
jit_tex->base = lp_tex->tex_data;
}
else {
jit_tex->base = lp_tex->data;
}
if (LP_PERF & PERF_TEX_MEM) {
/* use dummy tile memory */
jit_tex->base = lp_dummy_tile;
jit_tex->width = TILE_SIZE/8;
jit_tex->height = TILE_SIZE/8;
jit_tex->depth = 1;
jit_tex->first_level = 0;
jit_tex->last_level = 0;
jit_tex->mip_offsets[0] = 0;
jit_tex->row_stride[0] = 0;
jit_tex->img_stride[0] = 0;
}
else {
jit_tex->width = res->width0;
jit_tex->height = res->height0;
jit_tex->depth = res->depth0;
jit_tex->first_level = first_level;
jit_tex->last_level = last_level;
if (llvmpipe_resource_is_texture(res)) {
for (j = first_level; j <= last_level; j++) {
jit_tex->mip_offsets[j] = lp_tex->mip_offsets[j];
jit_tex->row_stride[j] = lp_tex->row_stride[j];
jit_tex->img_stride[j] = lp_tex->img_stride[j];
}
if (res->target == PIPE_TEXTURE_1D_ARRAY ||
res->target == PIPE_TEXTURE_2D_ARRAY ||
res->target == PIPE_TEXTURE_CUBE ||
res->target == PIPE_TEXTURE_CUBE_ARRAY) {
/*
* For array textures, we don't have first_layer, instead
* adjust last_layer (stored as depth) plus the mip level offsets
* (as we have mip-first layout can't just adjust base ptr).
* XXX For mip levels, could do something similar.
*/
jit_tex->depth = view->u.tex.last_layer - view->u.tex.first_layer + 1;
for (j = first_level; j <= last_level; j++) {
jit_tex->mip_offsets[j] += view->u.tex.first_layer *
lp_tex->img_stride[j];
}
if (view->target == PIPE_TEXTURE_CUBE ||
view->target == PIPE_TEXTURE_CUBE_ARRAY) {
assert(jit_tex->depth % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
assert(view->u.tex.last_layer < res->array_size);
}
}
else {
/*
* For buffers, we don't have first_element, instead adjust
* last_element (stored as width) plus the base pointer.
*/
unsigned view_blocksize = util_format_get_blocksize(view->format);
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:Mesa,代码行数:101,代码来源:lp_setup.c
示例6: svga_vbuf_render_draw_elements
static void
svga_vbuf_render_draw_elements( struct vbuf_render *render,
const ushort *indices,
uint nr_indices)
{
struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
struct svga_context *svga = svga_render->svga;
struct pipe_screen *screen = svga->pipe.screen;
int bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
boolean ret;
size_t size = 2 * nr_indices;
assert(( svga_render->vbuf_offset - svga_render->vdecl_offset) % svga_render->vertex_size == 0);
if (svga_render->ibuf_size < svga_render->ibuf_offset + size)
pipe_resource_reference(&svga_render->ibuf, NULL);
if (!svga_render->ibuf) {
svga_render->ibuf_size = MAX2(size, svga_render->ibuf_alloc_size);
svga_render->ibuf = pipe_buffer_create(screen,
PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STREAM,
svga_render->ibuf_size);
svga_render->ibuf_offset = 0;
}
pipe_buffer_write_nooverlap(&svga->pipe, svga_render->ibuf,
svga_render->ibuf_offset, 2 * nr_indices, indices);
/* off to hardware */
svga_vbuf_submit_state(svga_render);
/* Need to call update_state() again as the draw module may have
* altered some of our state behind our backs. Testcase:
* redbook/polys.c
*/
svga_update_state_retry( svga, SVGA_STATE_HW_DRAW );
ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
svga_render->ibuf,
2,
bias,
svga_render->min_index,
svga_render->max_index,
svga_render->prim,
svga_render->ibuf_offset / 2, nr_indices);
if(ret != PIPE_OK) {
svga_context_flush(svga, NULL);
ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
svga_render->ibuf,
2,
bias,
svga_render->min_index,
svga_render->max_index,
svga_render->prim,
svga_render->ibuf_offset / 2, nr_indices);
svga->swtnl.new_vbuf = TRUE;
assert(ret == PIPE_OK);
}
svga_render->ibuf_offset += size;
}
开发者ID:mlankhorst,项目名称:Mesa-3D,代码行数:62,代码来源:svga_swtnl_backend.c
示例7: r300_draw_elements
static void r300_draw_elements(struct r300_context *r300,
const struct pipe_draw_info *info,
int instance_id)
{
struct pipe_resource *indexBuffer = r300->index_buffer.buffer;
unsigned indexSize = r300->index_buffer.index_size;
struct pipe_resource* orgIndexBuffer = indexBuffer;
unsigned start = info->start;
unsigned count = info->count;
boolean alt_num_verts = r300->screen->caps.is_r500 &&
count > 65536;
unsigned short_count;
int buffer_offset = 0, index_offset = 0; /* for index bias emulation */
uint16_t indices3[3];
if (info->index_bias && !r300->screen->caps.is_r500) {
r300_split_index_bias(r300, info->index_bias, &buffer_offset,
&index_offset);
}
r300_translate_index_buffer(r300, &r300->index_buffer, &indexBuffer,
&indexSize, index_offset, &start, count);
/* Fallback for misaligned ushort indices. */
if (indexSize == 2 && (start & 1) && indexBuffer) {
/* If we got here, then orgIndexBuffer == indexBuffer. */
uint16_t *ptr = r300->rws->buffer_map(r300_resource(orgIndexBuffer)->cs_buf,
r300->cs,
PIPE_TRANSFER_READ |
PIPE_TRANSFER_UNSYNCHRONIZED);
if (info->mode == PIPE_PRIM_TRIANGLES) {
memcpy(indices3, ptr + start, 6);
} else {
/* Copy the mapped index buffer directly to the upload buffer.
* The start index will be aligned simply from the fact that
* every sub-buffer in the upload buffer is aligned. */
r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start,
count, (uint8_t*)ptr);
}
} else {
if (r300->index_buffer.user_buffer)
r300_upload_index_buffer(r300, &indexBuffer, indexSize,
&start, count,
r300->index_buffer.user_buffer);
}
/* 19 dwords for emit_draw_elements. Give up if the function fails. */
if (!r300_prepare_for_rendering(r300,
PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS |
PREP_INDEXED, indexBuffer, 19, buffer_offset, info->index_bias,
instance_id))
goto done;
if (alt_num_verts || count <= 65535) {
r300_emit_draw_elements(r300, indexBuffer, indexSize,
info->max_index, info->mode, start, count,
indices3);
} else {
do {
/* The maximum must be divisible by 4 and 3,
* so that quad and triangle lists are split correctly.
*
* Strips, loops, and fans won't work. */
short_count = MIN2(count, 65532);
r300_emit_draw_elements(r300, indexBuffer, indexSize,
info->max_index,
info->mode, start, short_count, indices3);
start += short_count;
count -= short_count;
/* 15 dwords for emit_draw_elements */
if (count) {
if (!r300_prepare_for_rendering(r300,
PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS | PREP_INDEXED,
indexBuffer, 19, buffer_offset, info->index_bias,
instance_id))
goto done;
}
} while (count);
}
done:
if (indexBuffer != orgIndexBuffer) {
pipe_resource_reference( &indexBuffer, NULL );
}
}
开发者ID:Thermionix,项目名称:Mesa-3D,代码行数:89,代码来源:r300_render.c
示例8: vlVaDeriveImage
VAStatus
vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
{
vlVaDriver *drv;
vlVaSurface *surf;
vlVaBuffer *img_buf;
VAImage *img;
struct pipe_surface **surfaces;
int w;
int h;
int i;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
drv = VL_VA_DRIVER(ctx);
if (!drv)
return VA_STATUS_ERROR_INVALID_CONTEXT;
surf = handle_table_get(drv->htab, surface);
if (!surf || !surf->buffer || surf->buffer->interlaced)
return VA_STATUS_ERROR_INVALID_SURFACE;
surfaces = surf->buffer->get_surfaces(surf->buffer);
if (!surfaces || !surfaces[0]->texture)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
img = CALLOC(1, sizeof(VAImage));
if (!img)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
img->format.fourcc = PipeFormatToVaFourcc(surf->buffer->buffer_format);
img->buf = VA_INVALID_ID;
img->width = surf->buffer->width;
img->height = surf->buffer->height;
img->num_palette_entries = 0;
img->entry_bytes = 0;
w = align(surf->buffer->width, 2);
h = align(surf->buffer->height, 2);
for (i = 0; i < ARRAY_SIZE(formats); ++i) {
if (img->format.fourcc == formats[i].fourcc) {
img->format = formats[i];
break;
}
}
switch (img->format.fourcc) {
case VA_FOURCC('U','Y','V','Y'):
case VA_FOURCC('Y','U','Y','V'):
img->num_planes = 1;
img->pitches[0] = w * 2;
img->offsets[0] = 0;
img->data_size = w * h * 2;
break;
case VA_FOURCC('B','G','R','A'):
case VA_FOURCC('R','G','B','A'):
case VA_FOURCC('B','G','R','X'):
case VA_FOURCC('R','G','B','X'):
img->num_planes = 1;
img->pitches[0] = w * 4;
img->offsets[0] = 0;
img->data_size = w * h * 4;
break;
default:
/* VaDeriveImage is designed for contiguous planes. */
FREE(img);
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
}
img_buf = CALLOC(1, sizeof(vlVaBuffer));
if (!img_buf) {
FREE(img);
return VA_STATUS_ERROR_ALLOCATION_FAILED;
}
pipe_mutex_lock(drv->mutex);
img->image_id = handle_table_add(drv->htab, img);
img_buf->type = VAImageBufferType;
img_buf->size = img->data_size;
img_buf->num_elements = 1;
pipe_resource_reference(&img_buf->derived_surface.resource, surfaces[0]->texture);
img->buf = handle_table_add(VL_VA_DRIVER(ctx)->htab, img_buf);
pipe_mutex_unlock(drv->mutex);
*image = *img;
return VA_STATUS_SUCCESS;
}
开发者ID:KidGundam,项目名称:Image-Synthesis,代码行数:96,代码来源:image.c
示例9: lp_scene_end_rasterization
/**
* Free all the temporary data in a scene.
*/
void
lp_scene_end_rasterization(struct lp_scene *scene )
{
int i, j;
/* Unmap color buffers */
for (i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->cbufs[i].map) {
struct pipe_surface *cbuf = scene->fb.cbufs[i];
if (llvmpipe_resource_is_texture(cbuf->texture)) {
llvmpipe_resource_unmap(cbuf->texture,
cbuf->u.tex.level,
cbuf->u.tex.first_layer);
}
scene->cbufs[i].map = NULL;
}
}
/* Unmap z/stencil buffer */
if (scene->zsbuf.map) {
struct pipe_surface *zsbuf = scene->fb.zsbuf;
llvmpipe_resource_unmap(zsbuf->texture,
zsbuf->u.tex.level,
zsbuf->u.tex.first_layer);
scene->zsbuf.map = NULL;
}
/* Reset all command lists:
*/
for (i = 0; i < scene->tiles_x; i++) {
for (j = 0; j < scene->tiles_y; j++) {
struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
bin->head = NULL;
bin->tail = NULL;
bin->last_state = NULL;
}
}
/* If there are any bins which weren't cleared by the loop above,
* they will be caught (on debug builds at least) by this assert:
*/
assert(lp_scene_is_empty(scene));
/* Decrement texture ref counts
*/
{
struct resource_ref *ref;
int i, j = 0;
for (ref = scene->resources; ref; ref = ref->next) {
for (i = 0; i < ref->count; i++) {
if (LP_DEBUG & DEBUG_SETUP)
debug_printf("resource %d: %p %dx%d sz %d\n",
j,
(void *) ref->resource[i],
ref->resource[i]->width0,
ref->resource[i]->height0,
llvmpipe_resource_size(ref->resource[i]));
j++;
pipe_resource_reference(&ref->resource[i], NULL);
}
}
if (LP_DEBUG & DEBUG_SETUP)
debug_printf("scene %d resources, sz %d\n",
j, scene->resource_reference_size);
}
/* Free all scene data blocks:
*/
{
struct data_block_list *list = &scene->data;
struct data_block *block, *tmp;
for (block = list->head->next; block; block = tmp) {
tmp = block->next;
FREE(block);
}
list->head->next = NULL;
list->head->used = 0;
}
lp_fence_reference(&scene->fence, NULL);
scene->resources = NULL;
scene->scene_size = 0;
scene->resource_reference_size = 0;
scene->has_depthstencil_clear = FALSE;
scene->alloc_failed = FALSE;
util_unreference_framebuffer_state( &scene->fb );
}
开发者ID:Forzaferrarileo,项目名称:mesa,代码行数:97,代码来源:lp_scene.c
示例10: noop_surface_destroy
static void noop_surface_destroy(struct pipe_context *ctx,
struct pipe_surface *surface)
{
pipe_resource_reference(&surface->texture, NULL);
FREE(surface);
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:6,代码来源:noop_state.c
示例11: noop_stream_output_target_destroy
static void noop_stream_output_target_destroy(struct pipe_context *ctx,
struct pipe_stream_output_target *t)
{
pipe_resource_reference(&t->buffer, NULL);
FREE(t);
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:6,代码来源:noop_state.c
示例12: noop_sampler_view_destroy
static void noop_sampler_view_destroy(struct pipe_context *ctx,
struct pipe_sampler_view *state)
{
pipe_resource_reference(&state->texture, NULL);
FREE(state);
}
开发者ID:anupamkaul,项目名称:mesa,代码行数:6,代码来源:noop_state.c
示例13: dri2_destroy_image
static void
dri2_destroy_image(__DRIimage *img)
{
pipe_resource_reference(&img->texture, NULL);
FREE(img);
}
开发者ID:mlankhorst,项目名称:Mesa-3D,代码行数:6,代码来源:dri2.c
示例14: dri2_drawable_process_buffers
/**
* Process __DRIbuffer and convert them into pipe_resources.
*/
static void
dri2_drawable_process_buffers(struct dri_drawable *drawable,
__DRIbuffer *buffers, unsigned count)
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
__DRIdrawable *dri_drawable = drawable->dPriv;
struct pipe_resource templ;
struct winsys_handle whandle;
boolean have_depth = FALSE;
unsigned i, bind;
if (drawable->old_num == count &&
drawable->old_w == dri_drawable->w &&
drawable->old_h == dri_drawable->h &&
memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0)
return;
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
pipe_resource_reference(&drawable->textures[i], NULL);
memset(&templ, 0, sizeof(templ));
templ.target = screen->target;
templ.last_level = 0;
templ.width0 = dri_drawable->w;
templ.height0 = dri_drawable->h;
templ.depth0 = 1;
templ.array_size = 1;
memset(&whandle, 0, sizeof(whandle));
for (i = 0; i < count; i++) {
__DRIbuffer *buf = &buffers[i];
enum st_attachment_type statt;
enum pipe_format format;
switch (buf->attachment) {
case __DRI_BUFFER_FRONT_LEFT:
if (!screen->auto_fake_front) {
statt = ST_ATTACHMENT_INVALID;
break;
}
/* fallthrough */
case __DRI_BUFFER_FAKE_FRONT_LEFT:
statt = ST_ATTACHMENT_FRONT_LEFT;
break;
case __DRI_BUFFER_BACK_LEFT:
statt = ST_ATTACHMENT_BACK_LEFT;
break;
case __DRI_BUFFER_DEPTH:
case __DRI_BUFFER_DEPTH_STENCIL:
case __DRI_BUFFER_STENCIL:
/* use only the first depth/stencil buffer */
if (!have_depth) {
have_depth = TRUE;
statt = ST_ATTACHMENT_DEPTH_STENCIL;
}
else {
statt = ST_ATTACHMENT_INVALID;
}
break;
default:
statt = ST_ATTACHMENT_INVALID;
break;
}
dri_drawable_get_format(drawable, statt, &format, &bind);
if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE)
continue;
templ.format = format;
templ.bind = bind;
whandle.handle = buf->name;
whandle.stride = buf->pitch;
drawable->textures[statt] =
screen->base.screen->resource_from_handle(screen->base.screen,
&templ, &whandle);
}
drawable->old_num = count;
drawable->old_w = dri_drawable->w;
drawable->old_h = dri_drawable->h;
memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
}
开发者ID:mlankhorst,项目名称:Mesa-3D,代码行数:87,代码来源:dri2.c
示例15: r600_draw_rectangle
void r600_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2, float depth,
enum blitter_attrib_type type,
const union pipe_color_union *attrib)
{
struct r600_common_context *rctx =
(struct r600_common_context*)util_blitter_get_pipe(blitter);
struct pipe_viewport_state viewport;
struct pipe_resource *buf = NULL;
unsigned offset = 0;
float *vb;
if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib);
return;
}
/* Some operations (like color resolve on r6xx) don't work
* with the conventional primitive types.
* One that works is PT_RECTLIST, which we use here. */
/* setup viewport */
viewport.scale[0] = 1.0f;
viewport.scale[1] = 1.0f;
viewport.scale[2] = 1.0f;
viewport.translate[0] = 0.0f;
viewport.translate[1] = 0.0f;
viewport.translate[2] = 0.0f;
rctx->b.set_viewport_states(&rctx->b, 0, 1, &viewport);
/* Upload vertices. The hw rectangle has only 3 vertices,
* I guess the 4th one is derived from the first 3.
* The vertex specification should match u_blitter's vertex element state. */
u_upload_alloc(rctx->uploader, 0, sizeof(float) * 24, 256, &offset, &buf, (void**)&vb);
if (!buf)
return;
vb[0] = x1;
vb[1] = y1;
vb[2] = depth;
vb[3] = 1;
vb[8] = x1;
vb[9] = y2;
vb[10] = depth;
vb[11] = 1;
vb[16] = x2;
vb[17] = y1;
vb[18] = depth;
vb[19] = 1;
if (attrib) {
memcpy(vb+4, attrib->f, sizeof(float)*4);
memcpy(vb+12, attrib->f, sizeof(float)*4);
memcpy(vb+20, attrib->f, sizeof(float)*4);
}
/* draw */
util_draw_vertex_buffer(&rctx->b, NULL, buf, blitter->vb_slot, offset,
R600_PRIM_RECTANGLE_LIST, 3, 2);
pipe_resource_reference(&buf, NULL);
}
开发者ID:MartaLo,项目名称:mesa,代码行数:63,代码来源:r600_pipe_common.c
示例16: r600_tex_surface_destroy
static void r600_tex_surface_destroy(struct pipe_surface *surface)
{
pipe_resource_reference(&surface->texture, NULL);
FREE(surface);
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:5,代码来源:r600_texture.c
示例17: XvMCCreateSubpicture
PUBLIC
Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture,
unsigned short width, unsigned short height, int xvimage_id)
{
XvMCContextPrivate *context_priv;
XvMCSubpicturePrivate *subpicture_priv;
struct pipe_context *pipe;
struct pipe_resource tex_templ, *tex;
struct pipe_sampler_view sampler_templ;
Status ret;
XVMC_MSG(XVMC_TRACE, "[XvMC] Creating subpicture %p.\n", subpicture);
assert(dpy);
if (!context)
return XvMCBadContext;
context_priv = context->privData;
pipe = context_priv->pipe;
if (!subpicture)
return XvMCBadSubpicture;
if (width > context_priv->subpicture_max_width ||
height > context_priv->subpicture_max_height)
return BadValue;
ret = Validate(dpy, context->port, context->surface_type_id, xvimage_id);
if (ret != Success)
return ret;
subpicture_priv = CALLOC(1, sizeof(XvMCSubpicturePrivate));
if (!subpicture_priv)
return BadAlloc;
memset(&tex_templ, 0, sizeof(tex_templ));
tex_templ.target = PIPE_TEXTURE_2D;
tex_templ.format = XvIDToPipe(xvimage_id);
tex_templ.last_level = 0;
if (pipe->screen->get_video_param(pipe->screen,
PIPE_VIDEO_PROFILE_UNKNOWN,
PIPE_VIDEO_ENTRYPOINT_UNKNOWN,
PIPE_VIDEO_CAP_NPOT_TEXTURES)) {
tex_templ.width0 = width;
tex_templ.height0 = height;
}
else {
tex_templ.width0 = util_next_power_of_two(width);
tex_templ.height0 = util_next_power_of_two(height);
}
tex_templ.depth0 = 1;
tex_templ.array_size = 1;
tex_templ.usage = PIPE_USAGE_DYNAMIC;
tex_templ.bind = PIPE_BIND_SAMPLER_VIEW;
tex_templ.flags = 0;
tex = pipe->screen->resource_create(pipe->screen, &tex_templ);
memset(&sampler_templ, 0, sizeof(sampler_templ));
u_sampler_view_default_template(&sampler_templ, tex, tex->format);
subpicture_priv->sampler = pipe->create_sampler_view(pipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
if (!subpicture_priv->sampler) {
FREE(subpicture_priv);
return BadAlloc;
}
subpicture_priv->context = context;
subpicture->subpicture_id = XAllocID(dpy);
subpicture->context_id = context->context_id;
subpicture->xvimage_id = xvimage_id;
subpicture->width = width;
subpicture->height = height;
subpicture->num_palette_entries = NumPaletteEntries4XvID(xvimage_id);
subpicture->entry_bytes = PipeToComponentOrder(tex_templ.format, subpicture->component_order);
subpicture->privData = subpicture_priv;
if (subpicture->num_palette_entries > 0) {
tex_templ.target = PIPE_TEXTURE_1D;
tex_templ.format = PIPE_FORMAT_R8G8B8X8_UNORM;
tex_templ.width0 = subpicture->num_palette_entries;
tex_templ.height0 = 1;
tex_templ.usage = PIPE_USAGE_DEFAULT;
tex = pipe->screen->resource_create(pipe->screen, &tex_templ);
memset(&sampler_templ, 0, sizeof(sampler_templ));
u_sampler_view_default_template(&sampler_templ, tex, tex->format);
sampler_templ.swizzle_a = PIPE_SWIZZLE_ONE;
subpicture_priv->palette = pipe->create_sampler_view(pipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
if (!subpicture_priv->sampler) {
FREE(subpicture_priv);
return BadAlloc;
}
}
SyncHandle();
//.........这里部分代码省略.........
开发者ID:Haifen,项目名称:Mesa-3D,代码行数:101,代码来源:subpicture.c
示例18: lp_setup_set_fragment_sampler_views
/**
* Called during state validation when LP_NEW_SAMPLER_VIEW is set.
*/
void
lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
unsigned num,
struct pipe_sampler_view **views)
{
unsigned i;
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
assert(num <= PIPE_MAX_SAMPLERS);
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
struct pipe_sampler_view *view = i < num ? views[i] : NULL;
if (view) {
struct pipe_resource *tex = view->texture;
struct llvmpipe_resource *lp_tex = llvmpipe_resource(tex);
struct lp_jit_texture *jit_tex;
jit_tex = &setup->fs.current.jit_context.textures[i];
jit_tex->width = tex->width0;
jit_tex->height = tex->height0;
jit_tex->depth = tex->depth0;
jit_tex->first_level = view->u.tex.first_level;
jit_tex->last_level = tex->last_level;
/* We're referencing the texture's internal data, so save a
* reference to it.
*/
pipe_resource_reference(&setup->fs.current_tex[i], te
|
请发表评论