Skip to content

Commit d1185db

Browse files
committed
chore: make sure shader compiler uses std expected
1 parent afefcfd commit d1185db

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/ObjCompiling/Shader/D3DShaderCompiler.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,26 @@ namespace shader
122122
#endif
123123
}
124124

125-
result::Expected<std::optional<CompiledShader>, std::string> CompileShader(const std::string& shaderFile,
126-
const std::string& entryPoint,
127-
const std::string& target,
128-
const bool debug,
129-
ISearchPath& searchPath,
130-
MemoryManager& memory)
125+
std::expected<std::optional<CompiledShader>, std::string> CompileShader(const std::string& shaderFile,
126+
const std::string& entryPoint,
127+
const std::string& target,
128+
const bool debug,
129+
ISearchPath& searchPath,
130+
MemoryManager& memory)
131131
{
132132
#ifdef _WIN32
133133
if (!initialized)
134134
InitializeShaderCompilation();
135135
if (!compilationAvailable)
136-
return result::Unexpected<std::string>("Shader compilation unavailable");
136+
return std::unexpected("Shader compilation unavailable");
137137

138138
const auto fileName = GetSourceFileNameForShaderAssetName(shaderFile);
139139
auto file = searchPath.Open(fileName);
140140
if (!file.IsOpen() || file.m_length <= 0)
141141
return std::optional<CompiledShader>(std::nullopt);
142142

143143
if (std::cmp_greater(file.m_length, MAX_SHADER_SIZE))
144-
return result::Unexpected(std::format("File too big: {}", file.m_length));
144+
return std::unexpected(std::format("File too big: {}", file.m_length));
145145

146146
const auto shaderSize = file.m_length;
147147
const auto shaderData = std::make_unique<char[]>(static_cast<size_t>(shaderSize));
@@ -185,7 +185,7 @@ namespace shader
185185
if (shaderBlob)
186186
shaderBlob->Release();
187187

188-
return result::Unexpected(std::move(errorMessage));
188+
return std::unexpected(std::move(errorMessage));
189189
}
190190

191191
const auto shaderBlobSize = static_cast<size_t>(shaderBlob->GetBufferSize());

src/ObjCompiling/Shader/D3DShaderCompiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "SearchPath/ISearchPath.h"
44
#include "Utils/MemoryManager.h"
5-
#include "Utils/Result.h"
65

6+
#include <expected>
77
#include <optional>
88
#include <string>
99

@@ -18,6 +18,6 @@ namespace shader
1818

1919
bool ShaderCompilationAvailable();
2020

21-
result::Expected<std::optional<CompiledShader>, std::string> CompileShader(
21+
std::expected<std::optional<CompiledShader>, std::string> CompileShader(
2222
const std::string& shaderFile, const std::string& entryPoint, const std::string& target, bool debug, ISearchPath& searchPath, MemoryManager& memory);
2323
} // namespace shader

0 commit comments

Comments
 (0)