Skip to content

Commit

Permalink
Merge pull request #2 from smoogipoo/masking-ssbo
Browse files Browse the repository at this point in the history
Fix index out of range with version replace
  • Loading branch information
peppy committed Jul 31, 2023
2 parents 22b7f8b + 008c958 commit 6b4feca
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/libveldrid-spirv/libveldrid-spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,18 @@ CompilationResult *CompileVertexFragment(const CrossCompileInfo &info)
if (info.Target == GLSL && usesStorageResource)
{
std::string key = "#version 330";
vsText.replace(vsText.find(key), key.length(), "#version 430");
std::size_t idx = vsText.find(key);

if (idx != std::string::npos)
vsText.replace(idx, key.length(), "#version 430");
}
else if (info.Target == ESSL && usesStorageResource)
{
std::string key = "#version 300";
vsText.replace(vsText.find(key), key.length(), "#version 310");
std::size_t idx = vsText.find(key);

if (idx != std::string::npos)
vsText.replace(idx, key.length(), "#version 310");
}

std::string fsText = fsCompiler->compile();
Expand All @@ -456,12 +462,18 @@ CompilationResult *CompileVertexFragment(const CrossCompileInfo &info)
if (info.Target == GLSL && usesStorageResource)
{
std::string key = "#version 330";
fsText.replace(vsText.find(key), key.length(), "#version 430");
std::size_t idx = fsText.find(key);

if (idx != std::string::npos)
fsText.replace(idx, key.length(), "#version 430");
}
else if (info.Target == ESSL && usesStorageResource)
{
std::string key = "#version 300";
fsText.replace(vsText.find(key), key.length(), "#version 310");
std::size_t idx = fsText.find(key);

if (idx != std::string::npos)
fsText.replace(idx, key.length(), "#version 310");
}

CompilationResult *result = new CompilationResult();
Expand Down

0 comments on commit 6b4feca

Please sign in to comment.