static void save_sampler_views(struct cso_context *ctx, struct sampler_info *info) { uint i; info->nr_views_saved = info->nr_views; for (i = 0; i < info->nr_views; i++) { assert(!info->views_saved[i]); pipe_sampler_view_reference(&info->views_saved[i], info->views[i]); } }
static void cso_save_fragment_sampler_views(struct cso_context *ctx) { unsigned i; ctx->nr_fragment_views_saved = ctx->nr_fragment_views; for (i = 0; i < ctx->nr_fragment_views; i++) { assert(!ctx->fragment_views_saved[i]); pipe_sampler_view_reference(&ctx->fragment_views_saved[i], ctx->fragment_views[i]); } }
static void nv30_fragtex_set_sampler_views(struct pipe_context *pipe, unsigned nr, struct pipe_sampler_view **views) { struct nv30_context *nv30 = nv30_context(pipe); unsigned i; for (i = 0; i < nr; i++) { nouveau_bufctx_reset(nv30->bufctx, BUFCTX_FRAGTEX(i)); pipe_sampler_view_reference(&nv30->fragprog.textures[i], views[i]); nv30->fragprog.dirty_samplers |= (1 << i); } for (; i < nv30->fragprog.num_textures; i++) { nouveau_bufctx_reset(nv30->bufctx, BUFCTX_FRAGTEX(i)); pipe_sampler_view_reference(&nv30->fragprog.textures[i], NULL); nv30->fragprog.dirty_samplers |= (1 << i); } nv30->fragprog.num_textures = nr; nv30->dirty |= NV30_NEW_FRAGTEX; }
void cso_save_sampler_views(struct cso_context *ctx, unsigned shader_stage) { struct sampler_info *info = &ctx->samplers[shader_stage]; unsigned i; info->nr_views_saved = info->nr_views; for (i = 0; i < info->nr_views; i++) { assert(!info->views_saved[i]); pipe_sampler_view_reference(&info->views_saved[i], info->views[i]); } }
static void r600_copy_first_sample(struct pipe_context *ctx, const struct pipe_resolve_info *info) { struct r600_context *rctx = (struct r600_context *)ctx; struct r600_texture *rsrc = (struct r600_texture*)info->src.res; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; struct pipe_box box; if (rsrc->is_depth && !rsrc->is_flushing_texture) { if (!r600_init_flushed_depth_texture(ctx, info->src.res, NULL)) return; /* error */ /* Decompress the first sample only. */ r600_blit_decompress_depth(ctx, rsrc, NULL, 0, 0, info->src.layer, info->src.layer, 0, 0); } if (rctx->chip_class != CAYMAN && rsrc->fmask_size && rsrc->cmask_size) { r600_blit_decompress_color(ctx, rsrc, 0, 0, info->src.layer, info->src.layer); } /* this is correct for upside-down blits too */ u_box_2d(info->src.x0, info->src.y0, info->src.x1 - info->src.x0, info->src.y1 - info->src.y0, &box); /* Initialize the surface. */ util_blitter_default_dst_texture(&dst_templ, info->dst.res, info->dst.level, info->dst.layer, &box); dst_view = ctx->create_surface(ctx, info->dst.res, &dst_templ); /* Initialize the sampler view. */ util_blitter_default_src_texture(&src_templ, info->src.res, 0); src_view = ctx->create_sampler_view(ctx, info->src.res, &src_templ); /* Copy the first sample into dst. */ r600_blitter_begin(ctx, R600_COPY_TEXTURE); util_blitter_copy_texture_view(rctx->blitter, dst_view, ~0, info->dst.x0, info->dst.y0, src_view, 0, &box, info->src.res->width0, info->src.res->height0, info->mask); r600_blitter_end(ctx); pipe_surface_reference(&dst_view, NULL); pipe_sampler_view_reference(&src_view, NULL); }
static void update_textures(struct st_context *st, unsigned shader_stage, const struct gl_program *prog, unsigned max_units, struct pipe_sampler_view **sampler_views, unsigned *num_textures) { const GLuint old_max = *num_textures; GLbitfield samplers_used = prog->SamplersUsed; GLuint unit, new_count; if (samplers_used == 0x0 && old_max == 0) return; *num_textures = 0; /* loop over sampler units (aka tex image units) */ for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) { struct pipe_sampler_view *sampler_view = NULL; if (samplers_used & 1) { const GLuint texUnit = prog->SamplerUnits[unit]; GLboolean retval; retval = update_single_texture(st, &sampler_view, texUnit); if (retval == GL_FALSE) continue; *num_textures = unit + 1; } else if (samplers_used == 0 && unit >= old_max) { /* if we've reset all the old views and we have no more new ones */ break; } pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view); } /* Ex: if old_max = 3 and *num_textures = 1, we need to pass an * array of views={X, NULL, NULL} to unref the old texture views * at positions [1] and [2]. */ new_count = MAX2(*num_textures, old_max); assert(new_count <= max_units); cso_set_sampler_views(st->cso_context, shader_stage, new_count, sampler_views); }
/** * If there's anything in the bitmap cache, draw/flush it now. */ void st_flush_bitmap_cache(struct st_context *st) { if (!st->bitmap.cache->empty) { struct bitmap_cache *cache = st->bitmap.cache; if (st->ctx->DrawBuffer) { struct pipe_context *pipe = st->pipe; struct pipe_sampler_view *sv; assert(cache->xmin <= cache->xmax); /* printf("flush size %d x %d at %d, %d\n", cache->xmax - cache->xmin, cache->ymax - cache->ymin, cache->xpos, cache->ypos); */ /* The texture transfer has been mapped until now. * So unmap and release the texture transfer before drawing. */ if (cache->trans) { if (0) print_cache(cache); pipe_transfer_unmap(pipe, cache->trans); cache->buffer = NULL; pipe->transfer_destroy(pipe, cache->trans); cache->trans = NULL; } sv = st_create_texture_sampler_view(st->pipe, cache->texture); if (sv) { draw_bitmap_quad(st->ctx, cache->xpos, cache->ypos, cache->zpos, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, sv, cache->color); pipe_sampler_view_reference(&sv, NULL); } } /* release/free the texture */ pipe_resource_reference(&cache->texture, NULL); reset_cache(st); } }
bool vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, struct pipe_sampler_view *src, struct pipe_surface *dst) { struct pipe_resource res_tmpl, *res; struct pipe_sampler_view sv_tmpl; assert(zscan && buffer); memset(buffer, 0, sizeof(struct vl_zscan_buffer)); pipe_sampler_view_reference(&buffer->src, src); buffer->viewport.scale[0] = dst->width; buffer->viewport.scale[1] = dst->height; buffer->viewport.scale[2] = 1; buffer->viewport.scale[3] = 1; buffer->viewport.translate[0] = 0; buffer->viewport.translate[1] = 0; buffer->viewport.translate[2] = 0; buffer->viewport.translate[3] = 0; buffer->fb_state.width = dst->width; buffer->fb_state.height = dst->height; buffer->fb_state.nr_cbufs = 1; pipe_surface_reference(&buffer->fb_state.cbufs[0], dst); memset(&res_tmpl, 0, sizeof(res_tmpl)); res_tmpl.target = PIPE_TEXTURE_3D; res_tmpl.format = PIPE_FORMAT_R8_UNORM; res_tmpl.width0 = VL_BLOCK_WIDTH * zscan->blocks_per_line; res_tmpl.height0 = VL_BLOCK_HEIGHT; res_tmpl.depth0 = 2; res_tmpl.array_size = 1; res_tmpl.usage = PIPE_USAGE_IMMUTABLE; res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW; res = zscan->pipe->screen->resource_create(zscan->pipe->screen, &res_tmpl); if (!res) return false; memset(&sv_tmpl, 0, sizeof(sv_tmpl)); u_sampler_view_default_template(&sv_tmpl, res, res->format); sv_tmpl.swizzle_r = sv_tmpl.swizzle_g = sv_tmpl.swizzle_b = sv_tmpl.swizzle_a = TGSI_SWIZZLE_X; buffer->quant = zscan->pipe->create_sampler_view(zscan->pipe, res, &sv_tmpl); pipe_resource_reference(&res, NULL); if (!buffer->quant) return false; return true; }
static void restore_sampler_views(struct cso_context *ctx, struct sampler_info *info, void (*set_views)(struct pipe_context *, unsigned num_views, struct pipe_sampler_view **)) { uint i; for (i = 0; i < info->nr_views_saved; i++) { pipe_sampler_view_reference(&info->views[i], info->views_saved[i]); pipe_sampler_view_reference(&info->views_saved[i], NULL); } for (; i < info->nr_views; i++) { pipe_sampler_view_reference(&info->views[i], NULL); } /* bind the old/saved sampler views */ set_views(ctx->pipe, info->nr_views_saved, info->views); info->nr_views = info->nr_views_saved; info->nr_views_saved = 0; }
bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer, struct pipe_sampler_view *source, struct pipe_sampler_view *intermediate) { assert(buffer && idct); assert(source && intermediate); memset(buffer, 0, sizeof(struct vl_idct_buffer)); pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, idct->matrix); pipe_sampler_view_reference(&buffer->sampler_views.individual.source, source); pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, idct->transpose); pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, intermediate); if (!init_source(idct, buffer)) return false; if (!init_intermediate(idct, buffer)) return false; return true; }
static void nvfx_set_fragment_sampler_views(struct pipe_context *pipe, unsigned nr, struct pipe_sampler_view **views) { struct nvfx_context *nvfx = nvfx_context(pipe); unsigned unit; for (unit = 0; unit < nr; unit++) { pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit], views[unit]); nvfx->dirty_samplers |= (1 << unit); } for (unit = nr; unit < nvfx->nr_textures; unit++) { pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit], NULL); nvfx->dirty_samplers |= (1 << unit); } nvfx->nr_textures = nr; nvfx->dirty |= NVFX_NEW_SAMPLER; }
static void update_textures(struct st_context *st, gl_shader_stage mesa_shader, const struct gl_program *prog, unsigned max_units, struct pipe_sampler_view **sampler_views, unsigned *num_textures) { const GLuint old_max = *num_textures; GLbitfield samplers_used = prog->SamplersUsed; GLuint unit; struct gl_shader_program *shader = st->ctx->_Shader->CurrentProgram[mesa_shader]; unsigned glsl_version = shader ? shader->Version : 0; unsigned shader_stage = st_shader_stage_to_ptarget(mesa_shader); if (samplers_used == 0x0 && old_max == 0) return; *num_textures = 0; /* loop over sampler units (aka tex image units) */ for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) { struct pipe_sampler_view *sampler_view = NULL; if (samplers_used & 1) { const GLuint texUnit = prog->SamplerUnits[unit]; GLboolean retval; retval = update_single_texture(st, &sampler_view, texUnit, glsl_version); if (retval == GL_FALSE) continue; *num_textures = unit + 1; } else if (samplers_used == 0 && unit >= old_max) { /* if we've reset all the old views and we have no more new ones */ break; } pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view); } cso_set_sampler_views(st->cso_context, shader_stage, *num_textures, sampler_views); }
void ilo_state_vector_cleanup(struct ilo_state_vector *vec) { unsigned i, sh; for (i = 0; i < Elements(vec->vb.states); i++) { if (vec->vb.enabled_mask & (1 << i)) pipe_resource_reference(&vec->vb.states[i].buffer, NULL); } pipe_resource_reference(&vec->ib.buffer, NULL); pipe_resource_reference(&vec->ib.hw_resource, NULL); for (i = 0; i < vec->so.count; i++) pipe_so_target_reference(&vec->so.states[i], NULL); for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { for (i = 0; i < vec->view[sh].count; i++) { struct pipe_sampler_view *view = vec->view[sh].states[i]; pipe_sampler_view_reference(&view, NULL); } for (i = 0; i < Elements(vec->cbuf[sh].cso); i++) { struct ilo_cbuf_cso *cbuf = &vec->cbuf[sh].cso[i]; pipe_resource_reference(&cbuf->resource, NULL); } } for (i = 0; i < vec->resource.count; i++) pipe_surface_reference(&vec->resource.states[i], NULL); for (i = 0; i < vec->fb.state.nr_cbufs; i++) pipe_surface_reference(&vec->fb.state.cbufs[i], NULL); if (vec->fb.state.zsbuf) pipe_surface_reference(&vec->fb.state.zsbuf, NULL); for (i = 0; i < vec->cs_resource.count; i++) pipe_surface_reference(&vec->cs_resource.states[i], NULL); for (i = 0; i < vec->global_binding.count; i++) { struct ilo_global_binding_cso *cso = util_dynarray_element(&vec->global_binding.bindings, struct ilo_global_binding_cso, i); pipe_resource_reference(&cso->resource, NULL); } util_dynarray_fini(&vec->global_binding.bindings); }
static void st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, GLboolean output, struct gl_texture_object *texObj, struct gl_texture_image *texImage, const GLvoid *vdpSurface, GLuint index) { struct st_texture_object *stObj = st_texture_object(texObj); struct st_texture_image *stImage = st_texture_image(texImage); pipe_resource_reference(&stObj->pt, NULL); pipe_sampler_view_reference(&stObj->sampler_view, NULL); pipe_resource_reference(&stImage->pt, NULL); _mesa_dirty_texobj(ctx, texObj); }
void st_texture_release_sampler_view(struct st_context *st, struct st_texture_object *stObj) { GLuint i; for (i = 0; i < stObj->num_sampler_views; ++i) { struct pipe_sampler_view **sv = &stObj->sampler_views[i]; if (*sv && (*sv)->context == st->pipe) { pipe_sampler_view_reference(sv, NULL); break; } } }
void cso_set_sampler_views(struct cso_context *ctx, unsigned shader_stage, unsigned count, struct pipe_sampler_view **views) { struct sampler_info *info = &ctx->samplers[shader_stage]; unsigned i; /* reference new views */ for (i = 0; i < count; i++) { pipe_sampler_view_reference(&info->views[i], views[i]); } /* unref extra old views, if any */ for (; i < info->nr_views; i++) { pipe_sampler_view_reference(&info->views[i], NULL); } info->nr_views = count; /* bind the new sampler views */ ctx->pipe->set_sampler_views(ctx->pipe, shader_stage, 0, count, info->views); }
/** * Called via ctx->Driver.Bitmap() */ static void st_Bitmap(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { struct st_context *st = st_context(ctx); struct pipe_resource *pt; if (width == 0 || height == 0) return; st_validate_state(st); if (!st->bitmap.vs) { /* create pass-through vertex shader now */ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_COLOR, st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC }; const uint semantic_indexes[] = { 0, 0, 0 }; st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3, semantic_names, semantic_indexes, FALSE); } if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap)) return; pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt); assert(pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT); if (sv) { draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], width, height, sv, st->ctx->Current.RasterColor); pipe_sampler_view_reference(&sv, NULL); } /* release/free the texture */ pipe_resource_reference(&pt, NULL); } }
/** * Called via ctx->Driver.Bitmap() */ static void st_Bitmap(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { struct st_context *st = st_context(ctx); struct pipe_resource *pt; assert(width > 0); assert(height > 0); st_invalidate_readpix_cache(st); if (!st->bitmap.cache) { init_bitmap_state(st); } /* We only need to validate any non-ST_NEW_CONSTANTS state. The VS we use * for bitmap drawing uses no constants and the FS constants are * explicitly uploaded in the draw_bitmap_quad() function. */ if ((st->dirty | ctx->NewDriverState) & ~ST_NEW_CONSTANTS & ST_PIPELINE_RENDER_STATE_MASK || st->gfx_shaders_may_be_dirty) { st_validate_state(st, ST_PIPELINE_RENDER); } if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap)) return; pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt); assert(pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT); if (sv) { draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], width, height, sv, ctx->Current.RasterColor); pipe_sampler_view_reference(&sv, NULL); } /* release/free the texture */ pipe_resource_reference(&pt, NULL); } }
static void nvc0_context_unreference_resources(struct nvc0_context *nvc0) { unsigned s, i; nouveau_bufctx_del(&nvc0->bufctx_3d); nouveau_bufctx_del(&nvc0->bufctx); nouveau_bufctx_del(&nvc0->bufctx_cp); util_unreference_framebuffer_state(&nvc0->framebuffer); for (i = 0; i < nvc0->num_vtxbufs; ++i) pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); for (s = 0; s < 6; ++s) { for (i = 0; i < nvc0->num_textures[s]; ++i) pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) if (!nvc0->constbuf[s][i].user) pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL); } for (s = 0; s < 2; ++s) { for (i = 0; i < NVC0_MAX_SURFACE_SLOTS; ++i) pipe_surface_reference(&nvc0->surfaces[s][i], NULL); } for (s = 0; s < 6; ++s) for (i = 0; i < NVC0_MAX_BUFFERS; ++i) pipe_resource_reference(&nvc0->buffers[s][i].buffer, NULL); for (i = 0; i < nvc0->num_tfbbufs; ++i) pipe_so_target_reference(&nvc0->tfbbuf[i], NULL); for (i = 0; i < nvc0->global_residents.size / sizeof(struct pipe_resource *); ++i) { struct pipe_resource **res = util_dynarray_element( &nvc0->global_residents, struct pipe_resource *, i); pipe_resource_reference(res, NULL); } util_dynarray_fini(&nvc0->global_residents); if (nvc0->tcp_empty) nvc0->base.pipe.delete_tcs_state(&nvc0->base.pipe, nvc0->tcp_empty); }
void svga_cleanup_tss_binding(struct svga_context *svga) { int i; unsigned count = MAX2( svga->curr.num_sampler_views, svga->state.hw_draw.num_views ); for (i = 0; i < count; i++) { struct svga_hw_view_state *view = &svga->state.hw_draw.views[i]; svga_sampler_view_reference(&view->v, NULL); pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL ); pipe_resource_reference( &view->texture, NULL ); view->dirty = 1; } }
static void softpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; assert(shader < PIPE_SHADER_TYPES); assert(start + num <= Elements(softpipe->sampler_views[shader])); /* Check for no-op */ if (start + num <= softpipe->num_sampler_views[shader] && !memcmp(softpipe->sampler_views[shader] + start, views, num * sizeof(struct pipe_sampler_view *))) { return; } draw_flush(softpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { pipe_sampler_view_reference(&softpipe->sampler_views[shader][start + i], views[i]); sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i], views[i]); } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(softpipe->num_sampler_views[shader], start + num); while (j > 0 && softpipe->sampler_views[shader][j - 1] == NULL) j--; softpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(softpipe->draw, shader, softpipe->sampler_views[shader], softpipe->num_sampler_views[shader]); } softpipe->dirty |= SP_NEW_TEXTURE; }
static void llvmpipe_set_sampler_views(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(shader < PIPE_SHADER_TYPES); assert(start + num <= Elements(llvmpipe->sampler_views[shader])); draw_flush(llvmpipe->draw); /* set the new sampler views */ for (i = 0; i < num; i++) { /* Note: we're using pipe_sampler_view_release() here to work around * a possible crash when the old view belongs to another context that * was already destroyed. */ pipe_sampler_view_release(pipe, &llvmpipe->sampler_views[shader][start + i]); pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i], views[i]); } /* find highest non-null sampler_views[] entry */ { unsigned j = MAX2(llvmpipe->num_sampler_views[shader], start + num); while (j > 0 && llvmpipe->sampler_views[shader][j - 1] == NULL) j--; llvmpipe->num_sampler_views[shader] = j; } if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { draw_set_sampler_views(llvmpipe->draw, shader, llvmpipe->sampler_views[shader], llvmpipe->num_sampler_views[shader]); } llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; }
static void set_sampler_views(struct fd_texture_stateobj *tex, unsigned start, unsigned nr, struct pipe_sampler_view **views) { unsigned i; for (i = 0; i < nr; i++) { struct pipe_sampler_view *view = views ? views[i] : NULL; unsigned p = i + start; pipe_sampler_view_reference(&tex->textures[p], view); if (tex->textures[p]) tex->valid_textures |= (1 << p); else tex->valid_textures &= ~(1 << p); } tex->num_textures = util_last_bit(tex->valid_textures); }
static void vg_context_update_blend_texture_view(struct vg_context *ctx, uint width, uint height) { struct pipe_context *pipe = ctx->pipe; struct st_framebuffer *stfb = ctx->draw_buffer; struct pipe_sampler_view *old = stfb->blend_texture_view; if (old && old->texture->width0 == width && old->texture->height0 == height) return; stfb->blend_texture_view = create_tex_and_view(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); pipe_sampler_view_reference(&old, NULL); }
static void pstip_first_tri(struct draw_stage *stage, struct prim_header *header) { struct pstip_stage *pstip = pstip_stage(stage); struct pipe_context *pipe = pstip->pipe; struct draw_context *draw = stage->draw; uint num_samplers; uint num_sampler_views; assert(stage->draw->rasterizer->poly_stipple_enable); /* bind our fragprog */ if (!bind_pstip_fragment_shader(pstip)) { stage->tri = draw_pipe_passthrough_tri; stage->tri(stage, header); return; } /* how many samplers? */ /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */ num_samplers = MAX2(pstip->num_samplers, pstip->fs->sampler_unit + 1); num_sampler_views = MAX2(pstip->num_sampler_views, num_samplers); /* plug in our sampler, texture */ pstip->state.samplers[pstip->fs->sampler_unit] = pstip->sampler_cso; pipe_sampler_view_reference(&pstip->state.sampler_views[pstip->fs->sampler_unit], pstip->sampler_view); assert(num_samplers <= PIPE_MAX_SAMPLERS); draw->suspend_flushing = TRUE; pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers, pstip->state.samplers); pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_views, pstip->state.sampler_views); draw->suspend_flushing = FALSE; /* now really draw first triangle */ stage->tri = draw_pipe_passthrough_tri; stage->tri(stage, header); }
static void st_bind_surface(struct gl_context *ctx, GLenum target, struct gl_texture_object *texObj, struct gl_texture_image *texImage, struct pipe_surface *ps) { struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; gl_format texFormat; /* map pipe format to base format */ if (util_format_get_component_bits(ps->format, UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) internalFormat = GL_RGBA; else internalFormat = GL_RGB; stObj = st_texture_object(texObj); stImage = st_texture_image(texImage); /* switch to surface based */ if (!stObj->surface_based) { _mesa_clear_texture_object(ctx, texObj); stObj->surface_based = GL_TRUE; } texFormat = st_pipe_format_to_mesa_format(ps->format); _mesa_init_teximage_fields(ctx, texImage, ps->width, ps->height, 1, 0, internalFormat, texFormat); /* FIXME create a non-default sampler view from the pipe_surface? */ pipe_resource_reference(&stObj->pt, ps->texture); pipe_sampler_view_reference(&stObj->sampler_view, NULL); pipe_resource_reference(&stImage->pt, stObj->pt); stObj->width0 = ps->width; stObj->height0 = ps->height; stObj->depth0 = 1; stObj->surface_format = ps->format; _mesa_dirty_texobj(ctx, texObj); }
/** * Destroy a VdpBitmapSurface. */ VdpStatus vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface) { vlVdpBitmapSurface *vlsurface; vlsurface = vlGetDataHTAB(surface); if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; mtx_lock(&vlsurface->device->mutex); pipe_sampler_view_reference(&vlsurface->sampler_view, NULL); mtx_unlock(&vlsurface->device->mutex); vlRemoveDataHTAB(surface); DeviceReference(&vlsurface->device, NULL); FREE(vlsurface); return VDP_STATUS_OK; }
void ilo_cleanup_states(struct ilo_context *ilo) { unsigned i, sh; for (i = 0; i < Elements(ilo->vb.states); i++) { if (ilo->vb.enabled_mask & (1 << i)) pipe_resource_reference(&ilo->vb.states[i].buffer, NULL); } pipe_resource_reference(&ilo->ib.buffer, NULL); pipe_resource_reference(&ilo->ib.hw_resource, NULL); for (i = 0; i < ilo->so.count; i++) pipe_so_target_reference(&ilo->so.states[i], NULL); for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { for (i = 0; i < ilo->view[sh].count; i++) { struct pipe_sampler_view *view = ilo->view[sh].states[i]; pipe_sampler_view_reference(&view, NULL); } for (i = 0; i < Elements(ilo->cbuf[sh].cso); i++) { struct ilo_cbuf_cso *cbuf = &ilo->cbuf[sh].cso[i]; pipe_resource_reference(&cbuf->resource, NULL); } } for (i = 0; i < ilo->resource.count; i++) pipe_surface_reference(&ilo->resource.states[i], NULL); for (i = 0; i < ilo->fb.state.nr_cbufs; i++) pipe_surface_reference(&ilo->fb.state.cbufs[i], NULL); if (ilo->fb.state.zsbuf) pipe_surface_reference(&ilo->fb.state.zsbuf, NULL); for (i = 0; i < ilo->cs_resource.count; i++) pipe_surface_reference(&ilo->cs_resource.states[i], NULL); for (i = 0; i < ilo->global_binding.count; i++) pipe_resource_reference(&ilo->global_binding.resources[i], NULL); }
struct pipe_sampler_view *vg_prepare_blend_surface(struct vg_context *ctx) { struct pipe_context *pipe = ctx->pipe; struct pipe_sampler_view *view; struct pipe_sampler_view view_templ; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; vg_validate_state(ctx); u_sampler_view_default_template(&view_templ, strb->texture, strb->texture->format); view = pipe->create_sampler_view(pipe, strb->texture, &view_templ); vg_prepare_blend_texture(ctx, view); pipe_sampler_view_reference(&view, NULL); return stfb->blend_texture_view; }
static void close_prog(struct program *p) { cso_destroy_context(p->cso); p->pipe->delete_vs_state(p->pipe, p->vs); p->pipe->delete_fs_state(p->pipe, p->fs); pipe_surface_reference(&p->framebuffer.cbufs[0], NULL); pipe_sampler_view_reference(&p->view, NULL); pipe_resource_reference(&p->target, NULL); pipe_resource_reference(&p->tex, NULL); pipe_resource_reference(&p->vbuf, NULL); p->pipe->destroy(p->pipe); p->screen->destroy(p->screen); pipe_loader_release(&p->dev, 1); FREE(p); }