Mesa (master): anv/pipeline: Properly handle OOM during shader compilation

Jason Ekstrand jekstrand at kemper.freedesktop.org
Tue Aug 30 22:49:04 UTC 2016


Module: Mesa
Branch: master
Commit: d5945bec124ab21606d0d2719abbae8c44a70cf1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5945bec124ab21606d0d2719abbae8c44a70cf1

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Aug 29 08:30:37 2016 -0700

anv/pipeline: Properly handle OOM during shader compilation

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Cc: "12.0" <mesa-stable at lists.freedesktop.org>

---

 src/intel/vulkan/anv_pipeline.c  | 35 +++++++++++++++++++++++------------
 src/intel/vulkan/genX_pipeline.c | 10 +++++++---
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index dd93d4a..e6afdc1 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1187,27 +1187,33 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
    }
 
    if (modules[MESA_SHADER_VERTEX]) {
-      anv_pipeline_compile_vs(pipeline, cache, pCreateInfo,
-                              modules[MESA_SHADER_VERTEX],
-                              pStages[MESA_SHADER_VERTEX]->pName,
-                              pStages[MESA_SHADER_VERTEX]->pSpecializationInfo);
+      result = anv_pipeline_compile_vs(pipeline, cache, pCreateInfo,
+                                       modules[MESA_SHADER_VERTEX],
+                                       pStages[MESA_SHADER_VERTEX]->pName,
+                                       pStages[MESA_SHADER_VERTEX]->pSpecializationInfo);
+      if (result != VK_SUCCESS)
+         goto compile_fail;
    }
 
    if (modules[MESA_SHADER_TESS_CTRL] || modules[MESA_SHADER_TESS_EVAL])
       anv_finishme("no tessellation support");
 
    if (modules[MESA_SHADER_GEOMETRY]) {
-      anv_pipeline_compile_gs(pipeline, cache, pCreateInfo,
-                              modules[MESA_SHADER_GEOMETRY],
-                              pStages[MESA_SHADER_GEOMETRY]->pName,
-                              pStages[MESA_SHADER_GEOMETRY]->pSpecializationInfo);
+      result = anv_pipeline_compile_gs(pipeline, cache, pCreateInfo,
+                                       modules[MESA_SHADER_GEOMETRY],
+                                       pStages[MESA_SHADER_GEOMETRY]->pName,
+                                       pStages[MESA_SHADER_GEOMETRY]->pSpecializationInfo);
+      if (result != VK_SUCCESS)
+         goto compile_fail;
    }
 
    if (modules[MESA_SHADER_FRAGMENT]) {
-      anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, extra,
-                              modules[MESA_SHADER_FRAGMENT],
-                              pStages[MESA_SHADER_FRAGMENT]->pName,
-                              pStages[MESA_SHADER_FRAGMENT]->pSpecializationInfo);
+      result = anv_pipeline_compile_fs(pipeline, cache, pCreateInfo, extra,
+                                       modules[MESA_SHADER_FRAGMENT],
+                                       pStages[MESA_SHADER_FRAGMENT]->pName,
+                                       pStages[MESA_SHADER_FRAGMENT]->pSpecializationInfo);
+      if (result != VK_SUCCESS)
+         goto compile_fail;
    }
 
    if (!(pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT)) {
@@ -1270,6 +1276,11 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
       pipeline->topology = _3DPRIM_RECTLIST;
 
    return VK_SUCCESS;
+
+compile_fail:
+   anv_reloc_list_finish(&pipeline->batch_relocs, alloc);
+
+   return result;
 }
 
 VkResult
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 5cbcfd2..8cf801f 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -76,9 +76,13 @@ genX(compute_pipeline_create)(
 
    assert(pCreateInfo->stage.stage == VK_SHADER_STAGE_COMPUTE_BIT);
    ANV_FROM_HANDLE(anv_shader_module, module,  pCreateInfo->stage.module);
-   anv_pipeline_compile_cs(pipeline, cache, pCreateInfo, module,
-                           pCreateInfo->stage.pName,
-                           pCreateInfo->stage.pSpecializationInfo);
+   result = anv_pipeline_compile_cs(pipeline, cache, pCreateInfo, module,
+                                    pCreateInfo->stage.pName,
+                                    pCreateInfo->stage.pSpecializationInfo);
+   if (result != VK_SUCCESS) {
+      anv_free2(&device->alloc, pAllocator, pipeline);
+      return result;
+   }
 
    pipeline->use_repclear = false;
 




More information about the mesa-commit mailing list