diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-10 00:52:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-10 00:52:44 +0300 |
commit | b6b94f878ff0b5a89cb8ee1493e4cafd004f8c27 (patch) | |
tree | 3c696dc4d3fd1cd584236ed90ad5551539d6c388 | |
parent | bda9a1b10387fba141a2ceecc34fb91d37e03862 (diff) | |
parent | 7301547ca7eea475b7f41b70d36b079d04708718 (diff) |
Merge branch 'blender-v3.2-release'
29 files changed, 97 insertions, 184 deletions
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index 8f4738d1f1c..b63e86a3ac2 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -54,9 +54,6 @@ include(cmake/freetype.cmake) include(cmake/freeglut.cmake) include(cmake/glew.cmake) include(cmake/alembic.cmake) -include(cmake/glfw.cmake) -include(cmake/clew.cmake) -include(cmake/cuew.cmake) include(cmake/opensubdiv.cmake) include(cmake/sdl.cmake) include(cmake/opencollada.cmake) diff --git a/build_files/build_environment/cmake/clew.cmake b/build_files/build_environment/cmake/clew.cmake deleted file mode 100644 index 8c965d52d2c..00000000000 --- a/build_files/build_environment/cmake/clew.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -set(CLEW_EXTRA_ARGS) - -ExternalProject_Add(external_clew - URL file://${PACKAGE_DIR}/${CLEW_FILE} - DOWNLOAD_DIR ${DOWNLOAD_DIR} - URL_HASH ${CLEW_HASH_TYPE}=${CLEW_HASH} - PREFIX ${BUILD_DIR}/clew - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/clew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CLEW_EXTRA_ARGS} - INSTALL_DIR ${LIBDIR}/clew -) diff --git a/build_files/build_environment/cmake/cuew.cmake b/build_files/build_environment/cmake/cuew.cmake deleted file mode 100644 index 8beb8b4fade..00000000000 --- a/build_files/build_environment/cmake/cuew.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -set(CUEW_EXTRA_ARGS) - -ExternalProject_Add(external_cuew - URL file://${PACKAGE_DIR}/${CUEW_FILE} - DOWNLOAD_DIR ${DOWNLOAD_DIR} - URL_HASH ${CUEW_HASH_TYPE}=${CUEW_HASH} - PREFIX ${BUILD_DIR}/cuew - PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/cuew/src/external_cuew < ${PATCH_DIR}/cuew.diff - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/cuew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CUEW_EXTRA_ARGS} - INSTALL_DIR ${LIBDIR}/cuew -) diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake index 80c53d05c28..81e7f7ab3fe 100644 --- a/build_files/build_environment/cmake/download.cmake +++ b/build_files/build_environment/cmake/download.cmake @@ -39,10 +39,6 @@ download_source(FREETYPE) download_source(GLEW) download_source(FREEGLUT) download_source(ALEMBIC) -download_source(GLFW) -download_source(CLEW) -download_source(GLFW) -download_source(CUEW) download_source(OPENSUBDIV) download_source(SDL) download_source(OPENCOLLADA) diff --git a/build_files/build_environment/cmake/glfw.cmake b/build_files/build_environment/cmake/glfw.cmake deleted file mode 100644 index 29fce7609e5..00000000000 --- a/build_files/build_environment/cmake/glfw.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -set(GLFW_EXTRA_ARGS) - -ExternalProject_Add(external_glfw - URL file://${PACKAGE_DIR}/${GLFW_FILE} - DOWNLOAD_DIR ${DOWNLOAD_DIR} - URL_HASH ${GLFW_HASH_TYPE}=${GLFW_HASH} - PREFIX ${BUILD_DIR}/glfw - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glfw -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${GLFW_EXTRA_ARGS} - INSTALL_DIR ${LIBDIR}/glfw -) diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake index 2246031be83..4e2d1503406 100644 --- a/build_files/build_environment/cmake/opencolorio.cmake +++ b/build_files/build_environment/cmake/opencolorio.cmake @@ -53,7 +53,8 @@ add_dependencies( external_opencolorio external_yamlcpp external_expat - external_openexr + external_imath + external_pystring ) if(WIN32) diff --git a/build_files/build_environment/cmake/opensubdiv.cmake b/build_files/build_environment/cmake/opensubdiv.cmake index 6d6e3568406..a142160b9cc 100644 --- a/build_files/build_environment/cmake/opensubdiv.cmake +++ b/build_files/build_environment/cmake/opensubdiv.cmake @@ -10,20 +10,16 @@ set(OPENSUBDIV_EXTRA_ARGS -DNO_OMP=ON -DNO_TBB=OFF -DNO_CUDA=ON - -DNO_OPENCL=OFF - -DNO_CLEW=OFF + -DNO_OPENCL=ON + -DNO_CLEW=ON -DNO_OPENGL=OFF -DNO_METAL=OFF -DNO_DX=ON -DNO_TESTS=ON -DNO_GLTESTS=ON - -DNO_GLEW=OFF - -DNO_GLFW=OFF + -DNO_GLEW=ON + -DNO_GLFW=ON -DNO_GLFW_X11=ON - -DGLEW_INCLUDE_DIR=${LIBDIR}/glew/include - -DGLEW_LIBRARY=${LIBDIR}/glew/lib/libGLEW${LIBEXT} - -DGLFW_INCLUDE_DIR=${LIBDIR}/glfw/include - -DGLFW_LIBRARIES=${LIBDIR}/glfw/lib/glfw3${LIBEXT} ) if(WIN32) @@ -31,19 +27,12 @@ if(WIN32) ${OPENSUBDIV_EXTRA_ARGS} -DTBB_INCLUDE_DIR=${LIBDIR}/tbb/include -DTBB_LIBRARIES=${LIBDIR}/tbb/lib/tbb.lib - -DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/CL - -DCLEW_LIBRARY=${LIBDIR}/clew/lib/clew${LIBEXT} - -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include - -DCUEW_LIBRARY=${LIBDIR}/cuew/lib/cuew${LIBEXT} ) else() set(OPENSUBDIV_EXTRA_ARGS ${OPENSUBDIV_EXTRA_ARGS} -DTBB_INCLUDE_DIR=${LIBDIR}/tbb/include -DTBB_tbb_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}tbb_static${LIBEXT} - -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include - -DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/CL - -DCLEW_LIBRARY=${LIBDIR}/clew/lib/static/${LIBPREFIX}clew${LIBEXT} ) endif() @@ -75,9 +64,5 @@ endif() add_dependencies( external_opensubdiv - external_glew - external_glfw - external_clew - external_cuew external_tbb ) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 25267273db0..550be86b6b6 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -98,27 +98,6 @@ set(ALEMBIC_HASH 2cd8d6e5a3ac4a014e24a4b04f4fadf9) set(ALEMBIC_HASH_TYPE MD5) set(ALEMBIC_FILE alembic-${ALEMBIC_VERSION}.tar.gz) -# hash is for 3.1.2 -set(GLFW_GIT_UID 30306e54705c3adae9fe082c816a3be71963485c) -set(GLFW_URI https://github.com/glfw/glfw/archive/${GLFW_GIT_UID}.zip) -set(GLFW_HASH 20cacb1613da7eeb092f3ac4f6b2b3d0) -set(GLFW_HASH_TYPE MD5) -set(GLFW_FILE glfw-${GLFW_GIT_UID}.zip) - -# latest uid in git as of 2016-04-01 -set(CLEW_GIT_UID 277db43f6cafe8b27c6f1055f69dc67da4aeb299) -set(CLEW_URI https://github.com/OpenCLWrangler/clew/archive/${CLEW_GIT_UID}.zip) -set(CLEW_HASH 2c699d10ed78362e71f56fae2a4c5f98) -set(CLEW_HASH_TYPE MD5) -set(CLEW_FILE clew-${CLEW_GIT_UID}.zip) - -# latest uid in git as of 2016-04-01 -set(CUEW_GIT_UID 1744972026de9cf27c8a7dc39cf39cd83d5f922f) -set(CUEW_URI https://github.com/CudaWrangler/cuew/archive/${CUEW_GIT_UID}.zip) -set(CUEW_HASH 86760d62978ebfd96cd93f5aa1abaf4a) -set(CUEW_HASH_TYPE MD5) -set(CUEW_FILE cuew-${CUEW_GIT_UID}.zip) - set(OPENSUBDIV_VERSION v3_4_4) set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz) set(OPENSUBDIV_HASH 39ecc5caf0abebc943d1ce131855e76e) diff --git a/build_files/build_environment/dependencies.dot b/build_files/build_environment/dependencies.dot index 62949f3de62..7e8637fbced 100644 --- a/build_files/build_environment/dependencies.dot +++ b/build_files/build_environment/dependencies.dot @@ -37,10 +37,6 @@ graph[autosize = false, size = "25.7,8.3!", resolution = 300, overlap = false, s external_openimageio -- external_webp; external_openimageio -- external_opencolorio_extra; external_openmp -- external_clang; - external_opensubdiv -- external_glew; - external_opensubdiv -- external_glfw; - external_opensubdiv -- external_clew; - external_opensubdiv -- external_cuew; external_opensubdiv -- external_tbb; openvdb -- external_tbb; openvdb -- external_boost; diff --git a/build_files/build_environment/patches/cuew.diff b/build_files/build_environment/patches/cuew.diff deleted file mode 100644 index 0363034cd93..00000000000 --- a/build_files/build_environment/patches/cuew.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- CmakeLists.txt.orig 2015-12-31 03:46:41 -0700 -+++ CMakeLists.txt 2016-04-01 13:28:33 -0600 -@@ -22,3 +22,10 @@ - - add_executable(testcuew cuewTest/cuewTest.c include/cuew.h) - target_link_libraries(testcuew cuew ${CMAKE_DL_LIBS}) -+ -+install(TARGETS cuew -+ LIBRARY DESTINATION lib COMPONENT libraries -+ ARCHIVE DESTINATION lib/static COMPONENT libraries) -+ -+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cuew.h -+ DESTINATION include/) -\ No newline at end of file ---- src/cuew.c 2016-04-01 13:41:43 -0600 -+++ src/cuew.c 2016-04-01 13:41:11 -0600 -@@ -15,7 +15,9 @@ - */ - - #ifdef _MSC_VER -+#if _MSC_VER < 1900 - # define snprintf _snprintf -+#endif - # define popen _popen - # define pclose _pclose - # define _CRT_SECURE_NO_WARNINGS diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 45abac33795..0344622e81d 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -343,8 +343,16 @@ int BLI_strcmp_ignore_pad(const char *str1, const char *str2, char pad) ATTR_WAR */ size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +/** + * String case conversion, not affected by locale. + */ + void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(); void BLI_str_toupper_ascii(char *str, size_t len) ATTR_NONNULL(); + +char BLI_tolower_ascii(const char c); +char BLI_toupper_ascii(const char c); + /** * Strip white-space from end of the string. */ diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 74559751d91..8387eb5f4f9 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -914,14 +914,22 @@ size_t BLI_strnlen(const char *s, const size_t maxlen) /** \name String Case Conversion * \{ */ +char BLI_tolower_ascii(const char c) +{ + return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c; +} + +char BLI_toupper_ascii(const char c) +{ + return (c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c; +} + void BLI_str_tolower_ascii(char *str, const size_t len) { size_t i; for (i = 0; (i < len) && str[i]; i++) { - if (str[i] >= 'A' && str[i] <= 'Z') { - str[i] += 'a' - 'A'; - } + str[i] = BLI_tolower_ascii(str[i]); } } @@ -930,9 +938,7 @@ void BLI_str_toupper_ascii(char *str, const size_t len) size_t i; for (i = 0; (i < len) && str[i]; i++) { - if (str[i] >= 'a' && str[i] <= 'z') { - str[i] -= 'a' - 'A'; - } + str[i] = BLI_toupper_ascii(str[i]); } } diff --git a/source/blender/draw/engines/eevee/shaders/closure_eval_surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_eval_surface_lib.glsl index f85ef4a89a4..0f5290a7c07 100644 --- a/source/blender/draw/engines/eevee/shaders/closure_eval_surface_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/closure_eval_surface_lib.glsl @@ -309,16 +309,19 @@ vec4 closure_to_rgba(Closure closure) return vec4(closure.radiance, 1.0 - saturate(avg(closure.transmittance))); } -Closure closure_add(Closure cl1, Closure cl2) +Closure closure_add(inout Closure cl1, inout Closure cl2) { Closure cl; cl.radiance = cl1.radiance + cl2.radiance; cl.transmittance = cl1.transmittance + cl2.transmittance; cl.holdout = cl1.holdout + cl2.holdout; + /* Make sure each closure is only added once to the result. */ + cl1 = CLOSURE_DEFAULT; + cl2 = CLOSURE_DEFAULT; return cl; } -Closure closure_mix(Closure cl1, Closure cl2, float fac) +Closure closure_mix(inout Closure cl1, inout Closure cl2, float fac) { /* Weights have already been applied. */ return closure_add(cl1, cl2); diff --git a/source/blender/draw/engines/eevee/shaders/closure_eval_volume_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_eval_volume_lib.glsl index e450b8ad3c8..5e34d654cfd 100644 --- a/source/blender/draw/engines/eevee/shaders/closure_eval_volume_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/closure_eval_volume_lib.glsl @@ -92,7 +92,7 @@ vec4 closure_to_rgba(Closure closure) return vec4(0.0); } -Closure closure_mix(Closure cl1, Closure cl2, float fac) +Closure closure_mix(inout Closure cl1, inout Closure cl2, float fac) { Closure cl; cl.absorption = mix(cl1.absorption, cl2.absorption, fac); @@ -102,7 +102,7 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac) return cl; } -Closure closure_add(Closure cl1, Closure cl2) +Closure closure_add(inout Closure cl1, inout Closure cl2) { Closure cl; cl.absorption = cl1.absorption + cl2.absorption; diff --git a/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl index 9698b5ea6f5..21d347942ca 100644 --- a/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl @@ -87,8 +87,8 @@ Closure closure_eval(ClosureDiffuse diffuse, ClosureReflection clearcoat, ClosureRefraction refraction); -Closure closure_add(Closure cl1, Closure cl2); -Closure closure_mix(Closure cl1, Closure cl2, float fac); +Closure closure_add(inout Closure cl1, inout Closure cl2); +Closure closure_mix(inout Closure cl1, inout Closure cl2, float fac); float ambient_occlusion_eval(vec3 normal, float distance, diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl index 1f2f7cb65cc..696e5d4c97b 100644 --- a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl @@ -112,6 +112,7 @@ GlobalData init_globals(void) surf.N = -surf.N; } # ifdef HAIR_SHADER + vec3 V = cameraVec(surf.P); /* Shade as a cylinder. */ vec3 B = normalize(cross(worldNormal, hairTangent)); float cos_theta; @@ -125,7 +126,10 @@ GlobalData init_globals(void) } float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta)); surf.N = safe_normalize(worldNormal * sin_theta + B * cos_theta); - surf.T = hairTangent; + surf.curve_T = -hairTangent; + /* Costly, but follows cycles per pixel tangent space (not following curve shape). */ + surf.curve_B = cross(V, surf.curve_T); + surf.curve_N = safe_normalize(cross(surf.curve_T, surf.curve_B)); surf.is_strand = true; surf.hair_time = hairTime; surf.hair_thickness = hairThickness; @@ -134,7 +138,7 @@ GlobalData init_globals(void) surf.barycentric_coords = hair_resolve_barycentric(hairBary); # endif # else - surf.T = vec3(0.0); + surf.curve_T = surf.curve_B = surf.curve_N = vec3(0.0); surf.is_strand = false; surf.hair_time = 0.0; surf.hair_thickness = 0.0; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_geom_curves_vert.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_geom_curves_vert.glsl index 11f93ad0d14..708bd153e84 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_geom_curves_vert.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_geom_curves_vert.glsl @@ -18,7 +18,7 @@ void main() ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz, interp.P, - T, + interp.curves_tangent, interp.curves_binormal, interp.curves_time, interp.curves_thickness, diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl index 06191a5c007..277b2e35d8b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl @@ -9,6 +9,7 @@ float g_holdout; /* The Closure type is never used. Use float as dummy type. */ #define Closure float +#define CLOSURE_DEFAULT 0.0 /* Sampled closure parameters. */ ClosureDiffuse g_diffuse_data; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl index 0d8644c9901..30b48edaa78 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_lib.glsl @@ -42,6 +42,12 @@ void init_globals_curves() float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta)); g_data.N = normalize(interp.N * sin_theta + interp.curves_binormal * cos_theta); + /* Costly, but follows cycles per pixel tangent space (not following curve shape). */ + vec3 V = cameraVec(g_data.P); + g_data.curve_T = -interp.curves_tangent; + g_data.curve_B = cross(V, g_data.curve_T); + g_data.curve_N = safe_normalize(cross(g_data.curve_T, g_data.curve_B)); + g_data.is_strand = true; g_data.hair_time = interp.curves_time; g_data.hair_thickness = interp.curves_thickness; @@ -94,6 +100,7 @@ void init_interface() interp.P = vec3(0.0); interp.N = vec3(0.0); interp.barycentric_coords = vec2(0.0); + interp.curves_tangent = vec3(0.0); interp.curves_binormal = vec3(0.0); interp.curves_time = 0.0; interp.curves_time_width = 0.0; diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh index cd297de5719..ccd67360073 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh @@ -54,6 +54,7 @@ GPU_SHADER_INTERFACE_INFO(eevee_surf_iface, "interp") .smooth(Type::VEC3, "P") .smooth(Type::VEC3, "N") .smooth(Type::VEC2, "barycentric_coords") + .smooth(Type::VEC3, "curves_tangent") .smooth(Type::VEC3, "curves_binormal") .smooth(Type::FLOAT, "curves_time") .smooth(Type::FLOAT, "curves_time_width") diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index fa911037d00..f1b46f8bf86 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -61,24 +61,25 @@ struct GPUCodegenCreateInfo : ShaderCreateInfo { char var_names[16][8]; blender::Vector<std::array<char, 32>, 16> sampler_names; - void append_sampler_name(const char name[32]) + /* Returns the appended name memory location */ + const char *append_sampler_name(const char name[32]) { - std::array<char, 32> sampler_name; - memcpy(sampler_name.data(), name, 32); - sampler_names.append(sampler_name); + auto index = sampler_names.append_and_get_index(std::array<char, 32>()); + char *name_buffer = sampler_names[index].data(); + memcpy(name_buffer, name, 32); + return name_buffer; } }; /** Optional generated interface. */ StageInterfaceInfo *interface_generated = nullptr; /** Optional name buffer containing names referenced by StringRefNull. */ - NameBuffer *name_buffer = nullptr; + NameBuffer name_buffer; GPUCodegenCreateInfo(const char *name) : ShaderCreateInfo(name){}; ~GPUCodegenCreateInfo() { delete interface_generated; - MEM_delete(name_buffer); }; }; @@ -297,7 +298,6 @@ void GPUCodegen::generate_attribs() GPUCodegenCreateInfo &info = *create_info; - info.name_buffer = MEM_new<GPUCodegenCreateInfo::NameBuffer>("info.name_buffer"); info.interface_generated = new StageInterfaceInfo("codegen_iface", "var_attrs"); StageInterfaceInfo &iface = *info.interface_generated; info.vertex_out(iface); @@ -311,11 +311,11 @@ void GPUCodegen::generate_attribs() BLI_assert_msg(0, "Too many attributes"); break; } - STRNCPY(info.name_buffer->attr_names[slot], attr->input_name); - SNPRINTF(info.name_buffer->var_names[slot], "v%d", attr->id); + STRNCPY(info.name_buffer.attr_names[slot], attr->input_name); + SNPRINTF(info.name_buffer.var_names[slot], "v%d", attr->id); - blender::StringRefNull attr_name = info.name_buffer->attr_names[slot]; - blender::StringRefNull var_name = info.name_buffer->var_names[slot]; + blender::StringRefNull attr_name = info.name_buffer.attr_names[slot]; + blender::StringRefNull var_name = info.name_buffer.var_names[slot]; eGPUType input_type, iface_type; @@ -357,28 +357,19 @@ void GPUCodegen::generate_resources() /* Textures. */ LISTBASE_FOREACH (GPUMaterialTexture *, tex, &graph.textures) { if (tex->colorband) { - info.name_buffer->append_sampler_name(tex->sampler_name); - info.sampler(0, - ImageType::FLOAT_1D_ARRAY, - info.name_buffer->sampler_names.last().data(), - Frequency::BATCH); + const char *name = info.name_buffer.append_sampler_name(tex->sampler_name); + info.sampler(0, ImageType::FLOAT_1D_ARRAY, name, Frequency::BATCH); } else if (tex->tiled_mapping_name[0] != '\0') { - info.name_buffer->append_sampler_name(tex->sampler_name); - info.sampler(0, - ImageType::FLOAT_2D_ARRAY, - info.name_buffer->sampler_names.last().data(), - Frequency::BATCH); - info.name_buffer->append_sampler_name(tex->tiled_mapping_name); - info.sampler(0, - ImageType::FLOAT_1D_ARRAY, - info.name_buffer->sampler_names.last().data(), - Frequency::BATCH); + const char *name = info.name_buffer.append_sampler_name(tex->sampler_name); + info.sampler(0, ImageType::FLOAT_2D_ARRAY, name, Frequency::BATCH); + + const char *name_mapping = info.name_buffer.append_sampler_name(tex->tiled_mapping_name); + info.sampler(0, ImageType::FLOAT_1D_ARRAY, name_mapping, Frequency::BATCH); } else { - info.name_buffer->append_sampler_name(tex->sampler_name); - info.sampler( - 0, ImageType::FLOAT_2D, info.name_buffer->sampler_names.last().data(), Frequency::BATCH); + const char *name = info.name_buffer.append_sampler_name(tex->sampler_name); + info.sampler(0, ImageType::FLOAT_2D, name, Frequency::BATCH); } } diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index bc7ace792bb..b3a091ffbb0 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -611,7 +611,7 @@ bool GPU_link(GPUMaterial *mat, const char *name, ...) va_start(params, name); for (i = 0; i < function->totparam; i++) { - if (function->paramqual[i] != FUNCTION_QUAL_IN) { + if (function->paramqual[i] == FUNCTION_QUAL_OUT) { linkptr = va_arg(params, GPUNodeLink **); gpu_node_output(node, function->paramtype[i], linkptr); } @@ -669,7 +669,7 @@ static bool gpu_stack_link_v(GPUMaterial *material, } for (i = 0; i < function->totparam; i++) { - if (function->paramqual[i] != FUNCTION_QUAL_IN) { + if (function->paramqual[i] == FUNCTION_QUAL_OUT) { if (totout == 0) { linkptr = va_arg(params, GPUNodeLink **); gpu_node_output(node, function->paramtype[i], linkptr); diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl index 5c97eada77d..6091a5c834a 100644 --- a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl @@ -191,8 +191,8 @@ struct GlobalData { vec3 N; /** Geometric Normal. */ vec3 Ng; - /** Surface default Tangent. */ - vec3 T; + /** Curve Tangent Space. */ + vec3 curve_T, curve_B, curve_N; /** Barycentric coordinates. */ vec2 barycentric_coords; vec3 barycentric_dists; diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_add_shader.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_add_shader.glsl index 99117400c57..3f42b6d9094 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_add_shader.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_add_shader.glsl @@ -1,4 +1,4 @@ -void node_add_shader(Closure shader1, Closure shader2, out Closure shader) +void node_add_shader(inout Closure shader1, inout Closure shader2, out Closure shader) { shader = closure_add(shader1, shader2); } diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl index 5e86a4577ee..4c9ff31622f 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl @@ -18,7 +18,7 @@ void node_geometry(vec3 orco, true_normal = g_data.Ng; if (g_data.is_strand) { - tangent = g_data.T; + tangent = g_data.curve_T; } else { tangent_orco_z(orco, orco); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_hair.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_hair.glsl index 7bf8795495a..b24f9ab65f0 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_hair.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_hair.glsl @@ -40,7 +40,7 @@ void node_bsdf_hair_principled(vec4 color, hair_data.color = color.rgb; hair_data.offset = offset; hair_data.roughness = vec2(0.0); - hair_data.T = g_data.T; + hair_data.T = g_data.curve_B; result = closure_eval(hair_data); } diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl index 8e878b6e14b..61458b05c86 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl @@ -5,14 +5,14 @@ void node_hair_info(float hair_length, out float intercept, out float out_length, out float thickness, - out vec3 tangent, + out vec3 normal, out float random) { is_strand = float(g_data.is_strand); intercept = g_data.hair_time; thickness = g_data.hair_thickness; out_length = hair_length; - tangent = g_data.T; + normal = g_data.curve_N; /* TODO: could be precomputed per strand instead. */ random = wang_hash_noise(uint(g_data.hair_strand_id)); } diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_mix_shader.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_mix_shader.glsl index c303d21d7c1..00cfba3ca12 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_mix_shader.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_mix_shader.glsl @@ -1,4 +1,4 @@ -void node_mix_shader(float fac, Closure shader1, Closure shader2, out Closure shader) +void node_mix_shader(float fac, inout Closure shader1, inout Closure shader2, out Closure shader) { shader = closure_mix(shader1, shader2, fac); } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 9948aaac5da..2281d8d85b3 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1394,12 +1394,10 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa const char *name = echan->m->name.c_str(); const char *end = name + strlen(name); const char *token; - char tokenbuf[EXR_TOT_MAXNAME]; - int len; /* some multilayers have the combined buffer with names A B G R saved */ if (name[1] == 0) { - echan->chan_id = name[0]; + echan->chan_id = BLI_toupper_ascii(name[0]); layname[0] = '\0'; if (ELEM(name[0], 'R', 'G', 'B', 'A')) { @@ -1416,13 +1414,17 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa } /* last token is channel identifier */ - len = imb_exr_split_token(name, end, &token); + size_t len = imb_exr_split_token(name, end, &token); if (len == 0) { printf("multilayer read: bad channel name: %s\n", name); return 0; } + + char channelname[EXR_TOT_MAXNAME]; + BLI_strncpy(channelname, token, std::min(len + 1, sizeof(channelname))); + if (len == 1) { - echan->chan_id = token[0]; + echan->chan_id = BLI_toupper_ascii(channelname[0]); } else if (len > 1) { bool ok = false; @@ -1436,36 +1438,35 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa * * Here we do some magic to distinguish such cases. */ - if (ELEM(token[1], 'X', 'Y', 'Z') || ELEM(token[1], 'R', 'G', 'B') || - ELEM(token[1], 'U', 'V', 'A')) { - echan->chan_id = token[1]; + const char chan_id = BLI_toupper_ascii(channelname[1]); + if (ELEM(chan_id, 'X', 'Y', 'Z', 'R', 'G', 'B', 'U', 'V', 'A')) { + echan->chan_id = chan_id; ok = true; } } - else if (BLI_strcaseeq(token, "red")) { + else if (BLI_strcaseeq(channelname, "red")) { echan->chan_id = 'R'; ok = true; } - else if (BLI_strcaseeq(token, "green")) { + else if (BLI_strcaseeq(channelname, "green")) { echan->chan_id = 'G'; ok = true; } - else if (BLI_strcaseeq(token, "blue")) { + else if (BLI_strcaseeq(channelname, "blue")) { echan->chan_id = 'B'; ok = true; } - else if (BLI_strcaseeq(token, "alpha")) { + else if (BLI_strcaseeq(channelname, "alpha")) { echan->chan_id = 'A'; ok = true; } - else if (BLI_strcaseeq(token, "depth")) { + else if (BLI_strcaseeq(channelname, "depth")) { echan->chan_id = 'Z'; ok = true; } if (ok == false) { - BLI_strncpy(tokenbuf, token, std::min(len + 1, EXR_TOT_MAXNAME)); - printf("multilayer read: unknown channel token: %s\n", tokenbuf); + printf("multilayer read: unknown channel token: %s\n", channelname); return 0; } } |