Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_shader.cc
| Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | switch (type) { | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| os << " "; | os << " "; | ||||
| } | } | ||||
| static std::ostream &print_qualifier(std::ostream &os, const Qualifier &qualifiers) | static std::ostream &print_qualifier(std::ostream &os, const Qualifier &qualifiers) | ||||
| { | { | ||||
| if ((qualifiers & Qualifier::RESTRICT) != Qualifier::RESTRICT) { | if ((qualifiers & Qualifier::RESTRICT) == Qualifier::RESTRICT) { | ||||
| os << "restrict"; | os << "restrict "; | ||||
| } | } | ||||
| if ((qualifiers & Qualifier::READ_ONLY) != Qualifier::READ_ONLY) { | if ((qualifiers & Qualifier::READ_ONLY) == Qualifier::READ_ONLY) { | ||||
| os << "readonly"; | os << "readonly "; | ||||
| } | } | ||||
| if ((qualifiers & Qualifier::WRITE_ONLY) != Qualifier::WRITE_ONLY) { | if ((qualifiers & Qualifier::WRITE_ONLY) == Qualifier::WRITE_ONLY) { | ||||
| os << "writeonly"; | os << "writeonly "; | ||||
| } | } | ||||
| return os << " "; | return os; | ||||
| } | } | ||||
| static void print_resource(std::ostream &os, const ShaderCreateInfo::Resource &res) | static void print_resource(std::ostream &os, const ShaderCreateInfo::Resource &res) | ||||
| { | { | ||||
| if (GLContext::explicit_location_support) { | if (GLContext::explicit_location_support) { | ||||
| os << "layout(binding = " << res.slot; | os << "layout(binding = " << res.slot; | ||||
| if (res.bind_type == ShaderCreateInfo::Resource::BindType::IMAGE) { | if (res.bind_type == ShaderCreateInfo::Resource::BindType::IMAGE) { | ||||
| os << ", " << res.image.format; | os << ", " << res.image.format; | ||||
| Show All 31 Lines | case ShaderCreateInfo::Resource::BindType::UNIFORM_BUFFER: | ||||
| StringRef(res.uniformbuf.name.c_str(), array_offset); | StringRef(res.uniformbuf.name.c_str(), array_offset); | ||||
| os << "uniform " << name_no_array << " { " << res.uniformbuf.type_name << " _" | os << "uniform " << name_no_array << " { " << res.uniformbuf.type_name << " _" | ||||
| << res.uniformbuf.name << "; };\n"; | << res.uniformbuf.name << "; };\n"; | ||||
| break; | break; | ||||
| case ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER: | case ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER: | ||||
| array_offset = res.storagebuf.name.find_first_of("["); | array_offset = res.storagebuf.name.find_first_of("["); | ||||
| name_no_array = (array_offset == -1) ? res.storagebuf.name : | name_no_array = (array_offset == -1) ? res.storagebuf.name : | ||||
| StringRef(res.storagebuf.name.c_str(), array_offset); | StringRef(res.storagebuf.name.c_str(), array_offset); | ||||
| os << "buffer "; | |||||
| print_qualifier(os, res.storagebuf.qualifiers); | print_qualifier(os, res.storagebuf.qualifiers); | ||||
| os << "buffer "; | |||||
| os << name_no_array << " { " << res.storagebuf.type_name << " _" << res.storagebuf.name | os << name_no_array << " { " << res.storagebuf.type_name << " _" << res.storagebuf.name | ||||
| << "; };\n"; | << "; };\n"; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void print_resource_alias(std::ostream &os, const ShaderCreateInfo::Resource &res) | static void print_resource_alias(std::ostream &os, const ShaderCreateInfo::Resource &res) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | std::string GLShader::geometry_interface_declare(const ShaderCreateInfo &info) const | ||||
| ss << "\n"; | ss << "\n"; | ||||
| for (const StageInterfaceInfo *iface : info.geometry_out_interfaces_) { | for (const StageInterfaceInfo *iface : info.geometry_out_interfaces_) { | ||||
| print_interface(ss, "out", *iface); | print_interface(ss, "out", *iface); | ||||
| } | } | ||||
| ss << "\n"; | ss << "\n"; | ||||
| return ss.str(); | return ss.str(); | ||||
| } | } | ||||
| std::string GLShader::compute_layout_declare(const ShaderCreateInfo &info) const | |||||
| { | |||||
| std::stringstream ss; | |||||
| ss << "\n/* Compute Layout. */\n"; | |||||
| ss << "layout(local_size_x = " << info.compute_layout_.local_size_x; | |||||
| if (info.compute_layout_.local_size_y != -1) { | |||||
| ss << ", local_size_y = " << info.compute_layout_.local_size_y; | |||||
| } | |||||
| if (info.compute_layout_.local_size_z != -1) { | |||||
| ss << ", local_size_y = " << info.compute_layout_.local_size_z; | |||||
| } | |||||
| ss << ") in;\n"; | |||||
| ss << "\n"; | |||||
| return ss.str(); | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Shader stage creation | /** \name Shader stage creation | ||||
| * \{ */ | * \{ */ | ||||
| static char *glsl_patch_default_get() | static char *glsl_patch_default_get() | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines | |||||