This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
617a4ac
commit 8cef0e0
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#include "common.h" | ||
#include "device.h" | ||
#include "vk_alloc.h" | ||
#include "v3dvk_error.h" | ||
#include "v3dvk_shader.h" | ||
#include "util/mesa-sha1.h" | ||
|
||
VkResult | ||
v3dvk_CreateShaderModule(VkDevice _device, | ||
const VkShaderModuleCreateInfo *pCreateInfo, | ||
const VkAllocationCallbacks *pAllocator, | ||
VkShaderModule *pShaderModule) | ||
{ | ||
V3DVK_FROM_HANDLE(v3dvk_device, device, _device); | ||
struct v3dvk_shader_module *module; | ||
|
||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO); | ||
assert(pCreateInfo->flags == 0); | ||
assert(pCreateInfo->codeSize % 4 == 0); | ||
|
||
module = vk_alloc2(&device->alloc, pAllocator, | ||
sizeof(*module) + pCreateInfo->codeSize, 8, | ||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); | ||
if (module == NULL) | ||
return v3dvk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); | ||
|
||
module->code_size = pCreateInfo->codeSize; | ||
memcpy(module->code, pCreateInfo->pCode, pCreateInfo->codeSize); | ||
|
||
_mesa_sha1_compute(module->code, module->code_size, module->sha1); | ||
|
||
*pShaderModule = v3dvk_shader_module_to_handle(module); | ||
|
||
return VK_SUCCESS; | ||
} | ||
|
||
void | ||
v3dvk_DestroyShaderModule(VkDevice _device, | ||
VkShaderModule _module, | ||
const VkAllocationCallbacks *pAllocator) | ||
{ | ||
V3DVK_FROM_HANDLE(v3dvk_device, device, _device); | ||
V3DVK_FROM_HANDLE(v3dvk_shader_module, module, _module); | ||
|
||
if (!module) | ||
return; | ||
|
||
vk_free2(&device->alloc, pAllocator, module); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
#ifndef V3DVK_SHADER_H | ||
#define V3DVK_SHADER_H | ||
|
||
#include <stdint.h> | ||
|
||
struct v3dvk_shader_module | ||
{ | ||
unsigned char sha1[20]; | ||
|
||
uint32_t code_size; | ||
const uint32_t *code[0]; | ||
}; | ||
|
||
#endif |