diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-08-12 11:57:11 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-08-12 11:57:11 -0400 |
| commit | 6f53c63454657d076221ad4228215e7812f1e4db (patch) | |
| tree | 3f7c37398b759f1f0fad2ac2c69d524d84aa3f62 | |
| parent | 39a9fcd3e955cc474a3fc6483dcb8f60e6c4cb03 (diff) | |
upload shader
| -rw-r--r-- | src/window.cpp | 15 | ||||
| -rw-r--r-- | src/window.hpp | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp index c8e6465..7fb2139 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -488,3 +488,18 @@ void DestroyWindow() { glfwTerminate(); } +VkShaderModule UploadShader(AssetHandle handle) { + const Asset *asset = GetAsset(handle); + + VkShaderModuleCreateInfo createInfo{}; + createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; + createInfo.codeSize = asset->size; + createInfo.pCode = static_cast<const uint32_t *>(asset->ptr); + + VkShaderModule vkShaderModule; + if (vkCreateShaderModule(vkDevice, &createInfo, vkAllocator, &vkShaderModule) != VK_SUCCESS) { + throw "failed to create shader module for asset"; + } + return vkShaderModule; +} + diff --git a/src/window.hpp b/src/window.hpp index 5c29008..fb5702a 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -2,6 +2,7 @@ #define PKE_WINDOW_HPP #include "memory.hpp" +#include "asset-manager.hpp" #include <GLFW/glfw3.h> #include <vulkan/vulkan.h> @@ -21,5 +22,6 @@ struct PKEWindowProperties { void CreateWindow(PKEWindowProperties *wp); void DestroyWindow(); +VkShaderModule UploadShader(AssetHandle handle); #endif /* PKE_WINDOW_HPP */ |
