summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChuyan Zhang <chuyan@ucsb.edu>2024-10-10 16:29:06 -0700
committerChuyan Zhang <chuyan@ucsb.edu>2024-10-10 16:29:06 -0700
commitba27f3c22e79b91a2573b7efd00c5a3bbdb96dbc (patch)
treeea6244cc24bccb891e45fe1413b66f3ceeba398d /src
parentd25c392cec57e8c561899bf75668da79c4e67aed (diff)
downloadiris-ba27f3c22e79b91a2573b7efd00c5a3bbdb96dbc.tar.gz
iris-ba27f3c22e79b91a2573b7efd00c5a3bbdb96dbc.zip
Update shader changes
Diffstat (limited to 'src')
-rw-r--r--src/render_graph.h41
-rw-r--r--src/shader.cpp16
-rw-r--r--src/shader.h8
3 files changed, 63 insertions, 2 deletions
diff --git a/src/render_graph.h b/src/render_graph.h
new file mode 100644
index 0000000..f09d6cb
--- /dev/null
+++ b/src/render_graph.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "render_pass.h"
+#include <cstdint>
+#include <vector>
+
+namespace iris {
+
+struct CreatedRenderResource {
+ enum struct Type {
+ Buffer,
+ Image,
+ ImageWithSampler,
+ AccelerationStructure,
+ } type;
+
+
+};
+
+struct ImportedRenderResource {
+
+};
+
+struct RenderResource {
+ enum struct Type {
+ Created,
+ Imported,
+ } type;
+
+ union {
+ CreatedRenderResource created;
+ ImportedRenderResource imported;
+ } inner;
+};
+
+struct RenderGraph {
+ std::vector<RenderPass> passes;
+ std::vector<RenderResource> resources;
+};
+
+} // namespace iris \ No newline at end of file
diff --git a/src/shader.cpp b/src/shader.cpp
index 95a7904..1bef97f 100644
--- a/src/shader.cpp
+++ b/src/shader.cpp
@@ -6,7 +6,11 @@
namespace iris {
-ShaderDesc::ShaderDesc(const std::string_view path) {
+ShaderDesc::ShaderDesc(
+ const std::string_view path,
+ std::vector<std::string> defines,
+ std::vector<std::pair<std::string, std::string>> valued_defines)
+{
// Load the shader from file
std::ifstream file("example.txt");
if (!file.is_open()) {
@@ -16,6 +20,7 @@ ShaderDesc::ShaderDesc(const std::string_view path) {
std::ostringstream file_stream;
file_stream << file.rdbuf();
this->source = file_stream.str();
+ this->entry_point = "main";
file.close();
// Determine the shader type
@@ -35,6 +40,13 @@ ShaderDesc::ShaderDesc(const std::string_view path) {
shaderc::Compiler compiler;
shaderc::CompileOptions options;
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_3);
+ options.SetOptimizationLevel(shaderc_optimization_level_performance);
+ for (const auto &define : defines) {
+ options.AddMacroDefinition(define);
+ }
+ for (const auto &[key, value] : valued_defines) {
+ options.AddMacroDefinition(key, value);
+ }
shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(
this->source, shaderc_glsl_compute_shader, path.data(), options);
@@ -56,6 +68,8 @@ ShaderDesc::Type ShaderDesc::shader_type_from_string(std::string_view type) {
return ShaderDesc::Type::eAnyHit;
} else if (type == "rint") {
return ShaderDesc::Type::eIntersection;
+ } else if (type == "rcall") {
+ return ShaderDesc::Type::eCallable;
} else if (type == "comp") {
return ShaderDesc::Type::eCompute;
} else {
diff --git a/src/shader.h b/src/shader.h
index b1be8a8..b34fd92 100644
--- a/src/shader.h
+++ b/src/shader.h
@@ -12,6 +12,8 @@ struct ShaderDesc {
std::string name;
// Source code of the shader
std::string source;
+ // Entry name of the shader
+ std::string entry_point;
// Shader type
enum struct Type {
@@ -20,6 +22,7 @@ struct ShaderDesc {
eClosestHit,
eAnyHit,
eIntersection,
+ eCallable,
eCompute,
} type;
@@ -27,7 +30,10 @@ struct ShaderDesc {
std::vector<uint32_t> compiled_binary;
static Type shader_type_from_string(std::string_view type);
- ShaderDesc(const std::string_view path);
+ ShaderDesc(
+ const std::string_view path,
+ std::vector<std::string> defines,
+ std::vector<std::pair<std::string, std::string>> valued_defines);
};
} // namespace iris \ No newline at end of file