Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/graphics/vulkan/ComputePipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void ComputePipeline::init(VkDevice device) {
VK_CHECK(vkCreatePipelineLayout(_device, &computeLayout, nullptr, &_pipelineLayout));

VkShaderModule computeShader;
if (!vkutil::load_shader_module(_config.shaderPath.c_str(), _device, &computeShader)) {
if (!vkutil::load_shader_module(_config.shaderPath, _device,
&computeShader)) {
fmt::println("Error when building the compute shader \n");
return;
}
Expand Down
6 changes: 4 additions & 2 deletions src/graphics/vulkan/GraphicsPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ void GraphicsPipeline::init(VkDevice device) {
VK_CHECK(vkCreatePipelineLayout(device, &layoutInfo, nullptr, &_pipelineLayout));

VkShaderModule vertexShader;
if (!vkutil::load_shader_module(_config.vertexShaderPath.c_str(), _device, &vertexShader)) {
if (!vkutil::load_shader_module(_config.vertexShaderPath, _device,
&vertexShader)) {
fmt::println("Error when building the vertex shader");
return;
}

VkShaderModule fragmentShader;
if (!vkutil::load_shader_module(_config.fragmentShaderPath.c_str(), _device, &fragmentShader)) {
if (!vkutil::load_shader_module(_config.fragmentShaderPath, _device,
&fragmentShader)) {
fmt::println("Error when building the fragment shader");
vkDestroyShaderModule(_device, vertexShader, nullptr);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/vulkan/pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void GLTFMetallic_Roughness::build_pipelines(VulkanEngine* engine) {
}

VkShaderModule GLTFMetallic_Roughness::load_shader(VulkanEngine* engine,
const char* relative_path,
const std::filesystem::path& relative_path,
const char* type) {
VkShaderModule shaderModule;
if (!vkutil::load_shader_module(relative_path, engine->_device,
Expand Down
8 changes: 4 additions & 4 deletions src/graphics/vulkan/vk_pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

#include "graphics/vulkan/vk_initializers.h"

bool vkutil::load_shader_module(const char* filePath, VkDevice device,
bool vkutil::load_shader_module(const std::filesystem::path& filePath, VkDevice device,
VkShaderModule* outShaderModule) {
// open the file. With cursor at the end
if (!std::filesystem::exists(filePath)) {
LOGE("Shader file does not exist: {}", filePath);
LOGE("Shader file does not exist: {}", filePath.c_str());
return false;
}

// Open the file in binary mode, with the cursor at the end
std::ifstream file(filePath, std::ios::ate | std::ios::binary);

if (!file.is_open()) {
LOGE("Failed to open shader file: {}", filePath);
LOGE("Failed to open shader file: {}", filePath.c_str());
return false;
}

Expand All @@ -31,7 +31,7 @@ bool vkutil::load_shader_module(const char* filePath, VkDevice device,
const auto fileSize = file.tellg();

if (fileSize == -1) {
LOGE("Failed to open file {}", filePath);
LOGE("Failed to open file {}", filePath.c_str());
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/include/graphics/vulkan/ComputePipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ComputePipeline : public IPipeline {
public:
struct ComputePipelineConfig {
VkDescriptorSetLayout descriptorSetLayout;
std::string shaderPath;
std::filesystem::path shaderPath;
std::function<void(VkDevice, VkPipeline, VkPipelineLayout)> customSetupCallback = nullptr;
};

Expand Down
4 changes: 2 additions & 2 deletions src/include/graphics/vulkan/GraphicsPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class GraphicsPipeline : public IPipeline {
public:
struct GraphicsPipelineConfig {
std::string vertexShaderPath;
std::string fragmentShaderPath;
std::filesystem::path vertexShaderPath;
std::filesystem::path fragmentShaderPath;
std::vector<VkDescriptorSetLayout> descriptorSetLayouts;
VkFormat colorFormat;
VkFormat depthFormat;
Expand Down
3 changes: 2 additions & 1 deletion src/include/graphics/vulkan/pipelines.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct GLTFMetallic_Roughness {
DescriptorAllocatorGrowable& descriptorAllocator);

private:
VkShaderModule load_shader(VulkanEngine* engine, const char* path,
VkShaderModule load_shader(VulkanEngine* engine,
const std::filesystem::path& relative_path,
const char* type);
void create_material_layout(VulkanEngine* engine);
VkPipelineLayout create_pipeline_layout(VulkanEngine* engine);
Expand Down
5 changes: 3 additions & 2 deletions src/include/graphics/vulkan/vk_pipelines.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

#include <filesystem>
#include <vector>
#include <vulkan/vulkan_core.h>

namespace vkutil {

bool load_shader_module(const char* filePath, VkDevice device,
VkShaderModule* outShaderModule);
bool load_shader_module(const std::filesystem::path& filePath,
VkDevice device, VkShaderModule* outShaderModule);

};

Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 2121 files
4 changes: 4 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
{
"name": "fastgltf",
"version": "0.7.1"
},
{
"name": "fmt",
"version": "11.2.0"
}
]
}
Loading