/** * Prior to context destruction, this function unbinds all state objects. */ void cso_release_all( struct cso_context *ctx ) { unsigned i; struct sampler_info *info; if (ctx->pipe) { ctx->pipe->bind_blend_state( ctx->pipe, NULL ); ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL ); if (ctx->pipe->bind_vertex_sampler_states) ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL); ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); ctx->pipe->set_fragment_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_vertex_sampler_views) ctx->pipe->set_vertex_sampler_views(ctx->pipe, 0, NULL); if (ctx->pipe->set_stream_output_targets) ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0); } /* free fragment samplers, views */ info = &ctx->fragment_samplers; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->views_saved[i], NULL); } /* free vertex samplers, views */ info = &ctx->vertex_samplers; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_sampler_view_reference(&info->views[i], NULL); pipe_sampler_view_reference(&info->views_saved[i], NULL); } util_unreference_framebuffer_state(&ctx->fb); util_unreference_framebuffer_state(&ctx->fb_saved); util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, NULL, 0); util_copy_vertex_buffers(ctx->vertex_buffers_saved, &ctx->nr_vertex_buffers_saved, NULL, 0); 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; } }
static void i915_set_vertex_buffers(struct pipe_context *pipe, unsigned count, const struct pipe_vertex_buffer *buffers) { struct i915_context *i915 = i915_context(pipe); struct draw_context *draw = i915->draw; int i; util_copy_vertex_buffers(i915->saved_vertex_buffers, &i915->saved_nr_vertex_buffers, buffers, count); #if 0 /* XXX doesn't look like this is needed */ /* unmap old */ for (i = 0; i < i915->num_vertex_buffers; i++) { draw_set_mapped_vertex_buffer(draw, i, NULL); } #endif /* pass-through to draw module */ draw_set_vertex_buffers(draw, count, buffers); /* map new */ for (i = 0; i < count; i++) { void *buf = i915_buffer(buffers[i].buffer)->data; draw_set_mapped_vertex_buffer(draw, i, buf); } }
void cso_save_vertex_buffers(struct cso_context *ctx) { util_copy_vertex_buffers(ctx->vertex_buffers_saved, &ctx->nr_vertex_buffers_saved, ctx->vertex_buffers, ctx->nr_vertex_buffers); }
void u_vbuf_save_vertex_buffers(struct u_vbuf *mgr) { util_copy_vertex_buffers(mgr->vertex_buffer_saved, &mgr->nr_vertex_buffers_saved, mgr->vertex_buffer, mgr->nr_vertex_buffers); }
void cso_restore_vertex_buffers(struct cso_context *ctx) { util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, ctx->vertex_buffers_saved, ctx->nr_vertex_buffers_saved); ctx->pipe->set_vertex_buffers(ctx->pipe, ctx->nr_vertex_buffers, ctx->vertex_buffers); }
void draw_set_vertex_buffers(struct draw_context *draw, unsigned count, const struct pipe_vertex_buffer *buffers) { assert(count <= PIPE_MAX_ATTRIBS); util_copy_vertex_buffers(draw->pt.vertex_buffer, &draw->pt.nr_vertex_buffers, buffers, count); }
void cso_set_vertex_buffers(struct cso_context *ctx, unsigned count, const struct pipe_vertex_buffer *buffers) { if (count != ctx->nr_vertex_buffers || memcmp(buffers, ctx->vertex_buffers, sizeof(struct pipe_vertex_buffer) * count) != 0) { util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, buffers, count); ctx->pipe->set_vertex_buffers(ctx->pipe, count, buffers); } }
void cso_save_vertex_buffers(struct cso_context *ctx) { struct u_vbuf *vbuf = ctx->vbuf; if (vbuf) { u_vbuf_save_vertex_buffers(vbuf); return; } util_copy_vertex_buffers(ctx->vertex_buffers_saved, &ctx->nr_vertex_buffers_saved, ctx->vertex_buffers, ctx->nr_vertex_buffers); }
static void softpipe_set_vertex_buffers(struct pipe_context *pipe, unsigned count, const struct pipe_vertex_buffer *buffers) { struct softpipe_context *softpipe = softpipe_context(pipe); assert(count <= PIPE_MAX_ATTRIBS); util_copy_vertex_buffers(softpipe->vertex_buffer, &softpipe->num_vertex_buffers, buffers, count); softpipe->dirty |= SP_NEW_VERTEX; draw_set_vertex_buffers(softpipe->draw, count, buffers); }
void cso_restore_vertex_buffers(struct cso_context *ctx) { unsigned i; struct u_vbuf *vbuf = ctx->vbuf; if (vbuf) { u_vbuf_restore_vertex_buffers(vbuf); return; } util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, ctx->vertex_buffers_saved, ctx->nr_vertex_buffers_saved); for (i = 0; i < ctx->nr_vertex_buffers_saved; i++) { pipe_resource_reference(&ctx->vertex_buffers_saved[i].buffer, NULL); } ctx->nr_vertex_buffers_saved = 0; ctx->pipe->set_vertex_buffers(ctx->pipe, ctx->nr_vertex_buffers, ctx->vertex_buffers); }