2#include <ossia/detail/variant.hpp>
4#include <score_plugin_gfx_export.h>
14class invalid_file :
public std::runtime_error
17 using std::runtime_error::runtime_error;
26 using value_type = bool;
27 using has_default = std::true_type;
33 using value_type = int64_t;
34 using has_minmax = std::true_type;
35 std::vector<ossia::variant<int64_t, double, std::string>> values;
36 std::vector<std::string> labels;
52 std::optional<int64_t> min;
53 std::optional<int64_t> max;
58 using value_type = double;
59 using has_minmax = std::true_type;
67 using value_type = std::array<double, 2>;
68 using has_minmax = std::true_type;
69 std::optional<value_type> def{};
70 std::optional<value_type> min{};
71 std::optional<value_type> max{};
76 using value_type = std::array<double, 3>;
77 using has_minmax = std::true_type;
78 std::optional<value_type> def{};
79 std::optional<value_type> min{};
80 std::optional<value_type> max{};
91 using value_type = std::array<double, 4>;
92 using has_minmax = std::true_type;
93 std::optional<value_type> def{};
94 std::optional<value_type> min{};
95 std::optional<value_type> max{};
122 std::string min_filter;
123 std::string mag_filter;
124 std::string mipmap_mode;
125 std::optional<float> anisotropy;
126 std::string border_color;
127 std::optional<float> lod_bias;
128 std::optional<float> min_lod;
129 std::optional<float> max_lod;
132 friend bool operator==(
const sampler_config&,
const sampler_config&) =
default;
137enum class composite_mode : uint8_t
151 bool is_array{
false};
159 bool is_static{
false};
160 sampler_config sampler;
181 sampler_config sampler;
191struct audio_sampler_config
200 audio_sampler_config sampler;
206 audio_sampler_config sampler;
209struct audioHist_input
212 audio_sampler_config sampler;
233 std::vector<layout_field> layout;
238 std::string visibility{
"vertex+fragment"};
252 std::vector<layout_field> layout;
254 std::string buffer_usage;
259 bool persistent{
false};
264 std::string visibility{
"fragment"};
270 sampler_config sampler;
273struct csf_image_input
278 std::string width_expression;
279 std::string height_expression;
280 std::string depth_expression;
300 bool is_array{
false};
301 std::string layers_expression;
305 std::string visibility{
"compute"};
311 bool persistent{
false};
319 bool generate_mips{
false};
322 composite_mode composite{composite_mode::unspecified};
324 bool is3D() const noexcept {
return dimensions == 3 || !depth_expression.empty(); }
325 bool isCube() const noexcept {
return cubemap; }
336 std::string geometry;
337 std::string attribute;
338 std::string auxiliary;
341 struct attribute_request
344 std::string semantic;
360 std::optional<copy_from> forward;
367 struct auxiliary_request
372 std::vector<storage_input::layout_field> layout;
377 std::optional<copy_from> forward;
386 bool persistent{
false};
394 bool is_uniform{
false};
403 struct auxiliary_texture_request
407 bool is_array{
false};
408 bool is_cubemap{
false};
409 bool is_depth{
false};
417 bool is_storage{
false};
418 std::string format{
"rgba8"};
419 std::string access{
"read_write"};
431 std::string width_expression;
432 std::string height_expression;
433 std::string depth_expression;
434 std::string layers_expression;
436 sampler_config sampler;
448 std::string ladder_base;
449 int ladder_index{-1};
452 bool in_ladder() const noexcept {
return !ladder_base.empty(); }
453 bool owns_ladder() const noexcept {
return ladder_index == 0 && in_ladder(); }
456 std::vector<attribute_request> attributes;
457 std::vector<auxiliary_request> auxiliary;
458 std::vector<auxiliary_texture_request> auxiliary_textures;
460 std::string vertex_count;
461 std::string instance_count;
467 bool persistent{
false};
474 std::string format_id;
479 std::string topology;
481 struct indirect_request
490 bool draw_count{
false};
505 std::optional<indirect_request> indirect;
510 using input_impl = ossia::variant<
511 float_input, long_input, event_input, bool_input, color_input, point2d_input,
512 point3d_input, image_input, cubemap_input, audio_input, audioFFT_input,
513 audioHist_input, storage_input, texture_input, csf_image_input,
514 geometry_input, uniform_input>;
523enum class attribute_type
606struct vertex_attribute
609 attribute_type type{};
619 std::string semantic;
627 std::string interpolation;
630struct vertex_input : vertex_attribute
657 std::vector<double> default_val;
659struct vertex_output : vertex_attribute
662struct fragment_input : vertex_attribute
665struct fragment_output : vertex_attribute
677enum class alpha_mode : uint8_t
684struct blend_attachment
687 std::string src_color{
"src_alpha"};
688 std::string dst_color{
"one_minus_src_alpha"};
689 std::string op_color{
"add"};
690 std::string src_alpha{
"one"};
691 std::string dst_alpha{
"one_minus_src_alpha"};
692 std::string op_alpha{
"add"};
693 std::string color_write{
"rgba"};
696struct stencil_op_state
698 std::string fail_op{
"keep"};
699 std::string depth_fail_op{
"keep"};
700 std::string pass_op{
"keep"};
701 std::string compare_op{
"always"};
706 std::optional<bool> depth_test;
707 std::optional<bool> depth_write;
708 std::optional<std::string> depth_compare;
709 std::optional<float> depth_bias;
710 std::optional<float> slope_scaled_depth_bias;
712 std::optional<std::string> cull_mode;
713 std::optional<std::string> front_face;
714 std::optional<std::string> polygon_mode;
715 std::optional<float> line_width;
734 std::optional<uint32_t> vertex_count;
735 std::optional<uint32_t> instance_count;
739 std::optional<std::string> topology;
743 std::optional<blend_attachment> blend_all;
744 std::vector<blend_attachment> blend_per_attachment;
747 std::optional<bool> stencil_test;
748 std::optional<uint32_t> stencil_read_mask;
749 std::optional<uint32_t> stencil_write_mask;
750 std::optional<stencil_op_state> stencil_front;
751 std::optional<stencil_op_state> stencil_back;
761 std::optional<std::array<int, 2>> shading_rate;
768 bool float_storage{};
769 bool nearest_filter{};
770 std::string width_expression{};
771 std::string height_expression{};
779 std::string z_expression{};
784 std::string format{};
787 pipeline_state override_state;
790struct output_declaration
821 bool is_cubemap{
false};
832 bool generate_mips{
false};
850 std::string width_expression;
851 std::string height_expression;
854 alpha_mode alpha{alpha_mode::unspecified};
857 composite_mode composite{composite_mode::unspecified};
862enum class render_queue : uint8_t
874 std::string format{
"rgba16f"};
875 std::array<float, 4> clear{0.f, 0.f, 0.f, 0.f};
876 std::optional<blend_attachment> blend;
877 composite_mode composite{composite_mode::unspecified};
884 bool declared{
false};
885 std::string output{
"isf_FragColor"};
886 std::optional<blend_attachment> blend;
887 composite_mode composite{composite_mode::unspecified};
888 bool depth_write{
false};
889 std::string depth_input;
890 std::string fragment;
895 bool declared{
false};
896 std::vector<layer_target> targets;
897 bool depth_test{
true};
898 layer_resolve resolve;
900 bool enabled() const noexcept {
return declared; }
912 std::string description;
914 std::vector<std::string> categories;
919 alpha_mode alpha{alpha_mode::unspecified};
923 composite_mode composite{composite_mode::unspecified};
924 std::vector<input> inputs;
925 std::vector<output_declaration> outputs;
926 std::vector<pass> passes;
927 std::vector<std::string> pass_targets;
928 bool default_vertex_shader{};
932 std::string primitive_mode;
933 std::string line_size;
934 std::array<double, 4> background_color{};
937 struct type_definition
940 std::vector<storage_input::layout_field> layout;
942 std::vector<type_definition> types;
946 std::array<int, 3> local_size{16, 16, 1};
947 std::string execution_type{
"2D_IMAGE"};
948 std::string target_resource;
953 std::array<int, 3> workgroups{1, 1, 1};
956 int indirect_byte_offset{0};
957 std::array<std::string, 3> stride{
"1",
"1",
"1"};
958 std::array<int, 3> user_dispatch_ports{-1, -1, -1};
960 std::vector<dispatch_info> csf_passes;
964 std::vector<vertex_input> vertex_inputs;
965 std::vector<vertex_output> vertex_outputs;
966 std::vector<fragment_input> fragment_inputs;
967 std::vector<fragment_output> fragment_outputs;
971 std::vector<geometry_input::auxiliary_request> auxiliary;
979 std::vector<geometry_input::auxiliary_texture_request> auxiliary_textures;
983 pipeline_state default_state;
987 int multiview_count{0};
1018 struct raster_execution_model
1022 std::string count_expression;
1024 raster_execution_model execution_model;
1029 std::vector<std::string> extensions{
1030 "GL_GOOGLE_include_directive",
"GL_GOOGLE_cpp_style_line_directive"};
1038 int clip_distances{0};
1045 bool primitive_data{
false};
1050 int cull_distances{0};
1077 render_queue queue{render_queue::unspecified};
1090 std::string depth_layout;
1095SCORE_PLUGIN_GFX_EXPORT
1096alpha_mode resolve_alpha(
1097 const descriptor& d,
const output_declaration* out =
nullptr) noexcept;
1101SCORE_PLUGIN_GFX_EXPORT
1102composite_mode resolve_composite(
1103 const descriptor& d, const output_declaration* out =
nullptr) noexcept;
1104SCORE_PLUGIN_GFX_EXPORT
1105composite_mode resolve_composite(const descriptor& d, const csf_image_input& img) noexcept;
1110SCORE_PLUGIN_GFX_EXPORT
1111bool premultiplied_by_engine(alpha_mode alpha, composite_mode composite) noexcept;
1115SCORE_PLUGIN_GFX_EXPORT
1116bool depth_nearer_is_greater(const descriptor& d) noexcept;
1119SCORE_PLUGIN_GFX_EXPORT
1120bool draws_transparent(const descriptor& d) noexcept;
1125SCORE_PLUGIN_GFX_EXPORT
1126bool renders_cube_faces(const descriptor& d) noexcept;
1129SCORE_PLUGIN_GFX_EXPORT
1130bool declares_blend(const pipeline_state& s) noexcept;
1136SCORE_PLUGIN_GFX_EXPORT
1137bool is_premultiplied_render_target(const input& in) noexcept;
1139class SCORE_PLUGIN_GFX_EXPORT parser
1141 std::string m_sourceVertex;
1142 std::string m_sourceFragment;
1143 std::string m_source_geometry_filter;
1146 std::string m_vertex;
1147 std::string m_fragment;
1148 std::string m_geometry_filter;
1153 bool m_injected_camera_aux{
false};
1158 enum class ShaderType
1168 RawRaytracePipeline,
1171 parser(std::string vert, std::string frag,
int glslVersion, ShaderType);
1172 explicit parser(std::string isf_geom_filter, ShaderType t);
1174 descriptor data()
const;
1175 descriptor::Mode mode()
const;
1176 std::string vertex()
const;
1177 std::string fragment()
const;
1178 std::string geometry_filter()
const;
1179 std::string compute_shader()
const;
1180 static std::pair<int, descriptor> parse_isf_header(std::string_view source);
1181 void parse_shadertoy_json(
const std::string& json);
1183 std::string write_isf()
const;
1187 void parse_raw_raster_pipeline();
1188 void parse_shadertoy();
1189 void parse_glsl_sandbox();
1190 void parse_geometry_filter();
@ Unknown
Versions unreadable; treated as usable.