summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/file_environment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/file_environment.cpp')
-rw-r--r--src/shader_recompiler/file_environment.cpp50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/shader_recompiler/file_environment.cpp b/src/shader_recompiler/file_environment.cpp
deleted file mode 100644
index f2104f444..000000000
--- a/src/shader_recompiler/file_environment.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
1#include <cstdio>
2
3#include "exception.h"
4#include "file_environment.h"
5
6namespace Shader {
7
8FileEnvironment::FileEnvironment(const char* path) {
9 std::FILE* const file{std::fopen(path, "rb")};
10 if (!file) {
11 throw RuntimeError("Failed to open file='{}'", path);
12 }
13 std::fseek(file, 0, SEEK_END);
14 const long size{std::ftell(file)};
15 std::rewind(file);
16 if (size % 8 != 0) {
17 std::fclose(file);
18 throw RuntimeError("File size={} is not aligned to 8", size);
19 }
20 // TODO: Use a unique_ptr to avoid zero-initializing this
21 const size_t num_inst{static_cast<size_t>(size) / 8};
22 data.resize(num_inst);
23 if (std::fread(data.data(), 8, num_inst, file) != num_inst) {
24 std::fclose(file);
25 throw RuntimeError("Failed to read instructions={} from file='{}'", num_inst, path);
26 }
27 std::fclose(file);
28}
29
30FileEnvironment::~FileEnvironment() = default;
31
32u64 FileEnvironment::ReadInstruction(u32 offset) {
33 if (offset % 8 != 0) {
34 throw InvalidArgument("offset={} is not aligned to 8", offset);
35 }
36 if (offset / 8 >= static_cast<u32>(data.size())) {
37 throw InvalidArgument("offset={} is out of bounds", offset);
38 }
39 return data[offset / 8];
40}
41
42u32 FileEnvironment::TextureBoundBuffer() const {
43 throw NotImplementedException("Texture bound buffer serialization");
44}
45
46std::array<u32, 3> FileEnvironment::WorkgroupSize() const {
47 return {1, 1, 1};
48}
49
50} // namespace Shader