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

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Mar 10 17:50:15 2021 -0500

tu: use common interfaces for shader modules

Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>

---

 src/freedreno/vulkan/tu_private.h | 10 +-------
 src/freedreno/vulkan/tu_shader.c  | 49 ++++-----------------------------------
 2 files changed, 5 insertions(+), 54 deletions(-)

diff --git a/src/freedreno/vulkan/tu_private.h 
b/src/freedreno/vulkan/tu_private.h
index 0c12cc35aa4..77cfe01a046 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -59,6 +59,7 @@
 #include "vk_extensions.h"
 #include "vk_instance.h"
 #include "vk_physical_device.h"
+#include "vk_shader_module.h"
 #include "wsi_common.h"
 
 #include "ir3/ir3_compiler.h"
@@ -1018,14 +1019,6 @@ struct tu_event
    struct tu_bo bo;
 };
 
-struct tu_shader_module
-{
-   struct vk_object_base base;
-
-   uint32_t code_size;
-   uint32_t code[];
-};
-
 struct tu_push_constant_range
 {
    uint32_t lo;
@@ -1629,7 +1622,6 @@ TU_DEFINE_NONDISP_HANDLE_CASTS(tu_query_pool, VkQueryPool)
 TU_DEFINE_NONDISP_HANDLE_CASTS(tu_render_pass, VkRenderPass)
 TU_DEFINE_NONDISP_HANDLE_CASTS(tu_sampler, VkSampler)
 TU_DEFINE_NONDISP_HANDLE_CASTS(tu_sampler_ycbcr_conversion, 
VkSamplerYcbcrConversion)
-TU_DEFINE_NONDISP_HANDLE_CASTS(tu_shader_module, VkShaderModule)
 
 /* for TU_FROM_HANDLE with both VkFence and VkSemaphore: */
 #define tu_syncobj_from_handle(x) ((struct tu_syncobj*) (uintptr_t) (x))
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index 28d00fa6122..bceba478ce7 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -111,11 +111,11 @@ tu_spirv_to_nir(struct tu_device *dev,
       num_spec = spec_info->mapEntryCount;
    }
 
-   struct tu_shader_module *module =
-      tu_shader_module_from_handle(stage_info->module);
-   assert(module->code_size % 4 == 0);
+   struct vk_shader_module *module =
+      vk_shader_module_from_handle(stage_info->module);
+   assert(module->size % 4 == 0);
    nir_shader *nir =
-      spirv_to_nir(module->code, module->code_size / 4,
+      spirv_to_nir((void*)module->data, module->size / 4,
                    spec, num_spec, stage, stage_info->pName,
                    &spirv_options, nir_options);
 
@@ -839,44 +839,3 @@ tu_shader_destroy(struct tu_device *dev,
 
    vk_free2(&dev->vk.alloc, alloc, shader);
 }
-
-VkResult
-tu_CreateShaderModule(VkDevice _device,
-                      const VkShaderModuleCreateInfo *pCreateInfo,
-                      const VkAllocationCallbacks *pAllocator,
-                      VkShaderModule *pShaderModule)
-{
-   TU_FROM_HANDLE(tu_device, device, _device);
-   struct tu_shader_module *module;
-
-   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
-   assert(pCreateInfo->flags == 0);
-   assert(pCreateInfo->codeSize % 4 == 0);
-
-   module = vk_object_alloc(&device->vk, pAllocator,
-                            sizeof(*module) + pCreateInfo->codeSize,
-                            VK_OBJECT_TYPE_SHADER_MODULE);
-   if (module == NULL)
-      return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
-
-   module->code_size = pCreateInfo->codeSize;
-   memcpy(module->code, pCreateInfo->pCode, pCreateInfo->codeSize);
-
-   *pShaderModule = tu_shader_module_to_handle(module);
-
-   return VK_SUCCESS;
-}
-
-void
-tu_DestroyShaderModule(VkDevice _device,
-                       VkShaderModule _module,
-                       const VkAllocationCallbacks *pAllocator)
-{
-   TU_FROM_HANDLE(tu_device, device, _device);
-   TU_FROM_HANDLE(tu_shader_module, module, _module);
-
-   if (!module)
-      return;
-
-   vk_object_free(&device->vk, pAllocator, module);
-}

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to