/** Offset within curbe_bo of space for next curbe entry */
GLuint curbe_next_offset;
+ /**
+ * Copy of the last set of CURBEs uploaded. Frequently we'll end up
+ * in brw_curbe.c with the same set of constant data to be uploaded,
+ * so we'd rather not upload new constants in that case (it can cause
+ * a pipeline bubble since only up to 4 can be pipelined at a time).
+ */
GLfloat *last_buf;
+ /**
+ * Allocation for where to calculate the next set of CURBEs.
+ * It's a hot enough path that malloc/free of that data matters.
+ */
+ GLfloat *next_buf;
GLuint last_bufsz;
} curbe;
GLuint i;
if (sz == 0) {
- if (brw->curbe.last_buf) {
- free(brw->curbe.last_buf);
- brw->curbe.last_buf = NULL;
- brw->curbe.last_bufsz = 0;
- }
+ brw->curbe.last_bufsz = 0;
return;
}
- buf = (GLfloat *) calloc(1, bufsz);
+ buf = brw->curbe.next_buf;
/* fragment shader constants */
if (brw->curbe.wm_size) {
}
if (brw->curbe.curbe_bo != NULL &&
- brw->curbe.last_buf &&
bufsz == brw->curbe.last_bufsz &&
memcmp(buf, brw->curbe.last_buf, bufsz) == 0) {
/* constants have not changed */
- free(buf);
- }
- else {
- /* constants have changed */
- if (brw->curbe.last_buf)
- free(brw->curbe.last_buf);
-
- brw->curbe.last_buf = buf;
+ } else {
+ /* Update the record of what our last set of constants was. We
+ * don't just flip the pointers because we don't fill in the
+ * data in the padding between the entries.
+ */
+ memcpy(brw->curbe.last_buf, buf, bufsz);
brw->curbe.last_bufsz = bufsz;
if (brw->curbe.curbe_bo != NULL &&
4096, 1 << 6);
brw->curbe.curbe_next_offset = 0;
drm_intel_gem_bo_map_gtt(brw->curbe.curbe_bo);
+ assert(bufsz < 4096);
}
brw->curbe.curbe_offset = brw->curbe.curbe_next_offset;