Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_shader_create_info.cc
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void ShaderCreateInfo::finalize() | ||||
| for (auto &info_name : additional_infos_) { | for (auto &info_name : additional_infos_) { | ||||
| const ShaderCreateInfo &info = *reinterpret_cast<const ShaderCreateInfo *>( | const ShaderCreateInfo &info = *reinterpret_cast<const ShaderCreateInfo *>( | ||||
| gpu_shader_create_info_get(info_name.c_str())); | gpu_shader_create_info_get(info_name.c_str())); | ||||
| /* Recursive. */ | /* Recursive. */ | ||||
| const_cast<ShaderCreateInfo &>(info).finalize(); | const_cast<ShaderCreateInfo &>(info).finalize(); | ||||
| #if 0 /* Enabled for debugging merging. TODO(fclem) exception handling and error reporting in \ | |||||
| console. */ | |||||
| std::cout << "Merging : " << info_name << " > " << name_ << std::endl; | |||||
| #endif | |||||
| interface_names_size_ += info.interface_names_size_; | interface_names_size_ += info.interface_names_size_; | ||||
| vertex_inputs_.extend(info.vertex_inputs_); | vertex_inputs_.extend(info.vertex_inputs_); | ||||
| fragment_outputs_.extend(info.fragment_outputs_); | fragment_outputs_.extend(info.fragment_outputs_); | ||||
| vertex_out_interfaces_.extend(info.vertex_out_interfaces_); | vertex_out_interfaces_.extend(info.vertex_out_interfaces_); | ||||
| geometry_out_interfaces_.extend(info.geometry_out_interfaces_); | geometry_out_interfaces_.extend(info.geometry_out_interfaces_); | ||||
| push_constants_.extend(info.push_constants_); | push_constants_.extend(info.push_constants_); | ||||
| defines_.extend(info.defines_); | defines_.extend(info.defines_); | ||||
| batch_resources_.extend(info.batch_resources_); | batch_resources_.extend(info.batch_resources_); | ||||
| pass_resources_.extend(info.pass_resources_); | pass_resources_.extend(info.pass_resources_); | ||||
| typedef_sources_.extend(info.typedef_sources_); | typedef_sources_.extend_non_duplicates(info.typedef_sources_); | ||||
| validate(info); | validate(info); | ||||
| if (info.local_group_size_[0] != 0) { | if (info.local_group_size_[0] != 0) { | ||||
| BLI_assert(local_group_size_[0] == 0); | BLI_assert(local_group_size_[0] == 0); | ||||
| for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
| local_group_size_[i] = info.local_group_size_[i]; | local_group_size_[i] = info.local_group_size_[i]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | void gpu_shader_create_info_exit() | ||||
| for (auto *value : g_interfaces->values()) { | for (auto *value : g_interfaces->values()) { | ||||
| delete value; | delete value; | ||||
| } | } | ||||
| delete g_interfaces; | delete g_interfaces; | ||||
| } | } | ||||
| bool gpu_shader_create_info_compile_all() | bool gpu_shader_create_info_compile_all() | ||||
| { | { | ||||
| int success = 0; | |||||
| int total = 0; | |||||
| for (ShaderCreateInfo *info : g_create_infos->values()) { | for (ShaderCreateInfo *info : g_create_infos->values()) { | ||||
| if (info->do_static_compilation_) { | if (info->do_static_compilation_) { | ||||
| // printf("Compiling %s: ... \n", info->name_.c_str()); | total++; | ||||
| GPUShader *shader = GPU_shader_create_from_info( | GPUShader *shader = GPU_shader_create_from_info( | ||||
| reinterpret_cast<const GPUShaderCreateInfo *>(info)); | reinterpret_cast<const GPUShaderCreateInfo *>(info)); | ||||
| if (shader == nullptr) { | if (shader == nullptr) { | ||||
| printf("Compilation %s Failed\n", info->name_.c_str()); | printf("Compilation %s Failed\n", info->name_.c_str()); | ||||
| return false; | } | ||||
| else { | |||||
| success++; | |||||
| } | } | ||||
| GPU_shader_free(shader); | GPU_shader_free(shader); | ||||
| // printf("Success\n"); | |||||
| } | } | ||||
| } | } | ||||
| return true; | printf("===============================\n"); | ||||
| printf("Shader Test compilation result: \n"); | |||||
| printf("%d Total\n", total); | |||||
| printf("%d Passed\n", success); | |||||
| printf("%d Failed\n", total - success); | |||||
| printf("===============================\n"); | |||||
| return success == total; | |||||
| } | } | ||||
| /* Runtime create infos are not registered in the dictionary and cannot be searched. */ | /* Runtime create infos are not registered in the dictionary and cannot be searched. */ | ||||
| const GPUShaderCreateInfo *gpu_shader_create_info_get(const char *info_name) | const GPUShaderCreateInfo *gpu_shader_create_info_get(const char *info_name) | ||||
| { | { | ||||
| if (g_create_infos->contains(info_name) == false) { | |||||
| printf("Error: Cannot find shader create info named \"%s\"\n", info_name); | |||||
| } | |||||
| ShaderCreateInfo *info = g_create_infos->lookup(info_name); | ShaderCreateInfo *info = g_create_infos->lookup(info_name); | ||||
| return reinterpret_cast<const GPUShaderCreateInfo *>(info); | return reinterpret_cast<const GPUShaderCreateInfo *>(info); | ||||
| } | } | ||||