v3dv: Create/DestroyShaderModule implementation

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Alejandro Piñeiro 2019-12-02 11:47:25 +01:00 committed by Marge Bot
parent a201c45000
commit dc1fbeb0f4
2 changed files with 32 additions and 2 deletions

View file

@ -31,7 +31,24 @@ v3dv_CreateShaderModule(VkDevice _device,
const VkAllocationCallbacks *pAllocator, const VkAllocationCallbacks *pAllocator,
VkShaderModule *pShaderModule) VkShaderModule *pShaderModule)
{ {
/* FIXME: stub */ V3DV_FROM_HANDLE(v3dv_device, device, _device);
struct v3dv_shader_module *module;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
assert(pCreateInfo->flags == 0);
module = vk_alloc2(&device->alloc, pAllocator,
sizeof(*module) + pCreateInfo->codeSize, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (module == NULL)
return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
module->size = pCreateInfo->codeSize;
memcpy(module->data, pCreateInfo->pCode, module->size);
_mesa_sha1_compute(module->data, module->size, module->sha1);
*pShaderModule = v3dv_shader_module_to_handle(module);
return VK_SUCCESS; return VK_SUCCESS;
} }
@ -41,7 +58,13 @@ v3dv_DestroyShaderModule(VkDevice _device,
VkShaderModule _module, VkShaderModule _module,
const VkAllocationCallbacks *pAllocator) const VkAllocationCallbacks *pAllocator)
{ {
/* FIXME: stub */ V3DV_FROM_HANDLE(v3dv_device, device, _device);
V3DV_FROM_HANDLE(v3dv_shader_module, module, _module);
if (!module)
return;
vk_free2(&device->alloc, pAllocator, module);
} }
void void

View file

@ -278,6 +278,12 @@ struct v3dv_image {
uint32_t alignment; uint32_t alignment;
}; };
struct v3dv_shader_module {
unsigned char sha1[20];
uint32_t size;
char data[0];
};
uint32_t v3dv_physical_device_api_version(struct v3dv_physical_device *dev); uint32_t v3dv_physical_device_api_version(struct v3dv_physical_device *dev);
int v3dv_get_instance_entrypoint_index(const char *name); int v3dv_get_instance_entrypoint_index(const char *name);
@ -370,6 +376,7 @@ V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory) V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image, VkImage) V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image, VkImage)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_shader_module, VkShaderModule)
static inline int static inline int
v3dv_ioctl(int fd, unsigned long request, void *arg) v3dv_ioctl(int fd, unsigned long request, void *arg)