| 845 | } |
| 846 | |
| 847 | id define_struct(const location &loc, struct_type &info) override |
| 848 | { |
| 849 | const id res = info.id = make_id(); |
| 850 | define_name<naming::unique>(res, info.unique_name); |
| 851 | |
| 852 | _structs.push_back(info); |
| 853 | |
| 854 | std::string &code = _blocks.at(_current_block); |
| 855 | |
| 856 | write_location(code, loc); |
| 857 | |
| 858 | code += "struct " + id_to_name(res) + "\n{\n"; |
| 859 | |
| 860 | for (const member_type &member : info.member_list) |
| 861 | { |
| 862 | code += '\t'; |
| 863 | write_type<true>(code, member.type); // HLSL allows interpolation attributes on struct members, so handle this like a parameter |
| 864 | code += ' ' + member.name; |
| 865 | |
| 866 | if (member.type.is_array()) |
| 867 | code += '[' + std::to_string(member.type.array_length) + ']'; |
| 868 | |
| 869 | if (!member.semantic.empty()) |
| 870 | code += " : " + convert_semantic(member.semantic, std::max(1u, member.type.components() / 4u) * std::max(1u, member.type.array_length)); |
| 871 | |
| 872 | code += ";\n"; |
| 873 | } |
| 874 | |
| 875 | code += "};\n"; |
| 876 | |
| 877 | return res; |
| 878 | } |
| 879 | id define_texture(const location &, texture &info) override |
| 880 | { |
| 881 | const id res = info.id = make_id(); |
nothing calls this directly
no test coverage detected