aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorReinUsesLisp <[email protected]>2018-08-25 20:16:37 -0300
committerReinUsesLisp <[email protected]>2018-08-25 20:16:37 -0300
commit34d215d3d8c4a9071715d9eccebb0f285f1c8434 (patch)
tree7e3a55efe3398434dc2342a1704a79d4af950f57 /tests
parent5cfa8aa6ab22157045348a25504c05bef4886abf (diff)
downloadsirit-34d215d3d8c4a9071715d9eccebb0f285f1c8434.tar.gz
sirit-34d215d3d8c4a9071715d9eccebb0f285f1c8434.zip
Implement stuff
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index c5c520f..ab8f68d 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -5,7 +5,39 @@
*/
#include <sirit/sirit.h>
+#include <cstdio>
+#include <cstdlib>
+
+class MyModule : public Sirit::Module {
+public:
+ MyModule() {}
+ ~MyModule() = default;
+
+ void Generate() {
+ AddCapability(spv::Capability::Shader);
+ SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450);
+
+ auto main_type{TypeFunction(TypeVoid())};
+ auto main_func{EmitFunction(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type)};
+ Add(main_func);
+ Add(EmitLabel());
+ Add(EmitReturn());
+ Add(EmitFunctionEnd());
+
+ AddEntryPoint(spv::ExecutionModel::Vertex, main_func, "main");
+ }
+};
+
+int main(int argc, char** argv) {
+ MyModule module;
+ module.Generate();
+
+ module.Optimize(2);
+ std::vector<std::uint8_t> code{module.Assembly()};
+
+ FILE* file = fopen("sirit.spv", "wb");
+ fwrite(code.data(), 1, code.size(), file);
+ fclose(file);
-int main(int argc, char **argv) {
return 0;
}