GLuint total_grf;
GLbitfield64 outputs_written;
GLuint nr_params; /**< number of float params/constants */
+ GLuint total_scratch;
GLuint inputs_read;
struct brw_vs_prog_data *prog_data;
int8_t *constant_map; /* variable array following prog_data */
+ drm_intel_bo *scratch_bo;
drm_intel_bo *const_bo;
/** Offset in the program cache to the VS program */
uint32_t prog_offset;
*/
void brwInitFragProgFuncs( struct dd_function_table *functions );
+int brw_get_scratch_size(int size);
+void brw_get_scratch_bo(struct intel_context *intel,
+ drm_intel_bo **scratch_bo, int size);
+
/* brw_urb.c
*/
return GL_TRUE;
}
+/* Per-thread scratch space is a power-of-two multiple of 1KB. */
+int
+brw_get_scratch_size(int size)
+{
+ int i;
+
+ for (i = 1024; i < size; i *= 2)
+ ;
+
+ return i;
+}
+
+void
+brw_get_scratch_bo(struct intel_context *intel,
+ drm_intel_bo **scratch_bo, int size)
+{
+ drm_intel_bo *old_bo = *scratch_bo;
+
+ if (old_bo && old_bo->size < size) {
+ drm_intel_bo_unreference(old_bo);
+ old_bo = NULL;
+ }
+
+ if (!old_bo) {
+ *scratch_bo = drm_intel_bo_alloc(intel->bufmgr, "scratch bo", size, 4096);
+ }
+}
+
void brwInitFragProgFuncs( struct dd_function_table *functions )
{
assert(functions->ProgramStringNotify == _tnl_program_string);
struct brw_vs_prog_key *key )
{
struct gl_context *ctx = &brw->intel.ctx;
+ struct intel_context *intel = &brw->intel;
GLuint program_size;
const GLuint *program;
struct brw_vs_compile c;
brw_old_vs_emit(&c);
}
+ /* Scratch space is used for register spilling */
+ if (c.last_scratch) {
+ c.prog_data.total_scratch = brw_get_scratch_size(c.last_scratch);
+
+ brw_get_scratch_bo(intel, &brw->vs.scratch_bo,
+ c.prog_data.total_scratch * brw->vs_max_threads);
+ }
+
/* get the program
*/
program = brw_get_program(&c.func, &program_size);
GLuint first_output;
GLuint nr_outputs;
GLuint first_overflow_output; /**< VERT_ATTRIB_x */
+ GLuint last_scratch;
GLuint first_tmp;
GLuint last_tmp;
/* Scratch space is used for register spilling */
if (c->last_scratch) {
- uint32_t total_scratch;
+ c->prog_data.total_scratch = brw_get_scratch_size(c->last_scratch);
- /* Per-thread scratch space is power-of-two sized. */
- for (c->prog_data.total_scratch = 1024;
- c->prog_data.total_scratch <= c->last_scratch;
- c->prog_data.total_scratch *= 2) {
- /* empty */
- }
- total_scratch = c->prog_data.total_scratch * brw->wm_max_threads;
-
- if (brw->wm.scratch_bo && total_scratch > brw->wm.scratch_bo->size) {
- drm_intel_bo_unreference(brw->wm.scratch_bo);
- brw->wm.scratch_bo = NULL;
- }
- if (brw->wm.scratch_bo == NULL) {
- brw->wm.scratch_bo = drm_intel_bo_alloc(intel->bufmgr,
- "wm scratch",
- total_scratch,
- 4096);
- }
- }
- else {
- c->prog_data.total_scratch = 0;
+ brw_get_scratch_bo(intel, &brw->vs.scratch_bo,
+ c->prog_data.total_scratch * brw->wm_max_threads);
}
if (unlikely(INTEL_DEBUG & DEBUG_WM))