commit ca67d3e2c563a725d7b4eac479c8f38ddd914d9d Author: Craig Stout Date: Thu Mar 23 17:11:29 2017 -0700 Fix dynamic state leak. anv_state_pool_alloc requires a matching free, whereas anv_state_stream_alloc will be cleaned up on finish. Change-Id: I28f068393defc76fce3f739940526e63a12d6ab9 diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index b4d9262c80..521a34be19 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -785,6 +785,18 @@ _anv_combine_address(struct anv_batch *batch, void *location, __state; \ }) +#define anv_state_stream_emit(stream, cmd, align, ...) \ + ({ \ + const uint32_t __size = __anv_cmd_length(cmd) * 4; \ + struct anv_state __state = anv_state_stream_alloc((stream), __size, align); \ + struct cmd __template = {__VA_ARGS__}; \ + __anv_cmd_pack(cmd)(NULL, __state.map, &__template); \ + VG(VALGRIND_CHECK_MEM_IS_DEFINED(__state.map, __anv_cmd_length(cmd) * 4)); \ + if (!(stream)->block_pool->device->info.has_llc) \ + anv_state_clflush(__state); \ + __state; \ + }) + #define GEN7_MOCS (struct GEN7_MEMORY_OBJECT_CONTROL_STATE) { \ .GraphicsDataTypeGFDT = 0, \ .LLCCacheabilityControlLLCCC = 0, \ diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f698961d42..25904aa556 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -1366,26 +1366,26 @@ flush_compute_descriptor_set(struct anv_cmd_buffer *cmd_buffer) const uint32_t slm_size = encode_slm_size(GEN_GEN, prog_data->total_shared); struct anv_state state = - anv_state_pool_emit(&device->dynamic_state_pool, - GENX(INTERFACE_DESCRIPTOR_DATA), 64, - .KernelStartPointer = pipeline->cs_simd, - .BindingTablePointer = surfaces.offset, - .BindingTableEntryCount = 0, - .SamplerStatePointer = samplers.offset, - .SamplerCount = 0, + anv_state_stream_emit(&cmd_buffer->dynamic_state_stream, + GENX(INTERFACE_DESCRIPTOR_DATA), 64, + .KernelStartPointer = pipeline->cs_simd, + .BindingTablePointer = surfaces.offset, + .BindingTableEntryCount = 0, + .SamplerStatePointer = samplers.offset, + .SamplerCount = 0, #if !GEN_IS_HASWELL - .ConstantURBEntryReadOffset = 0, + .ConstantURBEntryReadOffset = 0, #endif - .ConstantURBEntryReadLength = - cs_prog_data->push.per_thread.regs, + .ConstantURBEntryReadLength = + cs_prog_data->push.per_thread.regs, #if GEN_GEN >= 8 || GEN_IS_HASWELL - .CrossThreadConstantDataReadLength = - cs_prog_data->push.cross_thread.regs, + .CrossThreadConstantDataReadLength = + cs_prog_data->push.cross_thread.regs, #endif - .BarrierEnable = cs_prog_data->uses_barrier, - .SharedLocalMemorySize = slm_size, - .NumberofThreadsinGPGPUThreadGroup = - cs_prog_data->threads); + .BarrierEnable = cs_prog_data->uses_barrier, + .SharedLocalMemorySize = slm_size, + .NumberofThreadsinGPGPUThreadGroup = + cs_prog_data->threads); uint32_t size = GENX(INTERFACE_DESCRIPTOR_DATA_length) * sizeof(uint32_t); anv_batch_emit(&cmd_buffer->batch,