summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/vc5/vc5_context.h1
-rw-r--r--src/gallium/drivers/vc5/vc5_draw.c31
-rw-r--r--src/gallium/drivers/vc5/vc5_state.c20
3 files changed, 23 insertions, 29 deletions
diff --git a/src/gallium/drivers/vc5/vc5_context.h b/src/gallium/drivers/vc5/vc5_context.h
index 08d96f36ecf..a1017bd1a6a 100644
--- a/src/gallium/drivers/vc5/vc5_context.h
+++ b/src/gallium/drivers/vc5/vc5_context.h
@@ -164,6 +164,7 @@ struct vc5_vertex_stateobj {
unsigned num_elements;
uint8_t attrs[12 * VC5_MAX_ATTRIBUTES];
+ struct vc5_bo *default_attribute_values;
};
struct vc5_streamout_stateobj {
diff --git a/src/gallium/drivers/vc5/vc5_draw.c b/src/gallium/drivers/vc5/vc5_draw.c
index f6c22c9d182..11d9e92a96b 100644
--- a/src/gallium/drivers/vc5/vc5_draw.c
+++ b/src/gallium/drivers/vc5/vc5_draw.c
@@ -123,32 +123,6 @@ vc5_predraw_check_textures(struct pipe_context *pctx,
}
}
-static struct vc5_cl_reloc
-vc5_get_default_values(struct vc5_context *vc5)
-{
- struct vc5_job *job = vc5->job;
-
- /* VC5_DIRTY_VTXSTATE */
- struct vc5_vertex_stateobj *vtx = vc5->vtx;
-
- /* Set up the default values for attributes. */
- vc5_cl_ensure_space(&job->indirect, 4 * 4 * vtx->num_elements, 4);
- struct vc5_cl_reloc default_values =
- cl_address(job->indirect.bo, cl_offset(&job->indirect));
- vc5_bo_reference(default_values.bo);
-
- struct vc5_cl_out *defaults = cl_start(&job->indirect);
- for (int i = 0; i < vtx->num_elements; i++) {
- cl_aligned_f(&defaults, 0.0);
- cl_aligned_f(&defaults, 0.0);
- cl_aligned_f(&defaults, 0.0);
- cl_aligned_f(&defaults, 1.0);
- }
- cl_end(&job->indirect, defaults);
-
- return default_values;
-}
-
static void
vc5_emit_gl_shader_state(struct vc5_context *vc5,
const struct pipe_draw_info *info)
@@ -172,7 +146,6 @@ vc5_emit_gl_shader_state(struct vc5_context *vc5,
vc5_write_uniforms(vc5, vc5->prog.cs,
&vc5->constbuf[PIPE_SHADER_VERTEX],
&vc5->verttex);
- struct vc5_cl_reloc default_values = vc5_get_default_values(vc5);
uint32_t shader_rec_offset =
vc5_cl_ensure_space(&job->indirect,
@@ -236,7 +209,8 @@ vc5_emit_gl_shader_state(struct vc5_context *vc5,
shader.instance_id_read_by_vertex_shader =
vc5->prog.vs->prog_data.vs->uses_iid;
- shader.address_of_default_attribute_values = default_values;
+ shader.address_of_default_attribute_values =
+ cl_address(vtx->default_attribute_values, 0);
}
for (int i = 0; i < vtx->num_elements; i++) {
@@ -274,7 +248,6 @@ vc5_emit_gl_shader_state(struct vc5_context *vc5,
vc5_bo_unreference(&cs_uniforms.bo);
vc5_bo_unreference(&vs_uniforms.bo);
vc5_bo_unreference(&fs_uniforms.bo);
- vc5_bo_unreference(&default_values.bo);
job->shader_rec_count++;
}
diff --git a/src/gallium/drivers/vc5/vc5_state.c b/src/gallium/drivers/vc5/vc5_state.c
index 98426de977b..eebf94b4b9c 100644
--- a/src/gallium/drivers/vc5/vc5_state.c
+++ b/src/gallium/drivers/vc5/vc5_state.c
@@ -238,6 +238,7 @@ static void *
vc5_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
const struct pipe_vertex_element *elements)
{
+ struct vc5_context *vc5 = vc5_context(pctx);
struct vc5_vertex_stateobj *so = CALLOC_STRUCT(vc5_vertex_stateobj);
if (!so)
@@ -311,6 +312,25 @@ vc5_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
&attr_unpacked);
}
+ /* Set up the default attribute values in case any of the vertex
+ * elements use them.
+ */
+ so->default_attribute_values = vc5_bo_alloc(vc5->screen,
+ VC5_MAX_ATTRIBUTES *
+ 4 * sizeof(float),
+ "default attributes");
+ uint32_t *attrs = vc5_bo_map(so->default_attribute_values);
+ for (int i = 0; i < VC5_MAX_ATTRIBUTES; i++) {
+ attrs[i * 4 + 0] = 0;
+ attrs[i * 4 + 1] = 0;
+ attrs[i * 4 + 2] = 0;
+ if (i < so->num_elements &&
+ util_format_is_pure_integer(so->pipe[i].src_format)) {
+ attrs[i * 4 + 3] = 1;
+ } else {
+ attrs[i * 4 + 3] = fui(1.0);
+ }
+ }
return so;
}