Mesa (master): lavapipe: use common interfaces for shader modules

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 15 22:19:49 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Mar 10 17:49:28 2021 -0500

lavapipe: use common interfaces for shader modules

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>

---

 src/gallium/frontends/lavapipe/lvp_pipeline.c | 49 ++-------------------------
 src/gallium/frontends/lavapipe/lvp_private.h  |  9 +----
 2 files changed, 4 insertions(+), 54 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c
index d10bb4b32af..b3d794dcea2 100644
--- a/src/gallium/frontends/lavapipe/lvp_pipeline.c
+++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c
@@ -40,49 +40,6 @@
       dst = temp;                                                \
    } while(0)
 
-VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateShaderModule(
-   VkDevice                                    _device,
-   const VkShaderModuleCreateInfo*             pCreateInfo,
-   const VkAllocationCallbacks*                pAllocator,
-   VkShaderModule*                             pShaderModule)
-{
-   LVP_FROM_HANDLE(lvp_device, device, _device);
-   struct lvp_shader_module *module;
-
-   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
-   assert(pCreateInfo->flags == 0);
-
-   module = vk_alloc2(&device->vk.alloc, pAllocator,
-                      sizeof(*module) + pCreateInfo->codeSize, 8,
-                      VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-   if (module == NULL)
-      return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
-
-   vk_object_base_init(&device->vk, &module->base,
-                       VK_OBJECT_TYPE_SHADER_MODULE);
-   module->size = pCreateInfo->codeSize;
-   memcpy(module->data, pCreateInfo->pCode, module->size);
-
-   *pShaderModule = lvp_shader_module_to_handle(module);
-
-   return VK_SUCCESS;
-
-}
-
-VKAPI_ATTR void VKAPI_CALL lvp_DestroyShaderModule(
-   VkDevice                                    _device,
-   VkShaderModule                              _module,
-   const VkAllocationCallbacks*                pAllocator)
-{
-   LVP_FROM_HANDLE(lvp_device, device, _device);
-   LVP_FROM_HANDLE(lvp_shader_module, module, _module);
-
-   if (!_module)
-      return;
-   vk_object_base_finish(&module->base);
-   vk_free2(&device->vk.alloc, pAllocator, module);
-}
-
 VKAPI_ATTR void VKAPI_CALL lvp_DestroyPipeline(
    VkDevice                                    _device,
    VkPipeline                                  _pipeline,
@@ -445,7 +402,7 @@ shared_var_info(const struct glsl_type *type, unsigned *size, unsigned *align)
 
 static void
 lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
-                         struct lvp_shader_module *module,
+                         struct vk_shader_module *module,
                          const char *entrypoint_name,
                          gl_shader_stage stage,
                          const VkSpecializationInfo *spec_info)
@@ -782,7 +739,7 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
    pipeline->is_compute_pipeline = false;
 
    for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
-      LVP_FROM_HANDLE(lvp_shader_module, module,
+      VK_FROM_HANDLE(vk_shader_module, module,
                       pCreateInfo->pStages[i].module);
       gl_shader_stage stage = lvp_shader_stage(pCreateInfo->pStages[i].stage);
       lvp_shader_compile_to_ir(pipeline, module,
@@ -897,7 +854,7 @@ lvp_compute_pipeline_init(struct lvp_pipeline *pipeline,
                           const VkComputePipelineCreateInfo *pCreateInfo,
                           const VkAllocationCallbacks *alloc)
 {
-   LVP_FROM_HANDLE(lvp_shader_module, module,
+   VK_FROM_HANDLE(vk_shader_module, module,
                    pCreateInfo->stage.module);
    if (alloc == NULL)
       alloc = &device->vk.alloc;
diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h
index 3e67950b706..6607c0b39e9 100644
--- a/src/gallium/frontends/lavapipe/lvp_private.h
+++ b/src/gallium/frontends/lavapipe/lvp_private.h
@@ -52,6 +52,7 @@ typedef uint32_t xcb_window_t;
 #include "vk_device.h"
 #include "vk_instance.h"
 #include "vk_physical_device.h"
+#include "vk_shader_module.h"
 
 #include "wsi_common.h"
 
@@ -118,12 +119,6 @@ void __lvp_finishme(const char *file, int line, const char *format, ...)
       return; \
    } while (0)
 
-struct lvp_shader_module {
-   struct vk_object_base base;
-   uint32_t                                     size;
-   char                                         data[0];
-};
-
 static inline gl_shader_stage
 vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
 {
@@ -615,8 +610,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_render_pass, base, VkRenderPass,
                                VK_OBJECT_TYPE_RENDER_PASS)
 VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, base, VkSampler,
                                VK_OBJECT_TYPE_SAMPLER)
-VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_shader_module, base, VkShaderModule,
-                               VK_OBJECT_TYPE_SHADER_MODULE)
 VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_fence, base, VkFence, VK_OBJECT_TYPE_FENCE);
 VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_semaphore, base, VkSemaphore,
                                VK_OBJECT_TYPE_SEMAPHORE);



More information about the mesa-commit mailing list