i965: Use bo_map instead of subdata to upload the bits of constant buffer.
authorEric Anholt <eric@anholt.net>
Thu, 12 Nov 2009 22:57:30 +0000 (14:57 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 13 Nov 2009 21:18:57 +0000 (13:18 -0800)
Saves CPU time, resulting in a 2.5% FPS win on ETQW.

src/mesa/drivers/dri/i965/brw_vs_surface_state.c
src/mesa/drivers/dri/intel/intel_context.h

index 5dac632969331c15aec13022368ca750d7b8b689..3bc9840a9719ad1bb59e452f23fb6afc39a3e91f 100644 (file)
@@ -68,10 +68,13 @@ brw_vs_update_constant_buffer(struct brw_context *brw)
     */
    _mesa_load_state_parameters(&brw->intel.ctx, vp->program.Base.Parameters);
 
+   intel_bo_map_gtt_preferred(intel, const_buffer, GL_TRUE);
    for (i = 0; i < params->NumParameters; i++) {
-      dri_bo_subdata(const_buffer, i * 4 * sizeof(float), 4 * sizeof(float),
-                    params->ParameterValues[i]);
+      memcpy(const_buffer->virtual + i * 4 * sizeof(float),
+            params->ParameterValues[i],
+            4 * sizeof(float));
    }
+   intel_bo_unmap_gtt_preferred(intel, const_buffer);
 
    return const_buffer;
 }
index 84fbfc564c033109a42f1fd29cc63b8b31d95624..8936f757a42b4fa731e8238b75dd1bb4cbc6dec6 100644 (file)
@@ -590,4 +590,25 @@ is_power_of_two(uint32_t value)
    return (value & (value - 1)) == 0;
 }
 
+static inline void
+intel_bo_map_gtt_preferred(struct intel_context *intel,
+                          drm_intel_bo *bo,
+                          GLboolean write)
+{
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_map_gtt(bo);
+   else
+      drm_intel_bo_map(bo, write);
+}
+
+static inline void
+intel_bo_unmap_gtt_preferred(struct intel_context *intel,
+                            drm_intel_bo *bo)
+{
+   if (intel->intelScreen->kernel_exec_fencing)
+      drm_intel_gem_bo_unmap_gtt(bo);
+   else
+      drm_intel_bo_unmap(bo);
+}
+
 #endif