diff options
25 files changed, 183 insertions, 163 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index d7c017a91f2..ff40f19e685 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1061,34 +1061,31 @@ void cso_delete_compute_shader(struct cso_context *ctx, void *handle) static void cso_set_vertex_elements_direct(struct cso_context *ctx, - unsigned count, - const struct pipe_vertex_element *states) + const struct cso_velems_state *velems) { unsigned key_size, hash_key; struct cso_hash_iter iter; void *handle; - struct cso_velems_state velems_state; /* Need to include the count into the stored state data too. * Otherwise first few count pipe_vertex_elements could be identical * even if count is different, and there's no guarantee the hash would * be different in that case neither. */ - key_size = sizeof(struct pipe_vertex_element) * count + sizeof(unsigned); - velems_state.count = count; - memcpy(velems_state.velems, states, - sizeof(struct pipe_vertex_element) * count); - hash_key = cso_construct_key((void*)&velems_state, key_size); + key_size = sizeof(struct pipe_vertex_element) * velems->count + + sizeof(unsigned); + hash_key = cso_construct_key((void*)velems, key_size); iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS, - (void*)&velems_state, key_size); + (void*)velems, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_velements *cso = MALLOC(sizeof(struct cso_velements)); if (!cso) return; - memcpy(&cso->state, &velems_state, key_size); - cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, count, + memcpy(&cso->state, velems, key_size); + cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, + velems->count, &cso->state.velems[0]); cso->delete_state = (cso_state_callback) ctx->pipe->delete_vertex_elements_state; @@ -1114,17 +1111,16 @@ cso_set_vertex_elements_direct(struct cso_context *ctx, enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, - unsigned count, - const struct pipe_vertex_element *states) + const struct cso_velems_state *velems) { struct u_vbuf *vbuf = ctx->vbuf_current; if (vbuf) { - u_vbuf_set_vertex_elements(vbuf, count, states); + u_vbuf_set_vertex_elements(vbuf, velems); return PIPE_OK; } - cso_set_vertex_elements_direct(ctx, count, states); + cso_set_vertex_elements_direct(ctx, velems); return PIPE_OK; } @@ -1241,8 +1237,7 @@ cso_restore_vertex_buffer0(struct cso_context *ctx) */ void cso_set_vertex_buffers_and_elements(struct cso_context *ctx, - unsigned velem_count, - const struct pipe_vertex_element *velems, + const struct cso_velems_state *velems, unsigned vb_count, unsigned unbind_trailing_vb_count, const struct pipe_vertex_buffer *vbuffers, @@ -1267,7 +1262,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx, if (vb_count) u_vbuf_set_vertex_buffers(vbuf, 0, vb_count, vbuffers); - u_vbuf_set_vertex_elements(vbuf, velem_count, velems); + u_vbuf_set_vertex_elements(vbuf, velems); return; } @@ -1287,7 +1282,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx, if (vb_count) cso_set_vertex_buffers_direct(ctx, 0, vb_count, vbuffers); - cso_set_vertex_elements_direct(ctx, velem_count, velems); + cso_set_vertex_elements_direct(ctx, velems); } void diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 0204ace34b7..447630943f5 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -32,6 +32,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" +#include "cso_cache.h" #ifdef __cplusplus @@ -82,8 +83,7 @@ cso_single_sampler_done(struct cso_context *cso, enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, - unsigned count, - const struct pipe_vertex_element *states); + const struct cso_velems_state *velems); void cso_set_vertex_buffers(struct cso_context *ctx, unsigned start_slot, unsigned count, @@ -222,8 +222,7 @@ void cso_restore_constant_buffer_slot0(struct cso_context *cso, /* Optimized version. */ void cso_set_vertex_buffers_and_elements(struct cso_context *ctx, - unsigned velem_count, - const struct pipe_vertex_element *velems, + const struct cso_velems_state *velems, unsigned vb_count, unsigned unbind_trailing_vb_count, const struct pipe_vertex_buffer *vbuffers, diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 8e600797841..bc06265cad8 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -539,7 +539,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex) cso_set_tesseval_shader_handle(cso, NULL); cso_set_geometry_shader_handle(cso, NULL); cso_set_vertex_shader_handle(cso, hud->vs); - cso_set_vertex_elements(cso, 2, hud->velems); + cso_set_vertex_elements(cso, &hud->velems); cso_set_render_condition(cso, NULL, FALSE, 0); cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, 1, &hud->font_sampler_view); @@ -1872,10 +1872,11 @@ hud_create(struct cso_context *cso, struct hud_context *share) hud->rasterizer_aa_lines.line_smooth = 1; /* vertex elements */ + hud->velems.count = 2; for (i = 0; i < 2; i++) { - hud->velems[i].src_offset = i * 2 * sizeof(float); - hud->velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT; - hud->velems[i].vertex_buffer_index = 0; + hud->velems.velems[i].src_offset = i * 2 * sizeof(float); + hud->velems.velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT; + hud->velems.velems[i].vertex_buffer_index = 0; } /* sampler state (for font drawing) */ diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index deed329a8af..da0b47e498d 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -32,6 +32,7 @@ #include "pipe/p_state.h" #include "util/list.h" #include "hud/font.h" +#include "cso_cache/cso_context.h" enum hud_counter { HUD_COUNTER_OFFLOADED, @@ -61,7 +62,7 @@ struct hud_context { void *fs_color, *fs_text; struct pipe_rasterizer_state rasterizer, rasterizer_aa_lines; void *vs; - struct pipe_vertex_element velems[2]; + struct cso_velems_state velems; /* font */ struct util_font font; diff --git a/src/gallium/auxiliary/postprocess/pp_private.h b/src/gallium/auxiliary/postprocess/pp_private.h index 710909b71e2..7e63b5b2e4c 100644 --- a/src/gallium/auxiliary/postprocess/pp_private.h +++ b/src/gallium/auxiliary/postprocess/pp_private.h @@ -30,6 +30,7 @@ #include "postprocess.h" +#include "cso_cache/cso_context.h" /** @@ -48,7 +49,7 @@ struct pp_program struct pipe_sampler_state sampler_point; /* point */ struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; - struct pipe_vertex_element velem[2]; + struct cso_velems_state velem; union pipe_color_union clear_color; diff --git a/src/gallium/auxiliary/postprocess/pp_program.c b/src/gallium/auxiliary/postprocess/pp_program.c index 4cd3990d6ca..65d7f957ac5 100644 --- a/src/gallium/auxiliary/postprocess/pp_program.c +++ b/src/gallium/auxiliary/postprocess/pp_program.c @@ -109,14 +109,15 @@ pp_init_prog(struct pp_queue_t *ppq, struct pipe_context *pipe, PIPE_TEX_FILTER_NEAREST; p->sampler_point.normalized_coords = 1; - p->velem[0].src_offset = 0; - p->velem[0].instance_divisor = 0; - p->velem[0].vertex_buffer_index = 0; - p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - p->velem[1].src_offset = 1 * 4 * sizeof(float); - p->velem[1].instance_divisor = 0; - p->velem[1].vertex_buffer_index = 0; - p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + p->velem.count = 2; + p->velem.velems[0].src_offset = 0; + p->velem.velems[0].instance_divisor = 0; + p->velem.velems[0].vertex_buffer_index = 0; + p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + p->velem.velems[1].src_offset = 1 * 4 * sizeof(float); + p->velem.velems[1].instance_divisor = 0; + p->velem.velems[1].vertex_buffer_index = 0; + p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; if (!p->screen->is_format_supported(p->screen, PIPE_FORMAT_R32G32B32A32_FLOAT, diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c index 41fa7ed69e6..813225332fc 100644 --- a/src/gallium/auxiliary/postprocess/pp_run.c +++ b/src/gallium/auxiliary/postprocess/pp_run.c @@ -277,7 +277,7 @@ pp_filter_misc_state(struct pp_program *p) cso_set_rasterizer(p->cso, &p->rasterizer); cso_set_viewport(p->cso, &p->viewport); - cso_set_vertex_elements(p->cso, 2, p->velem); + cso_set_vertex_elements(p->cso, &p->velem); } /** Draw with the filter to the set output. */ diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 1216766ee84..79e5c6cba91 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -62,7 +62,7 @@ struct blit_state struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; - struct pipe_vertex_element velem[2]; + struct cso_velems_state velem; void *vs; void *fs[PIPE_MAX_TEXTURE_TYPES][4]; @@ -110,11 +110,12 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) ctx->sampler.mag_img_filter = 0; /* set later */ /* vertex elements state */ + ctx->velem.count = 2; for (i = 0; i < 2; i++) { - ctx->velem[i].src_offset = i * 4 * sizeof(float); - ctx->velem[i].instance_divisor = 0; - ctx->velem[i].vertex_buffer_index = 0; - ctx->velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + ctx->velem.velems[i].src_offset = i * 4 * sizeof(float); + ctx->velem.velems[i].instance_divisor = 0; + ctx->velem.velems[i].vertex_buffer_index = 0; + ctx->velem.velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; } ctx->vbuf = NULL; @@ -583,7 +584,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_set_sample_mask(ctx->cso, ~0); cso_set_min_samples(ctx->cso, 1); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); - cso_set_vertex_elements(ctx->cso, 2, ctx->velem); + cso_set_vertex_elements(ctx->cso, &ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, NULL); /* sampler */ diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c index 9751d9bcd6f..8ff22bccd4e 100644 --- a/src/gallium/auxiliary/util/u_tests.c +++ b/src/gallium/auxiliary/util/u_tests.c @@ -134,17 +134,17 @@ static void util_set_interleaved_vertex_elements(struct cso_context *cso, unsigned num_elements) { + struct cso_velems_state velem; unsigned i; - struct pipe_vertex_element *velem = - calloc(1, num_elements * sizeof(struct pipe_vertex_element)); + memset(&velem, 0, sizeof(velem)); + velem.count = num_elements; for (i = 0; i < num_elements; i++) { - velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velem[i].src_offset = i * 16; + velem.velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velem.velems[i].src_offset = i * 16; } - cso_set_vertex_elements(cso, num_elements, velem); - free(velem); + cso_set_vertex_elements(cso, &velem); } static void * diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 0201dc9b2bf..7a6e214b29a 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -167,7 +167,7 @@ struct u_vbuf { struct u_vbuf_elements *ve, *ve_saved; /* Vertex elements used for the translate fallback. */ - struct pipe_vertex_element fallback_velems[PIPE_MAX_ATTRIBS]; + struct cso_velems_state fallback_velems; /* If non-NULL, this is a vertex element state used for the translate * fallback and therefore used for rendering too. */ boolean using_translate; @@ -328,28 +328,26 @@ u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps) /* u_vbuf uses its own caching for vertex elements, because it needs to keep * its own preprocessed state per vertex element CSO. */ static struct u_vbuf_elements * -u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, unsigned count, - const struct pipe_vertex_element *states) +u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, + const struct cso_velems_state *velems) { struct pipe_context *pipe = mgr->pipe; unsigned key_size, hash_key; struct cso_hash_iter iter; struct u_vbuf_elements *ve; - struct cso_velems_state velems_state; /* need to include the count into the stored state data too. */ - key_size = sizeof(struct pipe_vertex_element) * count + sizeof(unsigned); - velems_state.count = count; - memcpy(velems_state.velems, states, - sizeof(struct pipe_vertex_element) * count); - hash_key = cso_construct_key((void*)&velems_state, key_size); + key_size = sizeof(struct pipe_vertex_element) * velems->count + + sizeof(unsigned); + hash_key = cso_construct_key((void*)velems, key_size); iter = cso_find_state_template(mgr->cso_cache, hash_key, CSO_VELEMENTS, - (void*)&velems_state, key_size); + (void*)velems, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_velements *cso = MALLOC_STRUCT(cso_velements); - memcpy(&cso->state, &velems_state, key_size); - cso->data = u_vbuf_create_vertex_elements(mgr, count, states); + memcpy(&cso->state, velems, key_size); + cso->data = u_vbuf_create_vertex_elements(mgr, velems->count, + velems->velems); cso->delete_state = (cso_state_callback)u_vbuf_delete_vertex_elements; cso->context = (void*)mgr; @@ -367,10 +365,10 @@ u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, unsigned count, return ve; } -void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count, - const struct pipe_vertex_element *states) +void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, + const struct cso_velems_state *velems) { - mgr->ve = u_vbuf_set_vertex_elements_internal(mgr, count, states); + mgr->ve = u_vbuf_set_vertex_elements_internal(mgr, velems); } void u_vbuf_unset_vertex_elements(struct u_vbuf *mgr) @@ -726,10 +724,10 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, for (type = 0; type < VB_NUM; type++) { if (elem_index[type][i] < key[type].nr_elements) { struct translate_element *te = &key[type].element[elem_index[type][i]]; - mgr->fallback_velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor; - mgr->fallback_velems[i].src_format = te->output_format; - mgr->fallback_velems[i].src_offset = te->output_offset; - mgr->fallback_velems[i].vertex_buffer_index = mgr->fallback_vbs[type]; + mgr->fallback_velems.velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor; + mgr->fallback_velems.velems[i].src_format = te->output_format; + mgr->fallback_velems.velems[i].src_offset = te->output_offset; + mgr->fallback_velems.velems[i].vertex_buffer_index = mgr->fallback_vbs[type]; /* elem_index[type][i] can only be set for one type. */ assert(type > VB_INSTANCE || elem_index[type+1][i] == ~0u); @@ -739,13 +737,14 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, } /* No translating, just copy the original vertex element over. */ if (type == VB_NUM) { - memcpy(&mgr->fallback_velems[i], &mgr->ve->ve[i], + memcpy(&mgr->fallback_velems.velems[i], &mgr->ve->ve[i], sizeof(struct pipe_vertex_element)); } } - u_vbuf_set_vertex_elements_internal(mgr, mgr->ve->count, - mgr->fallback_velems); + mgr->fallback_velems.count = mgr->ve->count; + + u_vbuf_set_vertex_elements_internal(mgr, &mgr->fallback_velems); mgr->using_translate = TRUE; return TRUE; } @@ -954,7 +953,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, unsigned i; unsigned nr_velems = mgr->ve->count; const struct pipe_vertex_element *velems = - mgr->using_translate ? mgr->fallback_velems : mgr->ve->ve; + mgr->using_translate ? mgr->fallback_velems.velems : mgr->ve->ve; unsigned start_offset[PIPE_MAX_ATTRIBS]; unsigned end_offset[PIPE_MAX_ATTRIBS]; uint32_t buffer_mask = 0; diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h index b364e06344a..3031a30bb47 100644 --- a/src/gallium/auxiliary/util/u_vbuf.h +++ b/src/gallium/auxiliary/util/u_vbuf.h @@ -42,6 +42,7 @@ extern "C" { #include "pipe/p_format.h" struct cso_context; +struct cso_velems_state; struct u_vbuf; /* Hardware vertex fetcher limitations can be described by this structure. */ @@ -73,8 +74,8 @@ u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps); void u_vbuf_destroy(struct u_vbuf *mgr); /* State and draw functions. */ -void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count, - const struct pipe_vertex_element *states); +void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, + const struct cso_velems_state *velems); void u_vbuf_unset_vertex_elements(struct u_vbuf *mgr); void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, unsigned start_slot, unsigned count, diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 43675716a5e..227e9539592 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -813,7 +813,7 @@ update_vertex_elements(struct NineDevice9 *device) char used_streams[device->caps.MaxStreams]; int dummy_vbo_stream = -1; BOOL need_dummy_vbo = FALSE; - struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS]; + struct cso_velems_state ve; context->stream_usage_mask = 0; memset(vdecl_index_map, -1, 16); @@ -856,21 +856,21 @@ update_vertex_elements(struct NineDevice9 *device) for (n = 0; n < vs->num_inputs; ++n) { index = vdecl_index_map[n]; if (index >= 0) { - ve[n] = vdecl->elems[index]; - b = ve[n].vertex_buffer_index; + ve.velems[n] = vdecl->elems[index]; + b = ve.velems[n].vertex_buffer_index; context->stream_usage_mask |= 1 << b; /* XXX wine just uses 1 here: */ if (context->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA) - ve[n].instance_divisor = context->stream_freq[b] & 0x7FFFFF; + ve.velems[n].instance_divisor = context->stream_freq[b] & 0x7FFFFF; } else { /* if the vertex declaration is incomplete compared to what the * vertex shader needs, we bind a dummy vbo with 0 0 0 0. * This is not precised by the spec, but is the behaviour * tested on win */ - ve[n].vertex_buffer_index = dummy_vbo_stream; - ve[n].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - ve[n].src_offset = 0; - ve[n].instance_divisor = 0; + ve.velems[n].vertex_buffer_index = dummy_vbo_stream; + ve.velems[n].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + ve.velems[n].src_offset = 0; + ve.velems[n].instance_divisor = 0; } } @@ -884,7 +884,8 @@ update_vertex_elements(struct NineDevice9 *device) context->dummy_vbo_bound_at = dummy_vbo_stream; } - cso_set_vertex_elements(context->cso, vs->num_inputs, ve); + ve.count = vs->num_inputs; + cso_set_vertex_elements(context->cso, &ve); } static void @@ -2975,7 +2976,7 @@ update_vertex_elements_sw(struct NineDevice9 *device) char used_streams[device->caps.MaxStreams]; int dummy_vbo_stream = -1; BOOL need_dummy_vbo = FALSE; - struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS]; + struct cso_velems_state ve; bool programmable_vs = state->vs && !(state->vdecl && state->vdecl->position_t); memset(vdecl_index_map, -1, 16); @@ -3017,24 +3018,25 @@ update_vertex_elements_sw(struct NineDevice9 *device) for (n = 0; n < vs->num_inputs; ++n) { index = vdecl_index_map[n]; if (index >= 0) { - ve[n] = vdecl->elems[index]; - b = ve[n].vertex_buffer_index; + ve.velems[n] = vdecl->elems[index]; + b = ve.velems[n].vertex_buffer_index; /* XXX wine just uses 1 here: */ if (state->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA) - ve[n].instance_divisor = state->stream_freq[b] & 0x7FFFFF; + ve.velems[n].instance_divisor = state->stream_freq[b] & 0x7FFFFF; } else { /* if the vertex declaration is incomplete compared to what the * vertex shader needs, we bind a dummy vbo with 0 0 0 0. * This is not precised by the spec, but is the behaviour * tested on win */ - ve[n].vertex_buffer_index = dummy_vbo_stream; - ve[n].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - ve[n].src_offset = 0; - ve[n].instance_divisor = 0; + ve.velems[n].vertex_buffer_index = dummy_vbo_stream; + ve.velems[n].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + ve.velems[n].src_offset = 0; + ve.velems[n].instance_divisor = 0; } } - cso_set_vertex_elements(device->cso_sw, vs->num_inputs, ve); + ve.count = vs->num_inputs; + cso_set_vertex_elements(device->cso_sw, &ve); } static void diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c index 582a5fa1308..c1aeacd22ce 100644 --- a/src/gallium/state_trackers/xa/xa_renderer.c +++ b/src/gallium/state_trackers/xa/xa_renderer.c @@ -88,7 +88,11 @@ renderer_draw(struct xa_context *r) r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor); - cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems); + struct cso_velems_state velems; + velems.count = r->attrs_per_vertex; + memcpy(velems.velems, r->velems, sizeof(r->velems[0]) * velems.count); + + cso_set_vertex_elements(r->cso, &velems); util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS, num_verts, /* verts */ r->attrs_per_vertex); /* attribs/vert */ @@ -517,7 +521,11 @@ renderer_draw_yuv(struct xa_context *r, r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor); - cso_set_vertex_elements(r->cso, num_attribs, r->velems); + struct cso_velems_state velems; + velems.count = num_attribs; + memcpy(velems.velems, r->velems, sizeof(r->velems[0]) * velems.count); + + cso_set_vertex_elements(r->cso, &velems); util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS, 4, /* verts */ num_attribs); /* attribs/vert */ diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c index 9a9d7012249..271dee648d6 100644 --- a/src/gallium/tests/trivial/quad-tex.c +++ b/src/gallium/tests/trivial/quad-tex.c @@ -73,7 +73,7 @@ struct program struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; - struct pipe_vertex_element velem[2]; + struct cso_velems_state velem; void *vs; void *fs; @@ -252,16 +252,18 @@ static void init_prog(struct program *p) } /* vertex elements state */ - memset(p->velem, 0, sizeof(p->velem)); - p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ - p->velem[0].instance_divisor = 0; - p->velem[0].vertex_buffer_index = 0; - p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + memset(&p->velem, 0, sizeof(p->velem)); + p->velem.count = 2; - p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ - p->velem[1].instance_divisor = 0; - p->velem[1].vertex_buffer_index = 0; - p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + p->velem.velems[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ + p->velem.velems[0].instance_divisor = 0; + p->velem.velems[0].vertex_buffer_index = 0; + p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + p->velem.velems[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ + p->velem.velems[1].instance_divisor = 0; + p->velem.velems[1].vertex_buffer_index = 0; + p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; /* vertex shader */ { @@ -326,7 +328,7 @@ static void draw(struct program *p) cso_set_vertex_shader_handle(p->cso, p->vs); /* vertex element data */ - cso_set_vertex_elements(p->cso, 2, p->velem); + cso_set_vertex_elements(p->cso, &p->velem); util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0, 0, diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c index 3827edc0da3..1e773cb28f9 100644 --- a/src/gallium/tests/trivial/tri.c +++ b/src/gallium/tests/trivial/tri.c @@ -70,7 +70,7 @@ struct program struct pipe_rasterizer_state rasterizer; struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; - struct pipe_vertex_element velem[2]; + struct cso_velems_state velem; void *vs; void *fs; @@ -196,16 +196,18 @@ static void init_prog(struct program *p) } /* vertex elements state */ - memset(p->velem, 0, sizeof(p->velem)); - p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ - p->velem[0].instance_divisor = 0; - p->velem[0].vertex_buffer_index = 0; - p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + memset(&p->velem, 0, sizeof(p->velem)); + p->velem.count = 2; - p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ - p->velem[1].instance_divisor = 0; - p->velem[1].vertex_buffer_index = 0; - p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + p->velem.velems[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ + p->velem.velems[0].instance_divisor = 0; + p->velem.velems[0].vertex_buffer_index = 0; + p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + p->velem.velems[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ + p->velem.velems[1].instance_divisor = 0; + p->velem.velems[1].vertex_buffer_index = 0; + p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; /* vertex shader */ { @@ -257,7 +259,7 @@ static void draw(struct program *p) cso_set_vertex_shader_handle(p->cso, p->vs); /* vertex element data */ - cso_set_vertex_elements(p->cso, 2, p->velem); + cso_set_vertex_elements(p->cso, &p->velem); util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0, 0, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index ede45d66784..dc7aa135ac6 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -41,6 +41,7 @@ struct st_vertex_program; struct st_common_variant; struct pipe_vertex_buffer; struct pipe_vertex_element; +struct cso_velems_state; /** * Enumeration of state tracker pipelines. @@ -62,7 +63,7 @@ void st_setup_arrays(struct st_context *st, const struct st_vertex_program *vp, const struct st_common_variant *vp_variant, - struct pipe_vertex_element *velements, + struct cso_velems_state *velements, struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers, bool *has_user_vertex_buffers); @@ -70,7 +71,7 @@ void st_setup_current_user(struct st_context *st, const struct st_vertex_program *vp, const struct st_common_variant *vp_variant, - struct pipe_vertex_element *velements, + struct cso_velems_state *velements, struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers); /* Define ST_NEW_xxx_INDEX */ diff --git a/src/mesa/state_tracker/st_atom_array.c b/src/mesa/state_tracker/st_atom_array.c index b4af4c3e629..16f7414fab6 100644 --- a/src/mesa/state_tracker/st_atom_array.c +++ b/src/mesa/state_tracker/st_atom_array.c @@ -132,7 +132,7 @@ ALWAYS_INLINE st_setup_arrays(struct st_context *st, const struct st_vertex_program *vp, const struct st_common_variant *vp_variant, - struct pipe_vertex_element *velements, + struct cso_velems_state *velements, struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers, bool *has_user_vertex_buffers) { @@ -184,7 +184,7 @@ st_setup_arrays(struct st_context *st, const struct gl_array_attributes *const attrib = _mesa_draw_array_attrib(vao, attr); const GLuint off = _mesa_draw_attributes_relative_offset(attrib); - init_velement(vp, velements, &attrib->Format, off, + init_velement(vp, velements->velems, &attrib->Format, off, binding->InstanceDivisor, bufidx, input_to_index[attr]); } while (attrmask); @@ -201,7 +201,7 @@ static int ALWAYS_INLINE st_setup_current(struct st_context *st, const struct st_vertex_program *vp, const struct st_common_variant *vp_variant, - struct pipe_vertex_element *velements, + struct cso_velems_state *velements, struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers) { struct gl_context *ctx = st->ctx; @@ -228,8 +228,8 @@ st_setup_current(struct st_context *st, if (alignment != size) memset(cursor + size, 0, alignment - size); - init_velement(vp, velements, &attrib->Format, cursor - data, 0, - bufidx, input_to_index[attr]); + init_velement(vp, velements->velems, &attrib->Format, cursor - data, + 0, bufidx, input_to_index[attr]); cursor += alignment; } while (curmask); @@ -263,7 +263,7 @@ void st_setup_current_user(struct st_context *st, const struct st_vertex_program *vp, const struct st_common_variant *vp_variant, - struct pipe_vertex_element *velements, + struct cso_velems_state *velements, struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers) { struct gl_context *ctx = st->ctx; @@ -279,7 +279,7 @@ st_setup_current_user(struct st_context *st, = _mesa_draw_current_attrib(ctx, attr); const unsigned bufidx = (*num_vbuffers)++; - init_velement(vp, velements, &attrib->Format, 0, 0, + init_velement(vp, velements->velems, &attrib->Format, 0, 0, bufidx, input_to_index[attr]); vbuffer[bufidx].is_user_buffer = true; @@ -299,29 +299,27 @@ st_update_array(struct st_context *st) struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS]; unsigned num_vbuffers = 0; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; - unsigned num_velements; + struct cso_velems_state velements; bool uses_user_vertex_buffers; /* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */ /* Setup arrays */ - st_setup_arrays(st, vp, vp_variant, velements, vbuffer, &num_vbuffers, + st_setup_arrays(st, vp, vp_variant, &velements, vbuffer, &num_vbuffers, &uses_user_vertex_buffers); /* _NEW_CURRENT_ATTRIB */ /* Setup zero-stride attribs. */ int current_attrib_buffer = - st_setup_current(st, vp, vp_variant, velements, vbuffer, &num_vbuffers); + st_setup_current(st, vp, vp_variant, &velements, vbuffer, &num_vbuffers); - /* Set the array into cso */ - num_velements = vp->num_inputs + vp_variant->key.passthrough_edgeflags; + velements.count = vp->num_inputs + vp_variant->key.passthrough_edgeflags; /* Set vertex buffers and elements. */ struct cso_context *cso = st->cso_context; unsigned unbind_trailing_vbuffers = st->last_num_vbuffers > num_vbuffers ? st->last_num_vbuffers - num_vbuffers : 0; - cso_set_vertex_buffers_and_elements(cso, num_velements, velements, + cso_set_vertex_buffers_and_elements(cso, &velements, num_vbuffers, unbind_trailing_vbuffers, vbuffer, uses_user_vertex_buffers); diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 112af82815a..788e004d651 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -255,7 +255,8 @@ setup_render_state(struct gl_context *ctx, st->state.fb_height, st->state.fb_orientation == Y_0_TOP); - cso_set_vertex_elements(cso, 3, st->util_velems); + st->util_velems.count = 3; + cso_set_vertex_elements(cso, &st->util_velems); cso_set_stream_outputs(st->cso_context, 0, NULL, NULL); } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 8334e6dfcac..436f7019ae2 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -321,7 +321,9 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) cso_set_depth_stencil_alpha(cso, &depth_stencil); } - cso_set_vertex_elements(cso, 2, st->util_velems); + st->util_velems.count = 2; + cso_set_vertex_elements(cso, &st->util_velems); + cso_set_stream_outputs(cso, 0, NULL, NULL); cso_set_sample_mask(cso, ~0); cso_set_min_samples(cso, 1); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 2f2b98ecb6f..5fb2fba2f24 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -896,7 +896,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, /* viewport state: viewport matching window dims */ cso_set_viewport_dims(cso, fb_width, fb_height, TRUE); - cso_set_vertex_elements(cso, 3, st->util_velems); + st->util_velems.count = 3; + cso_set_vertex_elements(cso, &st->util_velems); cso_set_stream_outputs(cso, 0, NULL, NULL); /* Compute Gallium window coords (y=0=top) with pixel zoom. diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index bba1ce41376..ebcfe1973fc 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -170,7 +170,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, GLboolean emitColor; enum tgsi_semantic semantic_names[2 + MAX_TEXTURE_UNITS]; uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; - struct pipe_vertex_element velements[2 + MAX_TEXTURE_UNITS]; + struct cso_velems_state velems; unsigned offset; st_flush_bitmap_cache(st); @@ -308,12 +308,14 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, cso_set_geometry_shader_handle(cso, NULL); for (i = 0; i < numAttribs; i++) { - velements[i].src_offset = i * 4 * sizeof(float); - velements[i].instance_divisor = 0; - velements[i].vertex_buffer_index = 0; - velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velems.velems[i].src_offset = i * 4 * sizeof(float); + velems.velems[i].instance_divisor = 0; + velems.velems[i].vertex_buffer_index = 0; + velems.velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; } - cso_set_vertex_elements(cso, numAttribs, velements); + velems.count = numAttribs; + + cso_set_vertex_elements(cso, &velems); cso_set_stream_outputs(cso, 0, NULL, NULL); /* viewport state: viewport matching window dims */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index b67850e1f04..baf354639e2 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -605,15 +605,15 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, STATIC_ASSERT(sizeof(struct st_util_vertex) == 9 * sizeof(float)); memset(&st->util_velems, 0, sizeof(st->util_velems)); - st->util_velems[0].src_offset = 0; - st->util_velems[0].vertex_buffer_index = 0; - st->util_velems[0].src_format = PIPE_FORMAT_R32G32B32_FLOAT; - st->util_velems[1].src_offset = 3 * sizeof(float); - st->util_velems[1].vertex_buffer_index = 0; - st->util_velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - st->util_velems[2].src_offset = 7 * sizeof(float); - st->util_velems[2].vertex_buffer_index = 0; - st->util_velems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; + st->util_velems.velems[0].src_offset = 0; + st->util_velems.velems[0].vertex_buffer_index = 0; + st->util_velems.velems[0].src_format = PIPE_FORMAT_R32G32B32_FLOAT; + st->util_velems.velems[1].src_offset = 3 * sizeof(float); + st->util_velems.velems[1].vertex_buffer_index = 0; + st->util_velems.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + st->util_velems.velems[2].src_offset = 7 * sizeof(float); + st->util_velems.velems[2].vertex_buffer_index = 0; + st->util_velems.velems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; } /* Need these flags: diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 853a1895825..267aa32ad78 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -38,6 +38,7 @@ #include "util/list.h" #include "vbo/vbo.h" #include "util/list.h" +#include "cso_cache/cso_context.h" #ifdef __cplusplus @@ -322,7 +323,7 @@ struct st_context } pbo; /** for drawing with st_util_vertex */ - struct pipe_vertex_element util_velems[3]; + struct cso_velems_state util_velems; /** passthrough vertex shader matching the util_velem attributes */ void *passthrough_vs; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 813a6388c79..16c88efa2ae 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -110,7 +110,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, struct st_common_variant *vp_variant; struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS]; unsigned num_vbuffers = 0; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; + struct cso_velems_state velements; struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {NULL}; struct pipe_transfer *ib_transfer = NULL; GLuint i; @@ -160,10 +160,10 @@ st_feedback_draw_vbo(struct gl_context *ctx, /* Must setup these after state validation! */ /* Setup arrays */ bool uses_user_vertex_buffers; - st_setup_arrays(st, vp, vp_variant, velements, vbuffers, &num_vbuffers, + st_setup_arrays(st, vp, vp_variant, &velements, vbuffers, &num_vbuffers, &uses_user_vertex_buffers); /* Setup current values as userspace arrays */ - st_setup_current_user(st, vp, vp_variant, velements, vbuffers, &num_vbuffers); + st_setup_current_user(st, vp, vp_variant, &velements, vbuffers, &num_vbuffers); /* Map all buffers and tell draw about their mapping */ for (unsigned buf = 0; buf < num_vbuffers; ++buf) { @@ -180,7 +180,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, } draw_set_vertex_buffers(draw, 0, num_vbuffers, vbuffers); - draw_set_vertex_elements(draw, vp->num_inputs, velements); + draw_set_vertex_elements(draw, vp->num_inputs, velements.velems); unsigned start = 0; diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c index 3f11a897594..bbb348f0200 100644 --- a/src/mesa/state_tracker/st_pbo.c +++ b/src/mesa/state_tracker/st_pbo.c @@ -219,7 +219,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr, /* Upload vertices */ { struct pipe_vertex_buffer vbo = {0}; - struct pipe_vertex_element velem; + struct cso_velems_state velem; float x0 = (float) addr->xoffset / surface_width * 2.0f - 1.0f; float y0 = (float) addr->yoffset / surface_height * 2.0f - 1.0f; @@ -246,14 +246,15 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr, u_upload_unmap(st->pipe->stream_uploader); - velem.src_offset = 0; - velem.instance_divisor = 0; - velem.vertex_buffer_index = 0; - velem.src_format = PIPE_FORMAT_R32G32_FLOAT; + velem.count = 1; + velem.velems[0].src_offset = 0; + velem.velems[0].instance_divisor = 0; + velem.velems[0].vertex_buffer_index = 0; + velem.velems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; - cso_set_vertex_elements(cso, 1, &velem); + cso_set_vertex_elements(cso, &velem); - cso_set_vertex_buffers(cso, velem.vertex_buffer_index, 1, &vbo); + cso_set_vertex_buffers(cso, 0, 1, &vbo); pipe_resource_reference(&vbo.buffer.resource, NULL); } |