lavapipe: use common interfaces for shader modules

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>
This commit is contained in:
Mike Blumenkrantz
2021-03-10 17:49:28 -05:00
committed by Marge Bot
parent a41e98ddca
commit c3db26a6f6
2 changed files with 4 additions and 54 deletions

View File

@@ -40,49 +40,6 @@
dst = temp; \ dst = temp; \
} while(0) } 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( VKAPI_ATTR void VKAPI_CALL lvp_DestroyPipeline(
VkDevice _device, VkDevice _device,
VkPipeline _pipeline, VkPipeline _pipeline,
@@ -445,7 +402,7 @@ shared_var_info(const struct glsl_type *type, unsigned *size, unsigned *align)
static void static void
lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline, lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
struct lvp_shader_module *module, struct vk_shader_module *module,
const char *entrypoint_name, const char *entrypoint_name,
gl_shader_stage stage, gl_shader_stage stage,
const VkSpecializationInfo *spec_info) const VkSpecializationInfo *spec_info)
@@ -782,7 +739,7 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
pipeline->is_compute_pipeline = false; pipeline->is_compute_pipeline = false;
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { 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); pCreateInfo->pStages[i].module);
gl_shader_stage stage = lvp_shader_stage(pCreateInfo->pStages[i].stage); gl_shader_stage stage = lvp_shader_stage(pCreateInfo->pStages[i].stage);
lvp_shader_compile_to_ir(pipeline, module, lvp_shader_compile_to_ir(pipeline, module,
@@ -897,7 +854,7 @@ lvp_compute_pipeline_init(struct lvp_pipeline *pipeline,
const VkComputePipelineCreateInfo *pCreateInfo, const VkComputePipelineCreateInfo *pCreateInfo,
const VkAllocationCallbacks *alloc) const VkAllocationCallbacks *alloc)
{ {
LVP_FROM_HANDLE(lvp_shader_module, module, VK_FROM_HANDLE(vk_shader_module, module,
pCreateInfo->stage.module); pCreateInfo->stage.module);
if (alloc == NULL) if (alloc == NULL)
alloc = &device->vk.alloc; alloc = &device->vk.alloc;

View File

@@ -52,6 +52,7 @@ typedef uint32_t xcb_window_t;
#include "vk_device.h" #include "vk_device.h"
#include "vk_instance.h" #include "vk_instance.h"
#include "vk_physical_device.h" #include "vk_physical_device.h"
#include "vk_shader_module.h"
#include "wsi_common.h" #include "wsi_common.h"
@@ -118,12 +119,6 @@ void __lvp_finishme(const char *file, int line, const char *format, ...)
return; \ return; \
} while (0) } while (0)
struct lvp_shader_module {
struct vk_object_base base;
uint32_t size;
char data[0];
};
static inline gl_shader_stage static inline gl_shader_stage
vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_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_OBJECT_TYPE_RENDER_PASS)
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, base, VkSampler, VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, base, VkSampler,
VK_OBJECT_TYPE_SAMPLER) 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_fence, base, VkFence, VK_OBJECT_TYPE_FENCE);
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_semaphore, base, VkSemaphore, VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_semaphore, base, VkSemaphore,
VK_OBJECT_TYPE_SEMAPHORE); VK_OBJECT_TYPE_SEMAPHORE);