aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-02-15 00:04:32 +0100
committerMarek Olšák <[email protected]>2010-02-15 04:03:12 +0100
commitd3d3345cb840bdfb4a0040ca86e8a588e9b68051 (patch)
treea8f10dec79a9d0699864d07061d5404c660fb624 /src/gallium
parent21fe86b036451bb8352ed6aa0774d49f45fcd417 (diff)
r300g: fix the size of constant buffers
4 more piglit tests pass, sweet.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/r300/r300_context.h3
-rw-r--r--src/gallium/drivers/r300/r300_screen.c4
-rw-r--r--src/gallium/drivers/r300/r300_state.c29
3 files changed, 34 insertions, 2 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index ac2b08b41c2..1eba8a8ed12 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -155,8 +155,7 @@ struct r300_ztop_state {
struct r300_constant_buffer {
/* Buffer of constants */
- /* XXX first number should be raised */
- float constants[32][4];
+ float constants[256][4];
/* Total number of constants */
unsigned count;
};
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 8e9f51aba2d..b892c084c04 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -152,6 +152,10 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
} else {
return 0;
}
+ case PIPE_CAP_MAX_CONST_BUFFERS:
+ return 1;
+ case PIPE_CAP_MAX_CONST_BUFFER_SIZE:
+ return 256;
case PIPE_CAP_INDEP_BLEND_ENABLE:
return 0;
case PIPE_CAP_INDEP_BLEND_FUNC:
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index b4c8ca45ab7..34bf81c1930 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1150,7 +1150,9 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
struct pipe_buffer *buf)
{
struct r300_context* r300 = r300_context(pipe);
+ struct r300_screen *r300screen = r300_screen(pipe->screen);
void *mapped;
+ int max_size = 0;
if (buf == NULL || buf->size == 0 ||
(mapped = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_READ)) == NULL)
@@ -1160,6 +1162,33 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
}
assert((buf->size % 4 * sizeof(float)) == 0);
+
+ /* Check the size of the constant buffer. */
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ max_size = 256;
+ break;
+ case PIPE_SHADER_FRAGMENT:
+ if (r300screen->caps->is_r500) {
+ max_size = 256;
+ /* XXX Implement emission of r400's extended constant buffer. */
+ /*} else if (r300screen->caps->is_r400) {
+ max_size = 64;*/
+ } else {
+ max_size = 32;
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ /* XXX Subtract immediates and RC_STATE_* variables. */
+ if (buf->size > (sizeof(float) * 4 * max_size)) {
+ debug_printf("r300: Max size of the constant buffer is "
+ "%i*4 floats.\n", max_size);
+ abort();
+ }
+
memcpy(r300->shader_constants[shader].constants, mapped, buf->size);
r300->shader_constants[shader].count = buf->size / (4 * sizeof(float));
pipe_buffer_unmap(pipe->screen, buf);