Skip to content

Commit

Permalink
remove dead shader read code
Browse files Browse the repository at this point in the history
  • Loading branch information
DadSchoorse committed May 16, 2020
1 parent eb5aa4b commit 59463d0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
60 changes: 0 additions & 60 deletions src/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,6 @@

namespace vkBasalt
{
std::vector<char> readFile(const std::string& filename)
{
static std::string shaderDir;

if (shaderDir.empty())
{
// Custom shader directory path
const char* tmpShaderEnv = std::getenv("VKBASALT_SHADER_PATH");
std::string customShaderDir = tmpShaderEnv ? std::string(tmpShaderEnv) : "";

// User shader directory path
const char* tmpHomeEnv = std::getenv("XDG_DATA_HOME");
std::string userShaderDir =
tmpHomeEnv ? std::string(tmpHomeEnv) + "/vkBasalt/shader" : std::string(std::getenv("HOME")) + "/.local/share/vkBasalt/shader";

// Allowed config paths
const std::array<std::string, 4> shaderPath = {
customShaderDir, // custom shaders (VKBASALT_SHADER_PATH=/path/to/vkBasalt/shader)
userShaderDir, // default shaders
"/usr/share/vkBasalt/shader", // system-wide shaders
"/usr/local/share/vkBasalt/shader", // system-wide shaders (alternative)
};

for (const auto& sDir : shaderPath)
{
if (!std::filesystem::is_directory(sDir))
continue;

Logger::info("shader directory: " + sDir);
shaderDir = sDir + "/";
break;
}
}
std::ifstream file;

if (filename[0] != '/')
{
file = std::ifstream(shaderDir + filename, std::ios::binary | std::ios::ate);
}
else
{
file = std::ifstream(filename, std::ios::binary | std::ios::ate);
}

if (file)
{
size_t fileSize = (size_t) file.tellg();
std::vector<char> fileBuffer(fileSize);
file.seekg(0);
file.read(fileBuffer.data(), fileSize);
file.close();
return fileBuffer;
}
else
{
Logger::err("read file " + filename + " failed");
return std::vector<char>(0);
}
}

void createShaderModule(LogicalDevice* pLogicalDevice, const std::vector<char>& code, VkShaderModule* shaderModule)
{
VkShaderModuleCreateInfo shaderCreateInfo;
Expand Down
2 changes: 0 additions & 2 deletions src/shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

namespace vkBasalt
{
std::vector<char> readFile(const std::string& filename);

void createShaderModule(LogicalDevice* pLogicalDevice, const std::vector<char>& code, VkShaderModule* shaderModule);
void createShaderModule(LogicalDevice* pLogicalDevice, const std::vector<uint32_t>& code, VkShaderModule* shaderModule);
} // namespace vkBasalt
Expand Down

0 comments on commit 59463d0

Please sign in to comment.