anv: Take a device parameter in anv_state_flush
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 20 Feb 2017 19:04:12 +0000 (11:04 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 21 Feb 2017 20:26:35 +0000 (12:26 -0800)
This allows the helper to check for llc instead of having to do it
manually at all the call sites.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_cmd_buffer.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/gen7_cmd_buffer.c
src/intel/vulkan/gen8_cmd_buffer.c
src/intel/vulkan/genX_blorp_exec.c
src/intel/vulkan/genX_cmd_buffer.c
src/intel/vulkan/genX_pipeline.c

index e82cfd298cb7a9fdfbfa7a885eaa26235c03d4b0..d7e50db139756c4a006ec0065e357da1720fc556 100644 (file)
@@ -587,8 +587,7 @@ anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer *cmd_buffer,
    state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, size, alignment);
    memcpy(state.map, data, size);
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(cmd_buffer->device, state);
 
    VG(VALGRIND_CHECK_MEM_IS_DEFINED(state.map, size));
 
@@ -609,8 +608,7 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
    for (uint32_t i = 0; i < dwords; i++)
       p[i] = a[i] | b[i];
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(cmd_buffer->device, state);
 
    VG(VALGRIND_CHECK_MEM_IS_DEFINED(p, dwords * 4));
 
@@ -646,8 +644,7 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer,
       u32_map[i] = *(uint32_t *)((uint8_t *)data + offset);
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(cmd_buffer->device, state);
 
    return state;
 }
@@ -706,8 +703,7 @@ anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer *cmd_buffer)
       }
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(cmd_buffer->device, state);
 
    return state;
 }
index f52b42a542fb6d08377353b8096420ba9fe0019f..6f570d8f54141c1fe078abb6ac54c189d32a7067 100644 (file)
@@ -861,8 +861,7 @@ anv_state_pool_emit_data(struct anv_state_pool *pool, size_t size, size_t align,
    state = anv_state_pool_alloc(pool, size, align);
    memcpy(state.map, p, size);
 
-   if (!pool->block_pool->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(pool->block_pool->device, state);
 
    return state;
 }
@@ -2055,8 +2054,7 @@ anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
                          .format = format,
                          .stride = stride);
 
-   if (!device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(device, state);
 }
 
 void anv_DestroySampler(
index c0142c80c4deee109e591b059d187487e416a79e..e2f7ca340fd5300e47cee13911050edc664d911c 100644 (file)
@@ -574,8 +574,7 @@ anv_CreateImageView(VkDevice _device,
                           .aux_usage = surf_usage,
                           .mocs = device->default_mocs);
 
-      if (!device->info.has_llc)
-         anv_state_flush(iview->sampler_surface_state);
+      anv_state_flush(device, iview->sampler_surface_state);
    } else {
       iview->sampler_surface_state.alloc_size = 0;
    }
@@ -626,10 +625,8 @@ anv_CreateImageView(VkDevice _device,
                                 &iview->storage_image_param,
                                 &surface->isl, &iview->isl);
 
-      if (!device->info.has_llc) {
-         anv_state_flush(iview->storage_surface_state);
-         anv_state_flush(iview->writeonly_storage_surface_state);
-      }
+      anv_state_flush(device, iview->storage_surface_state);
+      anv_state_flush(device, iview->writeonly_storage_surface_state);
    } else {
       iview->storage_surface_state.alloc_size = 0;
       iview->writeonly_storage_surface_state.alloc_size = 0;
index 7bf340b43390ca10f88fd0e0a87c211c612307e6..2527c2cc5a241c2f0aa3b19220bf6a437465a93d 100644 (file)
@@ -461,12 +461,6 @@ anv_invalidate_range(void *start, size_t size)
    __builtin_ia32_mfence();
 }
 
-static void inline
-anv_state_flush(struct anv_state state)
-{
-   anv_flush_range(state.map, state.alloc_size);
-}
-
 VkResult anv_block_pool_init(struct anv_block_pool *pool,
                              struct anv_device *device, uint32_t block_size);
 void anv_block_pool_finish(struct anv_block_pool *pool);
@@ -630,6 +624,15 @@ struct anv_device {
     pthread_cond_t                              queue_submit;
 };
 
+static void inline
+anv_state_flush(struct anv_device *device, struct anv_state state)
+{
+   if (device->info.has_llc)
+      return;
+
+   anv_flush_range(state.map, state.alloc_size);
+}
+
 void anv_device_init_blorp(struct anv_device *device);
 void anv_device_finish_blorp(struct anv_device *device);
 
index 3f7376c9a7dae8aa601ad5bb8d21cedb1f12b7e2..4ea3158a0f5cdec253f50ba9a2df3cf78b92853c 100644 (file)
@@ -90,8 +90,7 @@ gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
       ssp.ScissorRectPointer = scissor_state.offset;
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(scissor_state);
+   anv_state_flush(cmd_buffer->device, scissor_state);
 }
 #endif
 
@@ -191,8 +190,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
          .BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,
       };
       GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
