FREE(r300->viewport_state.state);
FREE(r300->ztop_state.state);
FREE(r300->fs_constants.state);
+ FREE(r300->vs_constants.state);
FREE(r300);
}
R300_INIT_ATOM(vap_output_state, 6);
R300_INIT_ATOM(pvs_flush, 2);
R300_INIT_ATOM(vs_state, 0);
+ R300_INIT_ATOM(vs_constants, 0);
R300_INIT_ATOM(texture_cache_inval, 2);
R300_INIT_ATOM(textures_state, 0);
R300_INIT_ATOM(fs, 0);
r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
+ r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
}
struct pipe_context* r300_create_context(struct pipe_screen* screen,
struct r300_atom blend_color_state;
/* User clip planes. */
struct r300_atom clip_state;
- /* Shader constants. */
- struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
/* Depth, stencil, and alpha state. */
struct r300_atom dsa_state;
/* Fragment shader. */
struct r300_atom vap_output_state;
/* Vertex shader. */
struct r300_atom vs_state;
+ /* Vertex shader constant buffer. */
+ struct r300_atom vs_constants;
/* Viewport state. */
struct r300_atom viewport_state;
/* ZTOP state. */
#define R300_RESOURCE_FLAG_TRANSFER PIPE_RESOURCE_FLAG_DRV_PRIV
/* Non-atom dirty state flags. */
-#define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000
#define R300_NEW_QUERY 0x40000000
#define R300_NEW_KITCHEN_SINK 0x7fffffff
END_CS;
}
-void r300_emit_vs_constant_buffer(struct r300_context* r300,
- struct rc_constant_list* constants)
+void r300_emit_vs_constants(struct r300_context* r300,
+ unsigned size, void *state)
{
unsigned i;
- unsigned count = ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count;
+ unsigned count =
+ ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count;
+ struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state;
CS_LOCALS(r300);
- BEGIN_CS(count * 4 + 3);
+ if (!count)
+ return;
+
+ BEGIN_CS(size);
OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
(r300->screen->caps.is_r500 ?
R500_PVS_CONST_START : R300_PVS_CONST_START));
OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4);
for (i = 0; i < count; i++) {
- const float *data =
- r300->shader_constants[PIPE_SHADER_VERTEX].constants[i];
+ const float *data = buf->constants[i];
OUT_CS_32F(data[0]);
OUT_CS_32F(data[1]);
OUT_CS_32F(data[2]);
}
}
- if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) {
- struct r300_vertex_shader* vs = r300->vs_state.state;
- if (vs->code.constants.Count) {
- r300_emit_vs_constant_buffer(r300, &vs->code.constants);
- }
- r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS;
- }
-
/* Emit the VBO for SWTCL. */
if (!r300screen->caps.has_tcl) {
r300_emit_vertex_buffer(r300);
void r300_emit_vap_output_state(struct r300_context* r300,
unsigned size, void* state);
-void r300_emit_vs_constant_buffer(struct r300_context* r300,
- struct rc_constant_list* constants);
+void r300_emit_vs_constants(struct r300_context* r300,
+ unsigned size, void *state);
void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state);
/* Unmark HWTCL state for SWTCL. */
if (!r300->screen->caps.has_tcl) {
r300->vs_state.dirty = FALSE;
- r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS;
+ r300->vs_constants.dirty = FALSE;
}
}
vs->code.length + 9 +
(vs->immediates_count ? vs->immediates_count * 4 + 3 : 0);
- r300->pvs_flush.dirty = TRUE;
+ if (vs->externals_count) {
+ r300->vs_constants.dirty = TRUE;
+ r300->vs_constants.size = vs->externals_count * 4 + 3;
+ } else {
+ r300->vs_constants.size = 0;
+ }
- r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS;
+ r300->pvs_flush.dirty = TRUE;
} else {
draw_flush(r300->draw);
draw_bind_vertex_shader(r300->draw,
switch (shader) {
case PIPE_SHADER_VERTEX:
- cbuf = &r300->shader_constants[PIPE_SHADER_VERTEX];
+ cbuf = (struct r300_constant_buffer*)r300->vs_constants.state;
max_size = 256;
break;
case PIPE_SHADER_FRAGMENT:
break;
default:
assert(0);
- cbuf = NULL;
+ return;
}
if (buf == NULL || buf->width0 == 0 ||
if (shader == PIPE_SHADER_VERTEX) {
if (r300->screen->caps.has_tcl) {
- r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS;
+ if (r300->vs_constants.size) {
+ r300->vs_constants.dirty = TRUE;
+ }
r300->pvs_flush.dirty = TRUE;
} else if (r300->draw) {
draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX,