struct cso_context {
- struct pipe_context *pipe;
+ struct cso_context_base base;
struct u_vbuf *vbuf;
struct u_vbuf *vbuf_current;
};
-struct pipe_context *
-cso_get_pipe_context(struct cso_context *cso)
-{
- return cso->pipe;
-}
-
-
static inline boolean
delete_cso(struct cso_context *ctx,
void *state, enum cso_cache_type type)
assert(0);
}
- cso_delete_state(ctx->pipe, state, type);
+ cso_delete_state(ctx->base.pipe, state, type);
return true;
}
bool uses_user_vertex_buffers = !(flags & CSO_NO_USER_VERTEX_BUFFERS);
bool needs64b = !(flags & CSO_NO_64B_VERTEX_BUFFERS);
- u_vbuf_get_caps(cso->pipe->screen, &caps, needs64b);
+ u_vbuf_get_caps(cso->base.pipe->screen, &caps, needs64b);
/* Enable u_vbuf if needed. */
if (caps.fallback_always ||
(uses_user_vertex_buffers &&
caps.fallback_only_for_user_vbuffers)) {
- assert(!cso->pipe->vbuf);
- cso->vbuf = u_vbuf_create(cso->pipe, &caps);
- cso->pipe->vbuf = cso->vbuf;
+ assert(!cso->base.pipe->vbuf);
+ cso->vbuf = u_vbuf_create(cso->base.pipe, &caps);
+ cso->base.pipe->vbuf = cso->vbuf;
cso->always_use_vbuf = caps.fallback_always;
cso->vbuf_current = caps.fallback_always ? cso->vbuf : NULL;
}
cso_cache_init(&ctx->cache, pipe);
cso_cache_set_sanitize_callback(&ctx->cache, sanitize_hash, ctx);
- ctx->pipe = pipe;
+ ctx->base.pipe = pipe;
ctx->sample_mask = ~0;
if (!(flags & CSO_NO_VBUF))
bool dumping = trace_dumping_enabled_locked();
if (dumping)
trace_dumping_stop_locked();
- if (ctx->pipe) {
- ctx->pipe->bind_blend_state(ctx->pipe, NULL);
- ctx->pipe->bind_rasterizer_state(ctx->pipe, NULL);
+ if (ctx->base.pipe) {
+ ctx->base.pipe->bind_blend_state(ctx->base.pipe, NULL);
+ ctx->base.pipe->bind_rasterizer_state(ctx->base.pipe, NULL);
{
static struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] = { NULL };
static struct pipe_shader_buffer ssbos[PIPE_MAX_SHADER_BUFFERS] = { 0 };
static void *zeros[PIPE_MAX_SAMPLERS] = { NULL };
- struct pipe_screen *scr = ctx->pipe->screen;
+ struct pipe_screen *scr = ctx->base.pipe->screen;
enum pipe_shader_type sh;
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
switch (sh) {
assert(maxcb <= PIPE_MAX_CONSTANT_BUFFERS);
assert(maximg <= PIPE_MAX_SHADER_IMAGES);
if (maxsam > 0) {
- ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros);
+ ctx->base.pipe->bind_sampler_states(ctx->base.pipe, sh, 0, maxsam, zeros);
}
if (maxview > 0) {
- ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, 0, false, views);
+ ctx->base.pipe->set_sampler_views(ctx->base.pipe, sh, 0, maxview, 0, false, views);
}
if (maxssbo > 0) {
- ctx->pipe->set_shader_buffers(ctx->pipe, sh, 0, maxssbo, ssbos, 0);
+ ctx->base.pipe->set_shader_buffers(ctx->base.pipe, sh, 0, maxssbo, ssbos, 0);
}
if (maximg > 0) {
- ctx->pipe->set_shader_images(ctx->pipe, sh, 0, 0, maximg, NULL);
+ ctx->base.pipe->set_shader_images(ctx->base.pipe, sh, 0, 0, maximg, NULL);
}
for (int i = 0; i < maxcb; i++) {
- ctx->pipe->set_constant_buffer(ctx->pipe, sh, i, false, NULL);
+ ctx->base.pipe->set_constant_buffer(ctx->base.pipe, sh, i, false, NULL);
}
}
}
- ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, NULL);
+ ctx->base.pipe->bind_depth_stencil_alpha_state(ctx->base.pipe, NULL);
struct pipe_stencil_ref sr = {0};
- ctx->pipe->set_stencil_ref(ctx->pipe, sr);
- ctx->pipe->bind_fs_state(ctx->pipe, NULL);
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
- ctx->pipe->bind_vs_state(ctx->pipe, NULL);
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
+ ctx->base.pipe->set_stencil_ref(ctx->base.pipe, sr);
+ ctx->base.pipe->bind_fs_state(ctx->base.pipe, NULL);
+ ctx->base.pipe->set_constant_buffer(ctx->base.pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
+ ctx->base.pipe->bind_vs_state(ctx->base.pipe, NULL);
+ ctx->base.pipe->set_constant_buffer(ctx->base.pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
if (ctx->has_geometry_shader) {
- ctx->pipe->bind_gs_state(ctx->pipe, NULL);
+ ctx->base.pipe->bind_gs_state(ctx->base.pipe, NULL);
}
if (ctx->has_tessellation) {
- ctx->pipe->bind_tcs_state(ctx->pipe, NULL);
- ctx->pipe->bind_tes_state(ctx->pipe, NULL);
+ ctx->base.pipe->bind_tcs_state(ctx->base.pipe, NULL);
+ ctx->base.pipe->bind_tes_state(ctx->base.pipe, NULL);
}
if (ctx->has_compute_shader) {
- ctx->pipe->bind_compute_state(ctx->pipe, NULL);
+ ctx->base.pipe->bind_compute_state(ctx->base.pipe, NULL);
}
- ctx->pipe->bind_vertex_elements_state(ctx->pipe, NULL);
+ ctx->base.pipe->bind_vertex_elements_state(ctx->base.pipe, NULL);
if (ctx->has_streamout)
- ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, NULL);
+ ctx->base.pipe->set_stream_output_targets(ctx->base.pipe, 0, NULL, NULL);
}
util_unreference_framebuffer_state(&ctx->fb);
* If the cso context is reused (with the same pipe context),
* need to really make sure the context state doesn't get out of sync.
*/
- ctx->pipe->set_sample_mask(ctx->pipe, ctx->sample_mask);
- if (ctx->pipe->set_min_samples)
- ctx->pipe->set_min_samples(ctx->pipe, ctx->min_samples);
+ ctx->base.pipe->set_sample_mask(ctx->base.pipe, ctx->sample_mask);
+ if (ctx->base.pipe->set_min_samples)
+ ctx->base.pipe->set_min_samples(ctx->base.pipe, ctx->min_samples);
if (dumping)
trace_dumping_start_locked();
}
if (ctx->vbuf)
u_vbuf_destroy(ctx->vbuf);
- ctx->pipe->vbuf = NULL;
+ ctx->base.pipe->vbuf = NULL;
FREE(ctx);
}
memset(&cso->state, 0, sizeof cso->state);
memcpy(&cso->state, templ, key_size);
- cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state);
+ cso->data = ctx->base.pipe->create_blend_state(ctx->base.pipe, &cso->state);
iter = cso_insert_state(&ctx->cache, hash_key, CSO_BLEND, cso);
if (cso_hash_iter_is_null(iter)) {
if (ctx->blend != handle) {
ctx->blend = handle;
- ctx->pipe->bind_blend_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_blend_state(ctx->base.pipe, handle);
}
return PIPE_OK;
}
{
if (ctx->blend != ctx->blend_saved) {
ctx->blend = ctx->blend_saved;
- ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend_saved);
+ ctx->base.pipe->bind_blend_state(ctx->base.pipe, ctx->blend_saved);
}
ctx->blend_saved = NULL;
}
return PIPE_ERROR_OUT_OF_MEMORY;
memcpy(&cso->state, templ, sizeof(*templ));
- cso->data = ctx->pipe->create_depth_stencil_alpha_state(ctx->pipe,
+ cso->data = ctx->base.pipe->create_depth_stencil_alpha_state(ctx->base.pipe,
&cso->state);
iter = cso_insert_state(&ctx->cache, hash_key,
if (ctx->depth_stencil != handle) {
ctx->depth_stencil = handle;
- ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_depth_stencil_alpha_state(ctx->base.pipe, handle);
}
return PIPE_OK;
}
{
if (ctx->depth_stencil != ctx->depth_stencil_saved) {
ctx->depth_stencil = ctx->depth_stencil_saved;
- ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe,
+ ctx->base.pipe->bind_depth_stencil_alpha_state(ctx->base.pipe,
ctx->depth_stencil_saved);
}
ctx->depth_stencil_saved = NULL;
return PIPE_ERROR_OUT_OF_MEMORY;
memcpy(&cso->state, templ, sizeof(*templ));
- cso->data = ctx->pipe->create_rasterizer_state(ctx->pipe, &cso->state);
+ cso->data = ctx->base.pipe->create_rasterizer_state(ctx->base.pipe, &cso->state);
iter = cso_insert_state(&ctx->cache, hash_key, CSO_RASTERIZER, cso);
if (cso_hash_iter_is_null(iter)) {
ctx->flatshade_first = templ->flatshade_first;
if (ctx->vbuf)
u_vbuf_set_flatshade_first(ctx->vbuf, ctx->flatshade_first);
- ctx->pipe->bind_rasterizer_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_rasterizer_state(ctx->base.pipe, handle);
}
return PIPE_OK;
}
ctx->flatshade_first = ctx->flatshade_first_saved;
if (ctx->vbuf)
u_vbuf_set_flatshade_first(ctx->vbuf, ctx->flatshade_first);
- ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rasterizer_saved);
+ ctx->base.pipe->bind_rasterizer_state(ctx->base.pipe, ctx->rasterizer_saved);
}
ctx->rasterizer_saved = NULL;
}
{
if (ctx->fragment_shader != handle) {
ctx->fragment_shader = handle;
- ctx->pipe->bind_fs_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_fs_state(ctx->base.pipe, handle);
}
}
cso_restore_fragment_shader(struct cso_context *ctx)
{
if (ctx->fragment_shader_saved != ctx->fragment_shader) {
- ctx->pipe->bind_fs_state(ctx->pipe, ctx->fragment_shader_saved);
+ ctx->base.pipe->bind_fs_state(ctx->base.pipe, ctx->fragment_shader_saved);
ctx->fragment_shader = ctx->fragment_shader_saved;
}
ctx->fragment_shader_saved = NULL;
{
if (ctx->vertex_shader != handle) {
ctx->vertex_shader = handle;
- ctx->pipe->bind_vs_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_vs_state(ctx->base.pipe, handle);
}
}
cso_restore_vertex_shader(struct cso_context *ctx)
{
if (ctx->vertex_shader_saved != ctx->vertex_shader) {
- ctx->pipe->bind_vs_state(ctx->pipe, ctx->vertex_shader_saved);
+ ctx->base.pipe->bind_vs_state(ctx->base.pipe, ctx->vertex_shader_saved);
ctx->vertex_shader = ctx->vertex_shader_saved;
}
ctx->vertex_shader_saved = NULL;
{
if (memcmp(&ctx->fb, fb, sizeof(*fb)) != 0) {
util_copy_framebuffer_state(&ctx->fb, fb);
- ctx->pipe->set_framebuffer_state(ctx->pipe, fb);
+ ctx->base.pipe->set_framebuffer_state(ctx->base.pipe, fb);
}
}
{
if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) {
util_copy_framebuffer_state(&ctx->fb, &ctx->fb_saved);
- ctx->pipe->set_framebuffer_state(ctx->pipe, &ctx->fb);
+ ctx->base.pipe->set_framebuffer_state(ctx->base.pipe, &ctx->fb);
util_unreference_framebuffer_state(&ctx->fb_saved);
}
}
{
if (memcmp(&ctx->vp, vp, sizeof(*vp))) {
ctx->vp = *vp;
- ctx->pipe->set_viewport_states(ctx->pipe, 0, 1, vp);
+ ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, vp);
}
}
{
if (memcmp(&ctx->vp, &ctx->vp_saved, sizeof(ctx->vp))) {
ctx->vp = ctx->vp_saved;
- ctx->pipe->set_viewport_states(ctx->pipe, 0, 1, &ctx->vp);
+ ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, &ctx->vp);
}
}
{
if (ctx->sample_mask != sample_mask) {
ctx->sample_mask = sample_mask;
- ctx->pipe->set_sample_mask(ctx->pipe, sample_mask);
+ ctx->base.pipe->set_sample_mask(ctx->base.pipe, sample_mask);
}
}
void
cso_set_min_samples(struct cso_context *ctx, unsigned min_samples)
{
- if (ctx->min_samples != min_samples && ctx->pipe->set_min_samples) {
+ if (ctx->min_samples != min_samples && ctx->base.pipe->set_min_samples) {
ctx->min_samples = min_samples;
- ctx->pipe->set_min_samples(ctx->pipe, min_samples);
+ ctx->base.pipe->set_min_samples(ctx->base.pipe, min_samples);
}
}
{
if (memcmp(&ctx->stencil_ref, &sr, sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = sr;
- ctx->pipe->set_stencil_ref(ctx->pipe, sr);
+ ctx->base.pipe->set_stencil_ref(ctx->base.pipe, sr);
}
}
if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved,
sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = ctx->stencil_ref_saved;
- ctx->pipe->set_stencil_ref(ctx->pipe, ctx->stencil_ref);
+ ctx->base.pipe->set_stencil_ref(ctx->base.pipe, ctx->stencil_ref);
}
}
boolean condition,
enum pipe_render_cond_flag mode)
{
- struct pipe_context *pipe = ctx->pipe;
+ struct pipe_context *pipe = ctx->base.pipe;
if (ctx->render_condition != query ||
ctx->render_condition_mode != mode ||
if (ctx->has_geometry_shader && ctx->geometry_shader != handle) {
ctx->geometry_shader = handle;
- ctx->pipe->bind_gs_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_gs_state(ctx->base.pipe, handle);
}
}
}
if (ctx->geometry_shader_saved != ctx->geometry_shader) {
- ctx->pipe->bind_gs_state(ctx->pipe, ctx->geometry_shader_saved);
+ ctx->base.pipe->bind_gs_state(ctx->base.pipe, ctx->geometry_shader_saved);
ctx->geometry_shader = ctx->geometry_shader_saved;
}
ctx->geometry_shader_saved = NULL;
if (ctx->has_tessellation && ctx->tessctrl_shader != handle) {
ctx->tessctrl_shader = handle;
- ctx->pipe->bind_tcs_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_tcs_state(ctx->base.pipe, handle);
}
}
}
if (ctx->tessctrl_shader_saved != ctx->tessctrl_shader) {
- ctx->pipe->bind_tcs_state(ctx->pipe, ctx->tessctrl_shader_saved);
+ ctx->base.pipe->bind_tcs_state(ctx->base.pipe, ctx->tessctrl_shader_saved);
ctx->tessctrl_shader = ctx->tessctrl_shader_saved;
}
ctx->tessctrl_shader_saved = NULL;
if (ctx->has_tessellation && ctx->tesseval_shader != handle) {
ctx->tesseval_shader = handle;
- ctx->pipe->bind_tes_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_tes_state(ctx->base.pipe, handle);
}
}
}
if (ctx->tesseval_shader_saved != ctx->tesseval_shader) {
- ctx->pipe->bind_tes_state(ctx->pipe, ctx->tesseval_shader_saved);
+ ctx->base.pipe->bind_tes_state(ctx->base.pipe, ctx->tesseval_shader_saved);
ctx->tesseval_shader = ctx->tesseval_shader_saved;
}
ctx->tesseval_shader_saved = NULL;
if (ctx->has_compute_shader && ctx->compute_shader != handle) {
ctx->compute_shader = handle;
- ctx->pipe->bind_compute_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_compute_state(ctx->base.pipe, handle);
}
}
}
if (ctx->compute_shader_saved != ctx->compute_shader) {
- ctx->pipe->bind_compute_state(ctx->pipe, ctx->compute_shader_saved);
+ ctx->base.pipe->bind_compute_state(ctx->base.pipe, ctx->compute_shader_saved);
ctx->compute_shader = ctx->compute_shader_saved;
}
ctx->compute_shader_saved = NULL;
struct pipe_vertex_element tmp[PIPE_MAX_ATTRIBS];
util_lower_uint64_vertex_elements(&new_elems, &new_count, tmp);
- cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, new_count,
+ cso->data = ctx->base.pipe->create_vertex_elements_state(ctx->base.pipe, new_count,
new_elems);
iter = cso_insert_state(&ctx->cache, hash_key, CSO_VELEMENTS, cso);
if (ctx->velements != handle) {
ctx->velements = handle;
- ctx->pipe->bind_vertex_elements_state(ctx->pipe, handle);
+ ctx->base.pipe->bind_vertex_elements_state(ctx->base.pipe, handle);
}
}
if (ctx->velements != ctx->velements_saved) {
ctx->velements = ctx->velements_saved;
- ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->velements_saved);
+ ctx->base.pipe->bind_vertex_elements_state(ctx->base.pipe, ctx->velements_saved);
}
ctx->velements_saved = NULL;
}
return;
}
- struct pipe_context *pipe = ctx->pipe;
+ struct pipe_context *pipe = ctx->base.pipe;
pipe->set_vertex_buffers(pipe, start_slot, count, unbind_trailing_count,
take_ownership, buffers);
}
const struct pipe_vertex_buffer *vbuffers)
{
struct u_vbuf *vbuf = ctx->vbuf;
- struct pipe_context *pipe = ctx->pipe;
+ struct pipe_context *pipe = ctx->base.pipe;
if (vbuf && (ctx->always_use_vbuf || uses_user_vertex_buffers)) {
if (!ctx->vbuf_current) {
return false;
memcpy(&cso->state, templ, sizeof(*templ));
- cso->data = ctx->pipe->create_sampler_state(ctx->pipe, &cso->state);
+ cso->data = ctx->base.pipe->create_sampler_state(ctx->base.pipe, &cso->state);
cso->hash_key = hash_key;
iter = cso_insert_state(&ctx->cache, hash_key, CSO_SAMPLER, cso);
if (ctx->max_sampler_seen == -1)
return;
- ctx->pipe->bind_sampler_states(ctx->pipe, shader_stage, 0,
+ ctx->base.pipe->bind_sampler_states(ctx->base.pipe, shader_stage, 0,
ctx->max_sampler_seen + 1,
info->samplers);
ctx->max_sampler_seen = -1;
struct pipe_stream_output_target **targets,
const unsigned *offsets)
{
- struct pipe_context *pipe = ctx->pipe;
+ struct pipe_context *pipe = ctx->base.pipe;
uint i;
if (!ctx->has_streamout) {
static void
cso_restore_stream_outputs(struct cso_context *ctx)
{
- struct pipe_context *pipe = ctx->pipe;
+ struct pipe_context *pipe = ctx->base.pipe;
uint i;
unsigned offset[PIPE_MAX_SO_BUFFERS];
if (state_mask & CSO_BIT_VIEWPORT)
cso_save_viewport(cso);
if (state_mask & CSO_BIT_PAUSE_QUERIES)
- cso->pipe->set_active_query_state(cso->pipe, false);
+ cso->base.pipe->set_active_query_state(cso->base.pipe, false);
}
if (state_mask & CSO_BIT_VERTEX_SHADER)
cso_restore_vertex_shader(cso);
if (unbind & CSO_UNBIND_FS_SAMPLERVIEWS)
- cso->pipe->set_sampler_views(cso->pipe, PIPE_SHADER_FRAGMENT, 0, 0,
+ cso->base.pipe->set_sampler_views(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, 0,
cso->max_fs_samplerviews, false, NULL);
if (unbind & CSO_UNBIND_FS_SAMPLERVIEW0)
- cso->pipe->set_sampler_views(cso->pipe, PIPE_SHADER_FRAGMENT, 0, 0,
+ cso->base.pipe->set_sampler_views(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, 0,
1, false, NULL);
if (state_mask & CSO_BIT_FRAGMENT_SAMPLERS)
cso_restore_fragment_samplers(cso);
if (unbind & CSO_UNBIND_FS_IMAGE0)
- cso->pipe->set_shader_images(cso->pipe, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
+ cso->base.pipe->set_shader_images(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
if (state_mask & CSO_BIT_FRAMEBUFFER)
cso_restore_framebuffer(cso);
if (state_mask & CSO_BIT_BLEND)
if (state_mask & CSO_BIT_VIEWPORT)
cso_restore_viewport(cso);
if (unbind & CSO_UNBIND_VS_CONSTANTS)
- cso->pipe->set_constant_buffer(cso->pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
+ cso->base.pipe->set_constant_buffer(cso->base.pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
if (unbind & CSO_UNBIND_FS_CONSTANTS)
- cso->pipe->set_constant_buffer(cso->pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
+ cso->base.pipe->set_constant_buffer(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
if (state_mask & CSO_BIT_VERTEX_ELEMENTS)
cso_restore_vertex_elements(cso);
if (unbind & CSO_UNBIND_VERTEX_BUFFER0)
- cso->pipe->set_vertex_buffers(cso->pipe, 0, 0, 1, false, NULL);
+ cso->base.pipe->set_vertex_buffers(cso->base.pipe, 0, 0, 1, false, NULL);
if (state_mask & CSO_BIT_STREAM_OUTPUTS)
cso_restore_stream_outputs(cso);
if (state_mask & CSO_BIT_PAUSE_QUERIES)
- cso->pipe->set_active_query_state(cso->pipe, true);
+ cso->base.pipe->set_active_query_state(cso->base.pipe, true);
cso->saved_state = 0;
}
/* Indirect only uses indirect->draw_count, not num_draws. */
assert(!indirect || num_draws == 1);
- struct pipe_context *pipe = cso->pipe;
+ struct pipe_context *pipe = cso->base.pipe;
if (cso->vbuf_current) {
u_vbuf_draw_vbo(pipe, info, drawid_offset, indirect, draws, num_draws);