anv: Take a device parameter in anv_state_flush

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>
This commit is contained in:
Jason Ekstrand
2017-02-20 11:04:12 -08:00
parent f408971deb
commit f31ed6d0cd
9 changed files with 32 additions and 52 deletions

View 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); state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, size, alignment);
memcpy(state.map, data, size); memcpy(state.map, data, size);
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, state);
anv_state_flush(state);
VG(VALGRIND_CHECK_MEM_IS_DEFINED(state.map, size)); 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++) for (uint32_t i = 0; i < dwords; i++)
p[i] = a[i] | b[i]; p[i] = a[i] | b[i];
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, state);
anv_state_flush(state);
VG(VALGRIND_CHECK_MEM_IS_DEFINED(p, dwords * 4)); 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); u32_map[i] = *(uint32_t *)((uint8_t *)data + offset);
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, state);
anv_state_flush(state);
return 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(cmd_buffer->device, state);
anv_state_flush(state);
return state; return state;
} }

View 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); state = anv_state_pool_alloc(pool, size, align);
memcpy(state.map, p, size); memcpy(state.map, p, size);
if (!pool->block_pool->device->info.has_llc) anv_state_flush(pool->block_pool->device, state);
anv_state_flush(state);
return state; return state;
} }
@@ -2055,8 +2054,7 @@ anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
.format = format, .format = format,
.stride = stride); .stride = stride);
if (!device->info.has_llc) anv_state_flush(device, state);
anv_state_flush(state);
} }
void anv_DestroySampler( void anv_DestroySampler(

View File

@@ -574,8 +574,7 @@ anv_CreateImageView(VkDevice _device,
.aux_usage = surf_usage, .aux_usage = surf_usage,
.mocs = device->default_mocs); .mocs = device->default_mocs);
if (!device->info.has_llc) anv_state_flush(device, iview->sampler_surface_state);
anv_state_flush(iview->sampler_surface_state);
} else { } else {
iview->sampler_surface_state.alloc_size = 0; iview->sampler_surface_state.alloc_size = 0;
} }
@@ -626,10 +625,8 @@ anv_CreateImageView(VkDevice _device,
&iview->storage_image_param, &iview->storage_image_param,
&surface->isl, &iview->isl); &surface->isl, &iview->isl);
if (!device->info.has_llc) { anv_state_flush(device, iview->storage_surface_state);
anv_state_flush(iview->storage_surface_state); anv_state_flush(device, iview->writeonly_storage_surface_state);
anv_state_flush(iview->writeonly_storage_surface_state);
}
} else { } else {
iview->storage_surface_state.alloc_size = 0; iview->storage_surface_state.alloc_size = 0;
iview->writeonly_storage_surface_state.alloc_size = 0; iview->writeonly_storage_surface_state.alloc_size = 0;

View File

@@ -461,12 +461,6 @@ anv_invalidate_range(void *start, size_t size)
__builtin_ia32_mfence(); __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, VkResult anv_block_pool_init(struct anv_block_pool *pool,
struct anv_device *device, uint32_t block_size); struct anv_device *device, uint32_t block_size);
void anv_block_pool_finish(struct anv_block_pool *pool); void anv_block_pool_finish(struct anv_block_pool *pool);
@@ -630,6 +624,15 @@ struct anv_device {
pthread_cond_t queue_submit; 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_init_blorp(struct anv_device *device);
void anv_device_finish_blorp(struct anv_device *device); void anv_device_finish_blorp(struct anv_device *device);

View File

@@ -90,8 +90,7 @@ gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
ssp.ScissorRectPointer = scissor_state.offset; ssp.ScissorRectPointer = scissor_state.offset;
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, scissor_state);
anv_state_flush(scissor_state);
} }
#endif #endif
@@ -191,8 +190,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
.BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff, .BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,
}; };
GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc); GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, cc_state);
anv_state_flush(cc_state);
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) { anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) {
ccp.ColorCalcStatePointer = cc_state.offset; ccp.ColorCalcStatePointer = cc_state.offset;

View File

@@ -67,8 +67,7 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
&sf_clip_viewport); &sf_clip_viewport);
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, sf_clip_state);
anv_state_flush(sf_clip_state);
anv_batch_emit(&cmd_buffer->batch, anv_batch_emit(&cmd_buffer->batch,
GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), clip) { 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); GENX(CC_VIEWPORT_pack)(NULL, cc_state.map + i * 8, &cc_viewport);
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, cc_state);
anv_state_flush(cc_state);
anv_batch_emit(&cmd_buffer->batch, anv_batch_emit(&cmd_buffer->batch,
GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), cc) { 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); GENX(COLOR_CALC_STATE_pack)(NULL, cc_state.map, &cc);
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, cc_state);
anv_state_flush(cc_state);
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) { anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CC_STATE_POINTERS), ccp) {
ccp.ColorCalcStatePointer = cc_state.offset; 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); GEN9_COLOR_CALC_STATE_pack(NULL, cc_state.map, &cc);
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, cc_state);
anv_state_flush(cc_state);
anv_batch_emit(&cmd_buffer->batch, GEN9_3DSTATE_CC_STATE_POINTERS, ccp) { anv_batch_emit(&cmd_buffer->batch, GEN9_3DSTATE_CC_STATE_POINTERS, ccp) {
ccp.ColorCalcStatePointer = cc_state.offset; ccp.ColorCalcStatePointer = cc_state.offset;

View File

@@ -101,8 +101,7 @@ blorp_alloc_binding_table(struct blorp_batch *batch, unsigned num_entries,
surface_maps[i] = surface_state.map; surface_maps[i] = surface_state.map;
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, bt_state);
anv_state_flush(bt_state);
} }
static void * static void *

