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;
};
} 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:
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)
}
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);