-      if (!cmd_buffer->device->info.has_llc)
-         anv_state_flush(cc_state);
+      anv_state_flush(cmd_buffer->device, cc_state);
 
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) {
          ccp.ColorCalcStatePointer = cc_state.offset;
index 7c9bfd01cffb4db0169ffa3907ad85a922081202..c891a76723de722db9eb89584403838fd9197fd1 100644 (file)
@@ -67,8 +67,7 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
                                  &sf_clip_viewport);
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(sf_clip_state);
+   anv_state_flush(cmd_buffer->device, sf_clip_state);
 
    anv_batch_emit(&cmd_buffer->batch,
                   GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), clip) {
@@ -96,8 +95,7 @@ gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer,
       GENX(CC_VIEWPORT_pack)(NULL, cc_state.map + i * 8, &cc_viewport);
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(cc_state);
+   anv_state_flush(cmd_buffer->device, cc_state);
 
    anv_batch_emit(&cmd_buffer->batch,
                   GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), cc) {
@@ -473,8 +471,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
       };
       GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
 
-      if (!cmd_buffer->device->info.has_llc)
-         anv_state_flush(cc_state);
+      anv_state_flush(cmd_buffer->device, cc_state);
 
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) {
          ccp.ColorCalcStatePointer        = cc_state.offset;
@@ -525,8 +522,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
       };
       GEN9_COLOR_CALC_STATE_pack(NULL, cc_state.map, &cc);
 
-      if (!cmd_buffer->device->info.has_llc)
-         anv_state_flush(cc_state);
+      anv_state_flush(cmd_buffer->device, cc_state);
 
       anv_batch_emit(&cmd_buffer->batch, GEN9_3DSTATE_CC_STATE_POINTERS, ccp) {
          ccp.ColorCalcStatePointer = cc_state.offset;
index b617e781573f856944365ed491544a8f34c9cb0f..c1499fbb727bee02c835f7776cb625737255dbb6 100644 (file)
@@ -101,8 +101,7 @@ blorp_alloc_binding_table(struct blorp_batch *batch, unsigned num_entries,
       surface_maps[i] = surface_state.map;
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(bt_state);
+   anv_state_flush(cmd_buffer->device, bt_state);
 }
 
 static void *
index ebf54fd9f1802748aef49c1c3d3c3d513bd10156..7af2b316795e02e85b5213e73cd19c56e40bde86 100644 (file)
@@ -579,8 +579,7 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
          }
       }
 
-      if (!cmd_buffer->device->info.has_llc)
-         anv_state_flush(state->render_pass_states);
+      anv_state_flush(cmd_buffer->device, state->render_pass_states);
    }
 }
 
@@ -1275,8 +1274,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
    assert(image == map->image_count);
 
  out:
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(*bt_state);
+   anv_state_flush(cmd_buffer->device, *bt_state);
 
    return VK_SUCCESS;
 }
@@ -1333,8 +1331,7 @@ emit_samplers(struct anv_cmd_buffer *cmd_buffer,
              sampler->state, sizeof(sampler->state));
    }
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(*state);
+   anv_state_flush(cmd_buffer->device, *state);
 
    return VK_SUCCESS;
 }
@@ -1652,8 +1649,7 @@ emit_base_vertex_instance(struct anv_cmd_buffer *cmd_buffer,
    ((uint32_t *)id_state.map)[0] = base_vertex;
    ((uint32_t *)id_state.map)[1] = base_instance;
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(id_state);
+   anv_state_flush(cmd_buffer->device, id_state);
 
    emit_base_vertex_instance_bo(cmd_buffer,
       &cmd_buffer->device->dynamic_state_block_pool.bo, id_state.offset);
@@ -1667,8 +1663,7 @@ emit_draw_index(struct anv_cmd_buffer *cmd_buffer, uint32_t draw_index)
 
    ((uint32_t *)state.map)[0] = draw_index;
 
-   if (!cmd_buffer->device->info.has_llc)
-      anv_state_flush(state);
+   anv_state_flush(cmd_buffer->device, state);
 
    emit_vertex_bo(cmd_buffer,
                   &cmd_buffer->device->dynamic_state_block_pool.bo,
@@ -1946,8 +1941,7 @@ void genX(CmdDispatch)(
       sizes[0] = x;
       sizes[1] = y;
       sizes[2] = z;
-      if (!cmd_buffer->device->info.has_llc)
-         anv_state_flush(state);
+      anv_state_flush(cmd_buffer->device, state);
       cmd_buffer->state.num_workgroups_offset = state.offset;
       cmd_buffer->state.num_workgroups_bo =
          &cmd_buffer->device->dynamic_state_block_pool.bo;
index e461e6e35636b6d89e9c1904cd871bcdd2dd41df..2a7e552746284aa2169da0d4c9a81debd82cf6f5 100644 (file)
@@ -976,8 +976,7 @@ emit_cb_state(struct anv_pipeline *pipeline,
 #endif
 
    GENX(BLEND_STATE_pack)(NULL, pipeline->blend_state.map, &blend_state);
-   if (!device->info.has_llc)
-      anv_state_flush(pipeline->blend_state);
+   anv_state_flush(device, pipeline->blend_state);
 
    anv_batch_emit(&pipeline->batch, GENX(3DSTATE_BLEND_STATE_POINTERS), bsp) {
       bsp.BlendStatePointer      = pipeline->blend_state.offset;