Move ShaderStage and name into Shader struct
These fields will eventually be determined automatically but for now it makes more sense to pass them as arguements to RenderDriver::create_shader.
This commit is contained in:
@@ -553,11 +553,13 @@ void VulkanRenderDriver::destroy_swapchain(SwapchainID p_swapchain) {
|
||||
delete p_swapchain;
|
||||
}
|
||||
|
||||
ShaderID VulkanRenderDriver::create_shader(const std::span<u8> p_bytes) {
|
||||
ShaderID VulkanRenderDriver::create_shader(const std::span<u8> p_bytes, ShaderStage p_stage) {
|
||||
NOVA_AUTO_TRACE();
|
||||
NOVA_ASSERT(!p_bytes.empty());
|
||||
|
||||
Shader* shader = new Shader();
|
||||
shader->stage = p_stage; // TODO: Get from shader code
|
||||
shader->name = "main"; // TODO: Get from shader code
|
||||
|
||||
VkShaderModuleCreateInfo create {};
|
||||
create.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
@@ -587,12 +589,12 @@ PipelineID VulkanRenderDriver::create_pipeline(GraphicsPipelineParams& p_params)
|
||||
NOVA_ASSERT(p_params.render_pass);
|
||||
|
||||
std::vector<VkPipelineShaderStageCreateInfo> shader_stages;
|
||||
for (const auto& [stage, shader] : p_params.shaders) {
|
||||
for (const auto& shader : p_params.shaders) {
|
||||
VkPipelineShaderStageCreateInfo stage_create {};
|
||||
stage_create.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
stage_create.stage = VK_SHADER_STAGE_MAP[static_cast<int>(stage)];
|
||||
stage_create.stage = VK_SHADER_STAGE_MAP[static_cast<int>(shader->stage)];
|
||||
stage_create.module = shader->handle;
|
||||
stage_create.pName = "main"; // TODO: Get from shader
|
||||
stage_create.pName = shader->name.c_str();
|
||||
// TODO: Get specialization info from shader
|
||||
shader_stages.push_back(stage_create);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Nova {
|
||||
|
||||
struct Shader {
|
||||
VkShaderModule handle = VK_NULL_HANDLE;
|
||||
ShaderStage stage = ShaderStage::VERTEX;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct Surface {
|
||||
@@ -67,7 +69,7 @@ namespace Nova {
|
||||
void resize_swapchain(SwapchainID swapchain) override;
|
||||
void destroy_swapchain(SwapchainID swapchain) override;
|
||||
|
||||
[[nodiscard]] ShaderID create_shader(const std::span<u8> bytes) override;
|
||||
[[nodiscard]] ShaderID create_shader(const std::span<u8> bytes, ShaderStage stage) override;
|
||||
void destroy_shader(ShaderID shader) override;
|
||||
|
||||
[[nodiscard]] PipelineID create_pipeline(GraphicsPipelineParams& params) override;
|
||||
|
||||
Reference in New Issue
Block a user