View 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(cmd_buffer->device, state->render_pass_states);
anv_state_flush(state->render_pass_states);
} }
} }
@@ -1275,8 +1274,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
assert(image == map->image_count); assert(image == map->image_count);
out: out:
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, *bt_state);
anv_state_flush(*bt_state);
return VK_SUCCESS; return VK_SUCCESS;
} }
@@ -1333,8 +1331,7 @@ emit_samplers(struct anv_cmd_buffer *cmd_buffer,
sampler->state, sizeof(sampler->state)); sampler->state, sizeof(sampler->state));
} }
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, *state);
anv_state_flush(*state);
return VK_SUCCESS; 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)[0] = base_vertex;
((uint32_t *)id_state.map)[1] = base_instance; ((uint32_t *)id_state.map)[1] = base_instance;
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, id_state);
anv_state_flush(id_state);
emit_base_vertex_instance_bo(cmd_buffer, emit_base_vertex_instance_bo(cmd_buffer,
&cmd_buffer->device->dynamic_state_block_pool.bo, id_state.offset); &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; ((uint32_t *)state.map)[0] = draw_index;
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, state);
anv_state_flush(state);
emit_vertex_bo(cmd_buffer, emit_vertex_bo(cmd_buffer,
&cmd_buffer->device->dynamic_state_block_pool.bo, &cmd_buffer->device->dynamic_state_block_pool.bo,
@@ -1946,8 +1941,7 @@ void genX(CmdDispatch)(
sizes[0] = x; sizes[0] = x;
sizes[1] = y; sizes[1] = y;
sizes[2] = z; sizes[2] = z;
if (!cmd_buffer->device->info.has_llc) anv_state_flush(cmd_buffer->device, state);
anv_state_flush(state);
cmd_buffer->state.num_workgroups_offset = state.offset; cmd_buffer->state.num_workgroups_offset = state.offset;
cmd_buffer->state.num_workgroups_bo = cmd_buffer->state.num_workgroups_bo =
&cmd_buffer->device->dynamic_state_block_pool.bo; &cmd_buffer->device->dynamic_state_block_pool.bo;

View File

@@ -976,8 +976,7 @@ emit_cb_state(struct anv_pipeline *pipeline,
#endif #endif
GENX(BLEND_STATE_pack)(NULL, pipeline->blend_state.map, &blend_state); GENX(BLEND_STATE_pack)(NULL, pipeline->blend_state.map, &blend_state);
if (!device->info.has_llc) anv_state_flush(device, pipeline->blend_state);
anv_state_flush(pipeline->blend_state);
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_BLEND_STATE_POINTERS), bsp) { anv_batch_emit(&pipeline->batch, GENX(3DSTATE_BLEND_STATE_POINTERS), bsp) {
bsp.BlendStatePointer = pipeline->blend_state.offset; bsp.BlendStatePointer = pipeline->blend_state.offset;