i965: Devirtualize update_renderbuffer_surface.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 17 Aug 2017 08:05:31 +0000 (01:05 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 23 Aug 2017 18:55:17 +0000 (11:55 -0700)
Replace piles of my own boilerplate with 1-2 lines of code.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index 3380582b3fab8b9fa57289a34f370472bc05c040..2dbcc450860f97a3fb1aab6d5b57cfd72c73100b 100644 (file)
@@ -882,16 +882,12 @@ brwCreateContext(gl_api api,
    brw->gs.base.stage = MESA_SHADER_GEOMETRY;
    brw->wm.base.stage = MESA_SHADER_FRAGMENT;
    if (brw->gen >= 8) {
-      gen6_init_vtable_surface_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = gen8_emit_depth_stencil_hiz;
    } else if (brw->gen >= 7) {
-      gen6_init_vtable_surface_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = gen7_emit_depth_stencil_hiz;
    } else if (brw->gen >= 6) {
-      gen6_init_vtable_surface_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = gen6_emit_depth_stencil_hiz;
    } else {
-      gen4_init_vtable_surface_functions(brw);
       brw->vtbl.emit_depth_stencil_hiz = brw_emit_depth_stencil_hiz;
    }
 
index 94c0a1b9636e596f2615334a83a9c3c7c57e4c73..2274fe5c80efec9f7f7fadfad1256b99e5ce1395 100644 (file)
@@ -633,11 +633,6 @@ struct brw_context
 
    struct
    {
-      uint32_t (*update_renderbuffer_surface)(struct brw_context *brw,
-                                              struct gl_renderbuffer *rb,
-                                              unsigned unit,
-                                              uint32_t surf_index);
-
       /**
        * Send the appropriate state packets to configure depth, stencil, and
        * HiZ buffers (i965+ only)
index b3196427840dd233251d85c047a0a884f98884d6..c9fd9414826ef099d794f298be181cd989ae9307 100644 (file)
@@ -195,7 +195,6 @@ void *brw_state_batch(struct brw_context *brw,
 uint32_t brw_state_batch_size(struct brw_context *brw, uint32_t offset);
 
 /* brw_wm_surface_state.c */
-void gen4_init_vtable_surface_functions(struct brw_context *brw);
 uint32_t brw_get_surface_tiling_bits(uint32_t tiling);
 uint32_t brw_get_surface_num_multisamples(unsigned num_samples);
 enum isl_format brw_isl_format_for_mesa_format(mesa_format mesa_format);
@@ -247,9 +246,6 @@ void brw_emit_sampler_state(struct brw_context *brw,
                             bool non_normalized_coordinates,
                             uint32_t border_color_offset);
 
-/* gen6_surface_state.c */
-void gen6_init_vtable_surface_functions(struct brw_context *brw);
-
 /* brw_vs_surface_state.c */
 void
 brw_upload_pull_constants(struct brw_context *brw,
index f63b9d2ed51788ef0a00c3f296b8b6d2442b945d..2d7de54dcdb43c03fc3087c274759ee178e5373e 100644 (file)
@@ -1000,11 +1000,12 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw,
    if (fb->_NumColorDrawBuffers >= 1) {
       for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
          const uint32_t surf_index = render_target_start + i;
+         struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[i];
 
-        if (intel_renderbuffer(fb->_ColorDrawBuffers[i])) {
-            surf_offset[surf_index] =
-               brw->vtbl.update_renderbuffer_surface(
-                  brw, fb->_ColorDrawBuffers[i], i, surf_index);
+        if (intel_renderbuffer(rb)) {
+            surf_offset[surf_index] = brw->gen >= 6 ?
+               gen6_update_renderbuffer_surface(brw, rb, i, surf_index) :
+               gen4_update_renderbuffer_surface(brw, rb, i, surf_index);
         } else {
             emit_null_surface_state(brw, w, h, s, &surf_offset[surf_index]);
         }
@@ -1669,19 +1670,6 @@ const struct brw_tracked_state brw_wm_image_surfaces = {
    .emit = brw_upload_wm_image_surfaces,
 };
 
-void
-gen4_init_vtable_surface_functions(struct brw_context *brw)
-{
-   brw->vtbl.update_renderbuffer_surface = gen4_update_renderbuffer_surface;
-}
-
-void
-gen6_init_vtable_surface_functions(struct brw_context *brw)
-{
-   gen4_init_vtable_surface_functions(brw);
-   brw->vtbl.update_renderbuffer_surface = gen6_update_renderbuffer_surface;
-}
-
 static void
 brw_upload_cs_work_groups_surface(struct brw_context *brw)
 {