aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c33
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h7
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c9
-rw-r--r--src/gallium/auxiliary/hud/hud_private.h3
-rw-r--r--src/gallium/auxiliary/postprocess/pp_private.h3
-rw-r--r--src/gallium/auxiliary/postprocess/pp_program.c17
-rw-r--r--src/gallium/auxiliary/postprocess/pp_run.c2
-rw-r--r--src/gallium/auxiliary/util/u_blit.c13
-rw-r--r--src/gallium/auxiliary/util/u_tests.c12
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c45
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.h5
11 files changed, 74 insertions, 75 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,