[Mesa-dev] [PATCH] i965: Use intel_upload_map/unmap for pull constant uploads.
Eric Anholt
eric at anholt.net
Fri Nov 15 10:47:47 PST 2013
No difference on GLB2.7 low resolution (n=1885/1886), but that isn't CPU
bound anyway at about 20-30% load. Some quick testing of DOTA2 showed no
difference (n of either 3 or 5, I forget), but it does cut a bunch of GPU
stalls at the start of a match when the GTT is getting cleaned up from all
the texture upload mappings, plus the frame working set size dropped by
200k or so because we could pack multiple constant uploads into one upload
BO.
---
src/mesa/drivers/dri/i965/brw_context.h | 3 +++
src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 19 ++++++++-----------
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 14 ++++++--------
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 8b1cbb3..bf88aa9 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -934,6 +934,9 @@ struct brw_stage_state
/** Pull constant buffer */
drm_intel_bo *const_bo;
+ /** Offset into the const_bo the constants are actually located at. */
+ uint32_t const_offset;
+
/** Offset in the program cache to the program */
uint32_t prog_offset;
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index 9834c11..ba2152f 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -34,7 +34,7 @@
#include "brw_context.h"
#include "brw_state.h"
-
+#include "intel_buffer_objects.h"
void
brw_upload_vec4_pull_constants(struct brw_context *brw,
@@ -62,15 +62,10 @@ brw_upload_vec4_pull_constants(struct brw_context *brw,
}
/* _NEW_PROGRAM_CONSTANTS */
- drm_intel_bo_unreference(stage_state->const_bo);
uint32_t size = prog_data->nr_pull_params * 4;
- stage_state->const_bo = drm_intel_bo_alloc(brw->bufmgr, "vec4_const_buffer",
- size, 64);
-
- drm_intel_gem_bo_map_gtt(stage_state->const_bo);
-
+ float *constants = intel_upload_map(brw, size, 16);
for (i = 0; i < prog_data->nr_pull_params; i++) {
- memcpy(stage_state->const_bo->virtual + i * 4,
+ memcpy(constants + i,
prog_data->pull_param[i],
4);
}
@@ -82,10 +77,12 @@ brw_upload_vec4_pull_constants(struct brw_context *brw,
i, row[0], row[1], row[2], row[3]);
}
}
+ drm_intel_bo_unreference(stage_state->const_bo);
+ intel_upload_unmap(brw, constants, size, 16, &stage_state->const_bo,
+ &stage_state->const_offset);
- drm_intel_gem_bo_unmap_gtt(stage_state->const_bo);
-
- brw_create_constant_surface(brw, stage_state->const_bo, 0, size,
+ brw_create_constant_surface(brw, stage_state->const_bo,
+ stage_state->const_offset, size,
&stage_state->surf_offset[surf_index],
false);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 662c975..3aa5049 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -457,19 +457,17 @@ brw_upload_wm_pull_constants(struct brw_context *brw)
return;
}
- drm_intel_bo_unreference(brw->wm.base.const_bo);
- brw->wm.base.const_bo = drm_intel_bo_alloc(brw->bufmgr, "WM const bo",
- size, 64);
-
/* _NEW_PROGRAM_CONSTANTS */
- drm_intel_gem_bo_map_gtt(brw->wm.base.const_bo);
- constants = brw->wm.base.const_bo->virtual;
+ constants = intel_upload_map(brw, size, 16);
for (i = 0; i < brw->wm.prog_data->nr_pull_params; i++) {
constants[i] = *brw->wm.prog_data->pull_param[i];
}
- drm_intel_gem_bo_unmap_gtt(brw->wm.base.const_bo);
+ drm_intel_bo_unreference(brw->wm.base.const_bo);
+ intel_upload_unmap(brw, constants, size, 16, &brw->wm.base.const_bo,
+ &brw->wm.base.const_offset);
- brw_create_constant_surface(brw, brw->wm.base.const_bo, 0, size,
+ brw_create_constant_surface(brw, brw->wm.base.const_bo,
+ brw->wm.base.const_offset, size,
&brw->wm.base.surf_offset[surf_index],
true);
--
1.8.4.rc3
More information about the mesa-dev
mailing list