| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "eu/log/log.h" |
| 2 |
|
|
|
| 3 |
|
|
|
| 4 |
|
|
#include "eu/render/shader.source.h" |
| 5 |
|
|
|
| 6 |
|
|
#include "mustache.hpp" |
| 7 |
|
|
|
| 8 |
|
|
// #include "default_shader.frag.glsl.h" |
| 9 |
|
|
// #include "default_shader.vert.glsl.h" |
| 10 |
|
|
// #include "skybox.frag.glsl.h" |
| 11 |
|
|
// #include "skybox.vert.glsl.h" |
| 12 |
|
|
|
| 13 |
|
|
// ==================================================================================================================== |
| 14 |
|
|
// Internal |
| 15 |
|
|
|
| 16 |
|
|
namespace internal |
| 17 |
|
|
{ |
| 18 |
|
|
namespace |
| 19 |
|
|
{ |
| 20 |
|
|
using namespace eu; |
| 21 |
|
|
using namespace eu::render; |
| 22 |
|
|
|
| 23 |
|
✗ |
kainjow::mustache::mustache load_mustache(std::string_view str) |
| 24 |
|
|
{ |
| 25 |
0/4
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 25 not taken.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 23 not taken.
|
✗ |
auto input = kainjow::mustache::mustache{ std::string{str.begin(), str.end()} }; |
| 26 |
0/2
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 18 not taken.
|
✗ |
if (input.is_valid() == false) |
| 27 |
|
|
{ |
| 28 |
|
✗ |
const auto& error = input.error_message(); |
| 29 |
0/6
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 37 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 31 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 29 not taken.
|
✗ |
LOG_ERR("Failed to parse mustache: {}", error); |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
0/2
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 33 not taken.
|
✗ |
input.set_custom_escape([](const std::string& s) { return s; }); |
| 33 |
|
✗ |
return input; |
| 34 |
|
✗ |
} |
| 35 |
|
|
|
| 36 |
|
|
|
| 37 |
|
✗ |
std::string generate(std::string_view str, const ShaderOptions& options, const std::string& uniform_buffer_source) |
| 38 |
|
|
{ |
| 39 |
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 212 not taken.
|
✗ |
auto input = load_mustache(str); |
| 40 |
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 210 not taken.
|
✗ |
auto data = kainjow::mustache::data{}; |
| 41 |
|
|
|
| 42 |
0/4
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 108 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 106 not taken.
|
✗ |
data["use_lights"] = options.use_lights; |
| 43 |
0/4
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 117 not taken.
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 115 not taken.
|
✗ |
data["use_blinn_phong"] = options.use_blinn_phong; |
| 44 |
0/4
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 126 not taken.
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 124 not taken.
|
✗ |
data["use_texture"] = options.use_texture; |
| 45 |
0/8
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 143 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 141 not taken.
✗ Branch 35 → 36 not taken.
✗ Branch 35 → 135 not taken.
✗ Branch 36 → 37 not taken.
✗ Branch 36 → 133 not taken.
|
✗ |
data["number_of_directional_lights"] = fmt::format("{}", options.number_of_directional_lights); |
| 46 |
0/8
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 156 not taken.
✗ Branch 43 → 44 not taken.
✗ Branch 43 → 154 not taken.
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 148 not taken.
✗ Branch 47 → 48 not taken.
✗ Branch 47 → 146 not taken.
|
✗ |
data["number_of_point_lights"] = fmt::format("{}", options.number_of_point_lights); |
| 47 |
0/8
✗ Branch 53 → 54 not taken.
✗ Branch 53 → 169 not taken.
✗ Branch 54 → 55 not taken.
✗ Branch 54 → 167 not taken.
✗ Branch 57 → 58 not taken.
✗ Branch 57 → 161 not taken.
✗ Branch 58 → 59 not taken.
✗ Branch 58 → 159 not taken.
|
✗ |
data["number_of_frustum_lights"] = fmt::format("{}", options.number_of_frustum_lights); |
| 48 |
0/4
✗ Branch 67 → 68 not taken.
✗ Branch 67 → 174 not taken.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 172 not taken.
|
✗ |
data["transparent_cutoff"] = options.transparent_cutoff; |
| 49 |
0/4
✗ Branch 76 → 77 not taken.
✗ Branch 76 → 183 not taken.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 181 not taken.
|
✗ |
data["use_instancing"] = options.use_instancing; |
| 50 |
0/6
✗ Branch 82 → 83 not taken.
✗ Branch 82 → 198 not taken.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 192 not taken.
✗ Branch 86 → 87 not taken.
✗ Branch 86 → 190 not taken.
|
✗ |
data["uniform_buffer_source"] = uniform_buffer_source; |
| 51 |
0/4
✗ Branch 94 → 95 not taken.
✗ Branch 94 → 201 not taken.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 199 not taken.
|
✗ |
data["only_depth"] = options.only_depth; |
| 52 |
|
|
|
| 53 |
0/2
✗ Branch 100 → 101 not taken.
✗ Branch 100 → 208 not taken.
|
✗ |
return input.render(data); |
| 54 |
|
✗ |
} |
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
✗ |
std::string generate(std::string_view str, const std::string& uniform_buffer_source) |
| 58 |
|
|
{ |
| 59 |
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 32 not taken.
|
✗ |
auto input = load_mustache(str); |
| 60 |
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 30 not taken.
|
✗ |
auto data = kainjow::mustache::data{}; |
| 61 |
|
|
|
| 62 |
0/6
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 27 not taken.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 21 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 19 not taken.
|
✗ |
data["uniform_buffer_source"] = uniform_buffer_source; |
| 63 |
|
|
|
| 64 |
0/2
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 28 not taken.
|
✗ |
return input.render(data); |
| 65 |
|
✗ |
} |
| 66 |
|
|
} |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
// ==================================================================================================================== |
| 70 |
|
|
// API |
| 71 |
|
|
|
| 72 |
|
|
namespace eu::render |
| 73 |
|
|
{ |
| 74 |
|
|
|
| 75 |
|
✗ |
ShaderOptions ShaderOptions::with_transparent_cutoff() const |
| 76 |
|
|
{ |
| 77 |
|
✗ |
auto ret = *this; |
| 78 |
|
✗ |
ret.transparent_cutoff = true; |
| 79 |
|
✗ |
return ret; |
| 80 |
|
|
} |
| 81 |
|
|
|
| 82 |
|
✗ |
ShaderOptions ShaderOptions::with_instanced_mat4() const |
| 83 |
|
|
{ |
| 84 |
|
✗ |
auto ret = *this; |
| 85 |
|
✗ |
ret.use_instancing = true; |
| 86 |
|
✗ |
return ret; |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
|
| 91 |
|
✗ |
std::string generate_blur(std::string_view src, const BlurOptions& options) |
| 92 |
|
|
{ |
| 93 |
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 92 not taken.
|
✗ |
auto input = internal::load_mustache(src); |
| 94 |
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 90 not taken.
|
✗ |
auto data = kainjow::mustache::data{}; |
| 95 |
|
|
|
| 96 |
0/4
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 50 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 48 not taken.
|
✗ |
data["is_horizontal"] = options.blur == BlurType::horizontal; |
| 97 |
0/4
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 59 not taken.
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 57 not taken.
|
✗ |
data["is_vertical"] = options.blur == BlurType::vertical; |
| 98 |
0/8
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 76 not taken.
✗ Branch 23 → 24 not taken.
✗ Branch 23 → 74 not taken.
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 68 not taken.
✗ Branch 27 → 28 not taken.
✗ Branch 27 → 66 not taken.
|
✗ |
data["sample_count"] = fmt::format("{}", options.sample_count); |
| 99 |
0/4
✗ Branch 36 → 37 not taken.
✗ Branch 36 → 81 not taken.
✗ Branch 37 → 38 not taken.
✗ Branch 37 → 79 not taken.
|
✗ |
data["is_gauss"] = options.is_gauss == IsGauss::yes; |
| 100 |
|
|
|
| 101 |
0/2
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 88 not taken.
|
✗ |
return input.render(data); |
| 102 |
|
✗ |
} |
| 103 |
|
|
|
| 104 |
|
|
|
| 105 |
|
|
|
| 106 |
|
✗ |
ShaderSource_withLayout load_shader_source(const ShaderSource& source, const ShaderOptions& options, const std::string& uniform_buffer_source) |
| 107 |
|
|
{ |
| 108 |
|
|
auto layout = core::ShaderVertexAttributes |
| 109 |
|
|
{ |
| 110 |
|
|
{ |
| 111 |
|
|
.type = core::VertexType::position3, |
| 112 |
|
✗ |
.name = "a_position" |
| 113 |
|
|
}, |
| 114 |
|
|
{ |
| 115 |
|
|
.type=core::VertexType::color3, |
| 116 |
|
|
.name = "a_color" |
| 117 |
|
|
} |
| 118 |
0/6
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 46 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
|
✗ |
}; |
| 119 |
|
|
|
| 120 |
0/2
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 22 not taken.
|
✗ |
if (options.use_texture) |
| 121 |
|
|
{ |
| 122 |
0/4
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 64 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 62 not taken.
|
✗ |
layout.emplace_back(core::VertexElementDescription |
| 123 |
|
|
{ |
| 124 |
|
|
.type = core::VertexType::texture2, |
| 125 |
|
✗ |
.name = "a_tex_coord" |
| 126 |
|
|
}); |
| 127 |
|
|
} |
| 128 |
|
|
|
| 129 |
0/2
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 30 not taken.
|
✗ |
if (options.use_lights) |
| 130 |
|
|
{ |
| 131 |
0/4
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 70 not taken.
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 68 not taken.
|
✗ |
layout.emplace_back(core::VertexElementDescription |
| 132 |
|
|
{ |
| 133 |
|
|
.type = core::VertexType::normal3, |
| 134 |
|
✗ |
.name = "a_normal" |
| 135 |
|
|
}); |
| 136 |
|
|
} |
| 137 |
|
|
|
| 138 |
0/14
✗ Branch 30 → 31 not taken.
✗ Branch 30 → 83 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 77 not taken.
✗ Branch 34 → 35 not taken.
✗ Branch 34 → 74 not taken.
✗ Branch 36 → 37 not taken.
✗ Branch 36 → 38 not taken.
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 74 → 75 not taken.
✗ Branch 74 → 76 not taken.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
|
✗ |
return ShaderSource_withLayout |
| 139 |
|
|
{ |
| 140 |
|
|
.layout = layout, |
| 141 |
|
|
.vertex = internal::generate(source.vertex, options, uniform_buffer_source), |
| 142 |
|
|
.fragment = internal::generate(source.fragment, options, uniform_buffer_source) |
| 143 |
|
✗ |
}; |
| 144 |
0/8
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 53 not taken.
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 53 not taken.
✗ Branch 56 → 57 not taken.
✗ Branch 56 → 60 not taken.
✗ Branch 58 → 59 not taken.
✗ Branch 58 → 60 not taken.
|
✗ |
} |
| 145 |
|
|
|
| 146 |
|
✗ |
ShaderSource load_skybox_source(const ShaderSource& source, const std::string& uniform_buffer_source) |
| 147 |
|
|
{ |
| 148 |
0/6
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 14 not taken.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 9 not taken.
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 16 not taken.
|
✗ |
return ShaderSource |
| 149 |
|
|
{ |
| 150 |
|
|
.vertex = internal::generate(source.vertex, uniform_buffer_source), |
| 151 |
|
|
.fragment = internal::generate(source.fragment, uniform_buffer_source) |
| 152 |
|
✗ |
}; |
| 153 |
|
|
} |
| 154 |
|
|
|
| 155 |
|
|
} |
| 156 |
|
|
|