i965/blorp: Refactor getting the blit kernel into a helper
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 29 Apr 2016 19:34:10 +0000 (12:34 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 14 May 2016 20:34:53 +0000 (13:34 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp

index ca20015190e216ff7b39a1f38bc3c8b21bc93517..a3ebdb874866f80fd3eaf0faa9e8b54aff16764f 100644 (file)
@@ -1737,6 +1737,27 @@ brw_blorp_blit_program::texture_lookup(struct brw_reg dst,
 #undef S
 #undef SWAP_XY_AND_XPYP
 
+static void
+brw_blorp_get_blit_kernel(struct brw_context *brw,
+                          struct brw_blorp_params *params,
+                          const struct brw_blorp_blit_prog_key *prog_key)
+{
+   if (brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
+                        prog_key, sizeof(*prog_key),
+                        &params->wm_prog_kernel, &params->wm_prog_data))
+      return;
+
+   brw_blorp_blit_program prog(brw, prog_key);
+   GLuint program_size;
+   const GLuint *program = prog.compile(brw, INTEL_DEBUG & DEBUG_BLORP,
+                                        &program_size);
+   brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
+                    prog_key, sizeof(*prog_key),
+                    program, program_size,
+                    &prog.prog_data, sizeof(prog.prog_data),
+                    &params->wm_prog_kernel, &params->wm_prog_data);
+}
+
 void
 brw_blorp_blit_program::render_target_write()
 {
@@ -2203,19 +2224,7 @@ brw_blorp_blit_miptrees(struct brw_context *brw,
       params.src.y_offset /= 2;
    }
 
-   if (!brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
-                         &wm_prog_key, sizeof(wm_prog_key),
-                         &params.wm_prog_kernel, &params.wm_prog_data)) {
-      brw_blorp_blit_program prog(brw, &wm_prog_key);
-      GLuint program_size;
-      const GLuint *program = prog.compile(brw, INTEL_DEBUG & DEBUG_BLORP,
-                                           &program_size);
-      brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
-                       &wm_prog_key, sizeof(wm_prog_key),
-                       program, program_size,
-                       &prog.prog_data, sizeof(prog.prog_data),
-                       &params.wm_prog_kernel, &params.wm_prog_data);
-   }
+   brw_blorp_get_blit_kernel(brw, &params, &wm_prog_key);
 
    params.src.swizzle = src_swizzle;