<p dir="ltr">On Oct 8, 2016 10:52 AM, "Jason Ekstrand" <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
> On Oct 8, 2016 10:36 AM, "Michael Schellenberger Costa" <<a href="mailto:mschellenbergercosta@googlemail.com">mschellenbergercosta@googlemail.com</a>> wrote:<br>
> ><br>
> > Hi Jason,<br>
> ><br>
> ><br>
> > is there a reason that the first counter "i" is declared outside of the loop?<br>
><br>
> Not really. I just moved the code that was there before. I have no idea why it was written that way.</p>
<p dir="ltr">Actually, I remember now. In an earlier version of the spec, CreateFooPipelines was supposed to completely clean up if any of the pipelines failed to get created properly. The reason I was declared outside was so that we could have a cleanup loop running from 0 to i in the case of failure. Later versions of the spec, however, made it the client's job to clean things up (or free some memory and try again) so we removed the cleanup loop and never put i back inside the loop.</p>
<p dir="ltr">--Jason</p>
<p dir="ltr">> ><br>
> > --Michael<br>
> ><br>
> ><br>
> ><br>
> > On 08.10.2016 18:18, Jason Ekstrand wrote:<br>
> >><br>
> >> Now that we don't have meta, we have no need for a gen-agnostic pipeline<br>
> >> create path. We can, instead, just generate one Create*Pipelines function<br>
> >> per gen and be done with it.<br>
> >><br>
> >> Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
> >> ---<br>
> >> src/intel/vulkan/anv_genX.h | 7 ---<br>
> >> src/intel/vulkan/anv_pipeline.c | 106 ---------------------------------------<br>
> >> src/intel/vulkan/anv_private.h | 7 ---<br>
> >> src/intel/vulkan/genX_pipeline.c | 63 ++++++++++++++++++++++-<br>
> >> 4 files changed, 61 insertions(+), 122 deletions(-)<br>
> >><br>
> >> diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h<br>
> >> index b862c06..e6cef53 100644<br>
> >> --- a/src/intel/vulkan/anv_genX.h<br>
> >> +++ b/src/intel/vulkan/anv_genX.h<br>
> >> @@ -65,12 +65,5 @@ genX(graphics_pipeline_create)(VkDevice _device,<br>
> >> const VkAllocationCallbacks *alloc,<br>
> >> VkPipeline *pPipeline);<br>
> >> -VkResult<br>
> >> -genX(compute_pipeline_create)(VkDevice _device,<br>
> >> - struct anv_pipeline_cache *cache,<br>
> >> - const VkComputePipelineCreateInfo *pCreateInfo,<br>
> >> - const VkAllocationCallbacks *alloc,<br>
> >> - VkPipeline *pPipeline);<br>
> >> -<br>
> >> void genX(blorp_exec)(struct blorp_batch *batch,<br>
> >> const struct blorp_params *params);<br>
> >> diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c<br>
> >> index 6a364ff..bd1bf38 100644<br>
> >> --- a/src/intel/vulkan/anv_pipeline.c<br>
> >> +++ b/src/intel/vulkan/anv_pipeline.c<br>
> >> @@ -1116,109 +1116,3 @@ compile_fail:<br>
> >> return result;<br>
> >> }<br>
> >> -<br>
> >> -VkResult<br>
> >> -anv_graphics_pipeline_create(<br>
> >> - VkDevice _device,<br>
> >> - VkPipelineCache _cache,<br>
> >> - const VkGraphicsPipelineCreateInfo *pCreateInfo,<br>
> >> - const VkAllocationCallbacks *pAllocator,<br>
> >> - VkPipeline *pPipeline)<br>
> >> -{<br>
> >> - ANV_FROM_HANDLE(anv_device, device, _device);<br>
> >> - ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);<br>
> >> -<br>
> >> - switch (device->info.gen) {<br>
> >> - case 7:<br>
> >> - if (device->info.is_haswell)<br>
> >> - return gen75_graphics_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - else<br>
> >> - return gen7_graphics_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - case 8:<br>
> >> - return gen8_graphics_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - case 9:<br>
> >> - return gen9_graphics_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - default:<br>
> >> - unreachable("unsupported gen\n");<br>
> >> - }<br>
> >> -}<br>
> >> -<br>
> >> -VkResult anv_CreateGraphicsPipelines(<br>
> >> - VkDevice _device,<br>
> >> - VkPipelineCache pipelineCache,<br>
> >> - uint32_t count,<br>
> >> - const VkGraphicsPipelineCreateInfo* pCreateInfos,<br>
> >> - const VkAllocationCallbacks* pAllocator,<br>
> >> - VkPipeline* pPipelines)<br>
> >> -{<br>
> >> - VkResult result = VK_SUCCESS;<br>
> >> -<br>
> >> - unsigned i = 0;<br>
> >> - for (; i < count; i++) {<br>
> >> - result = anv_graphics_pipeline_create(_device,<br>
> >> - pipelineCache,<br>
> >> - &pCreateInfos[i],<br>
> >> - pAllocator, &pPipelines[i]);<br>
> >> - if (result != VK_SUCCESS) {<br>
> >> - for (unsigned j = 0; j < i; j++) {<br>
> >> - anv_DestroyPipeline(_device, pPipelines[j], pAllocator);<br>
> >> - }<br>
> >> -<br>
> >> - return result;<br>
> >> - }<br>
> >> - }<br>
> >> -<br>
> >> - return VK_SUCCESS;<br>
> >> -}<br>
> >> -<br>
> >> -static VkResult anv_compute_pipeline_create(<br>
> >> - VkDevice _device,<br>
> >> - VkPipelineCache _cache,<br>
> >> - const VkComputePipelineCreateInfo* pCreateInfo,<br>
> >> - const VkAllocationCallbacks* pAllocator,<br>
> >> - VkPipeline* pPipeline)<br>
> >> -{<br>
> >> - ANV_FROM_HANDLE(anv_device, device, _device);<br>
> >> - ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);<br>
> >> -<br>
> >> - switch (device->info.gen) {<br>
> >> - case 7:<br>
> >> - if (device->info.is_haswell)<br>
> >> - return gen75_compute_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - else<br>
> >> - return gen7_compute_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - case 8:<br>
> >> - return gen8_compute_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - case 9:<br>
> >> - return gen9_compute_pipeline_create(_device, cache, pCreateInfo, pAllocator, pPipeline);<br>
> >> - default:<br>
> >> - unreachable("unsupported gen\n");<br>
> >> - }<br>
> >> -}<br>
> >> -<br>
> >> -VkResult anv_CreateComputePipelines(<br>
> >> - VkDevice _device,<br>
> >> - VkPipelineCache pipelineCache,<br>
> >> - uint32_t count,<br>
> >> - const VkComputePipelineCreateInfo* pCreateInfos,<br>
> >> - const VkAllocationCallbacks* pAllocator,<br>
> >> - VkPipeline* pPipelines)<br>
> >> -{<br>
> >> - VkResult result = VK_SUCCESS;<br>
> >> -<br>
> >> - unsigned i = 0;<br>
> >> - for (; i < count; i++) {<br>
> >> - result = anv_compute_pipeline_create(_device, pipelineCache,<br>
> >> - &pCreateInfos[i],<br>
> >> - pAllocator, &pPipelines[i]);<br>
> >> - if (result != VK_SUCCESS) {<br>
> >> - for (unsigned j = 0; j < i; j++) {<br>
> >> - anv_DestroyPipeline(_device, pPipelines[j], pAllocator);<br>
> >> - }<br>
> >> -<br>
> >> - return result;<br>
> >> - }<br>
> >> - }<br>
> >> -<br>
> >> - return VK_SUCCESS;<br>
> >> -}<br>
> >> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h<br>
> >> index 3545acd..761c7f3 100644<br>
> >> --- a/src/intel/vulkan/anv_private.h<br>
> >> +++ b/src/intel/vulkan/anv_private.h<br>
> >> @@ -1524,13 +1524,6 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,<br>
> >> const char *entrypoint,<br>
> >> const VkSpecializationInfo *spec_info);<br>
> >> -VkResult<br>
> >> -anv_graphics_pipeline_create(VkDevice device,<br>
> >> - VkPipelineCache cache,<br>
> >> - const VkGraphicsPipelineCreateInfo *pCreateInfo,<br>
> >> - const VkAllocationCallbacks *alloc,<br>
> >> - VkPipeline *pPipeline);<br>
> >> -<br>
> >> struct anv_format {<br>
> >> enum isl_format isl_format:16;<br>
> >> struct isl_swizzle swizzle;<br>
> >> diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c<br>
> >> index dce7c6a..2a4dd8e 100644<br>
> >> --- a/src/intel/vulkan/genX_pipeline.c<br>
> >> +++ b/src/intel/vulkan/genX_pipeline.c<br>
> >> @@ -26,8 +26,8 @@<br>
> >> #include "genxml/gen_macros.h"<br>
> >> #include "genxml/genX_pack.h"<br>
> >> -VkResult<br>
> >> -genX(compute_pipeline_create)(<br>
> >> +static VkResult<br>
> >> +compute_pipeline_create(<br>
> >> VkDevice _device,<br>
> >> struct anv_pipeline_cache * cache,<br>
> >> const VkComputePipelineCreateInfo* pCreateInfo,<br>
> >> @@ -133,3 +133,62 @@ genX(compute_pipeline_create)(<br>
> >> return VK_SUCCESS;<br>
> >> }<br>
> >> +<br>
> >> +VkResult genX(CreateGraphicsPipelines)(<br>
> >> + VkDevice _device,<br>
> >> + VkPipelineCache pipelineCache,<br>
> >> + uint32_t count,<br>
> >> + const VkGraphicsPipelineCreateInfo* pCreateInfos,<br>
> >> + const VkAllocationCallbacks* pAllocator,<br>
> >> + VkPipeline* pPipelines)<br>
> >> +{<br>
> >> + ANV_FROM_HANDLE(anv_pipeline_cache, pipeline_cache, pipelineCache);<br>
> >> +<br>
> >> + VkResult result = VK_SUCCESS;<br>
> >> +<br>
> >> + unsigned i = 0;<br>
> >> + for (; i < count; i++) {<br>
> >> + result = genX(graphics_pipeline_create)(_device,<br>
> >> + pipeline_cache,<br>
> >> + &pCreateInfos[i],<br>
> >> + pAllocator, &pPipelines[i]);<br>
> >> + if (result != VK_SUCCESS) {<br>
> >> + for (unsigned j = 0; j < i; j++) {<br>
> >> + anv_DestroyPipeline(_device, pPipelines[j], pAllocator);<br>
> >> + }<br>
> >> +<br>
> >> + return result;<br>
> >> + }<br>
> >> + }<br>
> >> +<br>
> >> + return VK_SUCCESS;<br>
> >> +}<br>
> >> +<br>
> >> +VkResult genX(CreateComputePipelines)(<br>
> >> + VkDevice _device,<br>
> >> + VkPipelineCache pipelineCache,<br>
> >> + uint32_t count,<br>
> >> + const VkComputePipelineCreateInfo* pCreateInfos,<br>
> >> + const VkAllocationCallbacks* pAllocator,<br>
> >> + VkPipeline* pPipelines)<br>
> >> +{<br>
> >> + ANV_FROM_HANDLE(anv_pipeline_cache, pipeline_cache, pipelineCache);<br>
> >> +<br>
> >> + VkResult result = VK_SUCCESS;<br>
> >> +<br>
> >> + unsigned i = 0;<br>
> >> + for (; i < count; i++) {<br>
> >> + result = compute_pipeline_create(_device, pipeline_cache,<br>
> >> + &pCreateInfos[i],<br>
> >> + pAllocator, &pPipelines[i]);<br>
> >> + if (result != VK_SUCCESS) {<br>
> >> + for (unsigned j = 0; j < i; j++) {<br>
> >> + anv_DestroyPipeline(_device, pPipelines[j], pAllocator);<br>
> >> + }<br>
> >> +<br>
> >> + return result;<br>
> >> + }<br>
> >> + }<br>
> >> +<br>
> >> + return VK_SUCCESS;<br>
> >> +}<br>
> ><br>
> ><br></p>