struct pipe_vertex_buffer aux_vertex_buffer_saved;
unsigned aux_vertex_buffer_index;
+ struct pipe_constant_buffer aux_constbuf_current[PIPE_SHADER_TYPES];
+ struct pipe_constant_buffer aux_constbuf_saved[PIPE_SHADER_TYPES];
+
unsigned nr_so_targets;
struct pipe_stream_output_target *so_targets[PIPE_MAX_SO_BUFFERS];
void *vertex_shader, *vertex_shader_saved;
void *geometry_shader, *geometry_shader_saved;
void *velements, *velements_saved;
+ struct pipe_query *render_condition, *render_condition_saved;
+ uint render_condition_mode, render_condition_mode_saved;
struct pipe_clip_state clip;
struct pipe_clip_state clip_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);
}
-
-enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx,
- void *handle )
+void cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle )
{
if (ctx->fragment_shader != handle) {
ctx->fragment_shader = handle;
ctx->pipe->bind_fs_state(ctx->pipe, handle);
}
- return PIPE_OK;
}
void cso_delete_fragment_shader(struct cso_context *ctx, void *handle )
}
-enum pipe_error cso_set_vertex_shader_handle(struct cso_context *ctx,
- void *handle )
+void cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle)
{
if (ctx->vertex_shader != handle) {
ctx->vertex_shader = handle;
ctx->pipe->bind_vs_state(ctx->pipe, handle);
}
- return PIPE_OK;
}
void cso_delete_vertex_shader(struct cso_context *ctx, void *handle )
}
-enum pipe_error cso_set_framebuffer(struct cso_context *ctx,
- const struct pipe_framebuffer_state *fb)
+void cso_set_framebuffer(struct cso_context *ctx,
+ const struct pipe_framebuffer_state *fb)
{
if (memcmp(&ctx->fb, fb, sizeof(*fb)) != 0) {
util_copy_framebuffer_state(&ctx->fb, fb);
ctx->pipe->set_framebuffer_state(ctx->pipe, fb);
}
- return PIPE_OK;
}
void cso_save_framebuffer(struct cso_context *ctx)
}
-enum pipe_error cso_set_viewport(struct cso_context *ctx,
- const struct pipe_viewport_state *vp)
+void cso_set_viewport(struct cso_context *ctx,
+ const struct pipe_viewport_state *vp)
{
if (memcmp(&ctx->vp, vp, sizeof(*vp))) {
ctx->vp = *vp;
ctx->pipe->set_viewport_state(ctx->pipe, vp);
}
- return PIPE_OK;
}
void cso_save_viewport(struct cso_context *ctx)
}
-enum pipe_error cso_set_blend_color(struct cso_context *ctx,
- const struct pipe_blend_color *bc)
+void cso_set_blend_color(struct cso_context *ctx,
+ const struct pipe_blend_color *bc)
{
if (memcmp(&ctx->blend_color, bc, sizeof(ctx->blend_color))) {
ctx->blend_color = *bc;
ctx->pipe->set_blend_color(ctx->pipe, bc);
}
- return PIPE_OK;
}
-enum pipe_error cso_set_sample_mask(struct cso_context *ctx,
- unsigned sample_mask)
+void cso_set_sample_mask(struct cso_context *ctx, unsigned sample_mask)
{
if (ctx->sample_mask != sample_mask) {
ctx->sample_mask = sample_mask;
ctx->pipe->set_sample_mask(ctx->pipe, sample_mask);
}
- return PIPE_OK;
}
void cso_save_sample_mask(struct cso_context *ctx)
cso_set_sample_mask(ctx, ctx->sample_mask_saved);
}
-enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
- const struct pipe_stencil_ref *sr)
+void cso_set_stencil_ref(struct cso_context *ctx,
+ const struct pipe_stencil_ref *sr)
{
if (memcmp(&ctx->stencil_ref, sr, sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = *sr;
ctx->pipe->set_stencil_ref(ctx->pipe, sr);
}
- return PIPE_OK;
}
void cso_save_stencil_ref(struct cso_context *ctx)
}
}
-enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
- void *handle)
+void cso_set_render_condition(struct cso_context *ctx,
+ struct pipe_query *query, uint mode)
+{
+ struct pipe_context *pipe = ctx->pipe;
+
+ if (ctx->render_condition != query || ctx->render_condition_mode != mode) {
+ pipe->render_condition(pipe, query, mode);
+ ctx->render_condition = query;
+ ctx->render_condition_mode = mode;
+ }
+}
+
+void cso_save_render_condition(struct cso_context *ctx)
+{
+ ctx->render_condition_saved = ctx->render_condition;
+ ctx->render_condition_mode_saved = ctx->render_condition_mode;
+}
+
+void cso_restore_render_condition(struct cso_context *ctx)
+{
+ cso_set_render_condition(ctx, ctx->render_condition_saved,
+ ctx->render_condition_mode_saved);
+}
+
+void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle)
{
assert(ctx->has_geometry_shader || !handle);
ctx->geometry_shader = handle;
ctx->pipe->bind_gs_state(ctx->pipe, handle);
}
- return PIPE_OK;
}
void cso_delete_geometry_shader(struct cso_context *ctx, void *handle)
ctx->nr_so_targets_saved = 0;
}
+/* constant buffers */
+
+void
+cso_set_constant_buffer(struct cso_context *cso, unsigned shader_stage,
+ unsigned index, struct pipe_constant_buffer *cb)
+{
+ struct pipe_context *pipe = cso->pipe;
+
+ pipe->set_constant_buffer(pipe, shader_stage, index, cb);
+
+ if (index == 0) {
+ util_copy_constant_buffer(&cso->aux_constbuf_current[shader_stage], cb);
+ }
+}
+
+void
+cso_set_constant_buffer_resource(struct cso_context *cso,
+ unsigned shader_stage,
+ unsigned index,
+ struct pipe_resource *buffer)
+{
+ if (buffer) {
+ struct pipe_constant_buffer cb;
+ cb.buffer = buffer;
+ cb.buffer_offset = 0;
+ cb.buffer_size = buffer->width0;
+ cb.user_buffer = NULL;
+ cso_set_constant_buffer(cso, shader_stage, index, &cb);
+ } else {
+ cso_set_constant_buffer(cso, shader_stage, index, NULL);
+ }
+}
+
+void
+cso_save_constant_buffer_slot0(struct cso_context *cso,
+ unsigned shader_stage)
+{
+ util_copy_constant_buffer(&cso->aux_constbuf_saved[shader_stage],
+ &cso->aux_constbuf_current[shader_stage]);
+}
+
+void
+cso_restore_constant_buffer_slot0(struct cso_context *cso,
+ unsigned shader_stage)
+{
+ cso_set_constant_buffer(cso, shader_stage, 0,
+ &cso->aux_constbuf_saved[shader_stage]);
+ pipe_resource_reference(&cso->aux_constbuf_saved[shader_stage].buffer,
+ NULL);
+}
+
/* drawing */
void