Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp3
-rw-r--r--intern/cycles/kernel/osl/bsdf_phong_ramp.cpp3
-rw-r--r--intern/cycles/kernel/osl/bssrdf.cpp2
-rw-r--r--intern/cycles/kernel/osl/closures.cpp23
-rw-r--r--intern/cycles/kernel/osl/closures.h1
-rw-r--r--source/blender/blenkernel/BKE_subdiv_modifier.h10
-rw-r--r--source/blender/blenkernel/intern/subdiv_modifier.c39
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c4
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c3
10 files changed, 58 insertions, 40 deletions
diff --git a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
index dbbce655ef7..39fcee1ac0d 100644
--- a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp
@@ -17,6 +17,7 @@
#include "kernel/types.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/bsdf_diffuse_ramp.h"
+#include "kernel/closure/bsdf_util.h"
// clang-format on
CCL_NAMESPACE_BEGIN
@@ -30,6 +31,8 @@ class DiffuseRampClosure : public CBSDFClosure {
void setup(ShaderData *sd, uint32_t /* path_flag */, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
DiffuseRampBsdf *bsdf = (DiffuseRampBsdf *)bsdf_alloc_osl(
sd, sizeof(DiffuseRampBsdf), weight, &params);
diff --git a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
index fd602c8847e..972ed7e4a6d 100644
--- a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
+++ b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp
@@ -17,6 +17,7 @@
#include "kernel/types.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/bsdf_phong_ramp.h"
+#include "kernel/closure/bsdf_util.h"
// clang-format on
CCL_NAMESPACE_BEGIN
@@ -30,6 +31,8 @@ class PhongRampClosure : public CBSDFClosure {
void setup(ShaderData *sd, uint32_t /* path_flag */, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
PhongRampBsdf *bsdf = (PhongRampBsdf *)bsdf_alloc_osl(
sd, sizeof(PhongRampBsdf), weight, &params);
diff --git a/intern/cycles/kernel/osl/bssrdf.cpp b/intern/cycles/kernel/osl/bssrdf.cpp
index 29d2d93ce34..4b282fddad3 100644
--- a/intern/cycles/kernel/osl/bssrdf.cpp
+++ b/intern/cycles/kernel/osl/bssrdf.cpp
@@ -44,6 +44,8 @@ class CBSSRDFClosure : public CClosurePrimitive {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
if (method == u_burley) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID);
}
diff --git a/intern/cycles/kernel/osl/closures.cpp b/intern/cycles/kernel/osl/closures.cpp
index 06b91ab9bb7..7c6b48154e4 100644
--- a/intern/cycles/kernel/osl/closures.cpp
+++ b/intern/cycles/kernel/osl/closures.cpp
@@ -180,6 +180,8 @@ class PrincipledSheenClosure : public CBSDFClosure {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
if (!skip(sd, path_flag, LABEL_DIFFUSE)) {
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
PrincipledSheenBsdf *bsdf = (PrincipledSheenBsdf *)bsdf_alloc_osl(
sd, sizeof(PrincipledSheenBsdf), weight, &params);
sd->flag |= (bsdf) ? bsdf_principled_sheen_setup(sd, bsdf) : 0;
@@ -223,6 +225,8 @@ class PrincipledHairClosure : public CBSDFClosure {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
if (!skip(sd, path_flag, LABEL_GLOSSY)) {
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
PrincipledHairBSDF *bsdf = (PrincipledHairBSDF *)alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -282,6 +286,7 @@ class PrincipledClearcoatClosure : public CBSDFClosure {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -503,6 +508,8 @@ class MicrofacetClosure : public CBSDFClosure {
return;
}
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = (MicrofacetBsdf *)bsdf_alloc_osl(
sd, sizeof(MicrofacetBsdf), weight, &params);
@@ -601,6 +608,8 @@ class MicrofacetGGXFresnelClosure : public MicrofacetFresnelClosure {
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -630,6 +639,8 @@ class MicrofacetGGXAnisoFresnelClosure : public MicrofacetFresnelClosure {
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -695,6 +706,8 @@ class MicrofacetMultiGGXClosure : public MicrofacetMultiClosure {
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -723,6 +736,8 @@ class MicrofacetMultiGGXAnisoClosure : public MicrofacetMultiClosure {
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -755,6 +770,8 @@ class MicrofacetMultiGGXGlassClosure : public MicrofacetMultiClosure {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -819,6 +836,8 @@ class MicrofacetMultiGGXFresnelClosure : public MicrofacetMultiFresnelClosure {
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -849,6 +868,8 @@ class MicrofacetMultiGGXAnisoFresnelClosure : public MicrofacetMultiFresnelClosu
public:
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
@@ -883,6 +904,8 @@ class MicrofacetMultiGGXGlassFresnelClosure : public MicrofacetMultiFresnelClosu
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
{
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
+
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
if (!bsdf) {
return;
diff --git a/intern/cycles/kernel/osl/closures.h b/intern/cycles/kernel/osl/closures.h
index 6225644a8e6..e10a3d88a04 100644
--- a/intern/cycles/kernel/osl/closures.h
+++ b/intern/cycles/kernel/osl/closures.h
@@ -114,6 +114,7 @@ class CBSDFClosure : public CClosurePrimitive {
void setup(ShaderData *sd, uint32_t path_flag, float3 weight) \
{ \
if (!skip(sd, path_flag, TYPE)) { \
+ params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N); \
structname *bsdf = (structname *)bsdf_alloc_osl(sd, sizeof(structname), weight, &params); \
sd->flag |= (bsdf) ? bsdf_##lower##_setup(bsdf) : 0; \
} \
diff --git a/source/blender/blenkernel/BKE_subdiv_modifier.h b/source/blender/blenkernel/BKE_subdiv_modifier.h
index e9de7d1532e..4ad17610207 100644
--- a/source/blender/blenkernel/BKE_subdiv_modifier.h
+++ b/source/blender/blenkernel/BKE_subdiv_modifier.h
@@ -42,18 +42,14 @@ bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(
* \param skip_check_is_last: When true, we assume that the modifier passed is the last enabled
* modifier in the stack.
*/
-bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const struct Scene *scene,
- const struct Object *ob,
- const struct Mesh *mesh,
- const struct SubsurfModifierData *smd,
- int required_mode,
- bool skip_check_is_last);
-
bool BKE_subsurf_modifier_can_do_gpu_subdiv(const struct Scene *scene,
const struct Object *ob,
const struct Mesh *mesh,
+ const struct SubsurfModifierData *smd,
int required_mode);
+bool BKE_subsurf_modifier_has_gpu_subdiv(const struct Mesh *mesh);
+
extern void (*BKE_subsurf_modifier_free_gpu_cache_cb)(struct Subdiv *subdiv);
/**
diff --git a/source/blender/blenkernel/intern/subdiv_modifier.c b/source/blender/blenkernel/intern/subdiv_modifier.c
index 3692a3cc4f7..e43da956ce5 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.c
+++ b/source/blender/blenkernel/intern/subdiv_modifier.c
@@ -3,6 +3,8 @@
#include "BKE_subdiv_modifier.h"
+#include "BLI_session_uuid.h"
+
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
@@ -105,12 +107,11 @@ bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(const SubsurfMod
return subsurf_modifier_use_autosmooth_or_split_normals(smd, mesh);
}
-bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const Scene *scene,
- const Object *ob,
- const Mesh *mesh,
- const SubsurfModifierData *smd,
- int required_mode,
- bool skip_check_is_last)
+bool BKE_subsurf_modifier_can_do_gpu_subdiv(const Scene *scene,
+ const Object *ob,
+ const Mesh *mesh,
+ const SubsurfModifierData *smd,
+ int required_mode)
{
if ((U.gpu_flag & USER_GPU_FLAG_SUBDIVISION_EVALUATION) == 0) {
return false;
@@ -122,33 +123,17 @@ bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const Scene *scene,
return false;
}
- if (!skip_check_is_last) {
- ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode);
- if (md != (const ModifierData *)smd) {
- return false;
- }
+ ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode);
+ if (md != (const ModifierData *)smd) {
+ return false;
}
return is_subdivision_evaluation_possible_on_gpu();
}
-bool BKE_subsurf_modifier_can_do_gpu_subdiv(const Scene *scene,
- const Object *ob,
- const Mesh *mesh,
- int required_mode)
+bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh)
{
- ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode);
-
- if (!md) {
- return false;
- }
-
- if (md->type != eModifierType_Subsurf) {
- return false;
- }
-
- return BKE_subsurf_modifier_can_do_gpu_subdiv_ex(
- scene, ob, mesh, (SubsurfModifierData *)md, required_mode, true);
+ return BLI_session_uuid_is_generated(&mesh->runtime.subsurf_session_uuid);
}
void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 080ec50e0fb..65c42545a77 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1357,7 +1357,6 @@ bool BLO_write_file(Main *mainvar,
/* Remapping of relative paths to new file location. */
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
-
if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) {
/* Make all relative as none of the existing paths can be relative in an unsaved document. */
if (relbase_valid == false) {
@@ -1396,6 +1395,13 @@ bool BLO_write_file(Main *mainvar,
}
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
+ /* Some path processing (e.g. with libraries) may use the current `main->filepath`, if this
+ * is not matching the path currently used for saving, unexpected paths corruptions can
+ * happen. See T98201. */
+ char mainvar_filepath_orig[FILE_MAX];
+ STRNCPY(mainvar_filepath_orig, mainvar->filepath);
+ STRNCPY(mainvar->filepath, filepath);
+
/* Check if we need to backup and restore paths. */
if (UNLIKELY(use_save_as_copy)) {
path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag);
@@ -1420,6 +1426,8 @@ bool BLO_write_file(Main *mainvar,
BLI_assert_unreachable(); /* Unreachable. */
break;
}
+
+ STRNCPY(mainvar->filepath, mainvar_filepath_orig);
}
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index ee5223af68d..7fdeaf34965 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1822,9 +1822,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
do_uvcage = !editmesh_eval_final->runtime.is_original;
}
- const int required_mode = BKE_subsurf_modifier_eval_required_mode(DRW_state_is_scene_render(),
- is_editmode);
- const bool do_subdivision = BKE_subsurf_modifier_can_do_gpu_subdiv(scene, ob, me, required_mode);
+ const bool do_subdivision = BKE_subsurf_modifier_has_gpu_subdiv(me);
MeshBufferList *mbuflist = &cache->final.buff;
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 571e564f583..4201bab0326 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -236,8 +236,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
* assigned at this stage of modifier stack evaluation. */
const bool is_editmode = (mesh->edit_mesh != NULL);
const int required_mode = BKE_subsurf_modifier_eval_required_mode(is_render_mode, is_editmode);
- if (BKE_subsurf_modifier_can_do_gpu_subdiv_ex(
- scene, ctx->object, mesh, smd, required_mode, false)) {
+ if (BKE_subsurf_modifier_can_do_gpu_subdiv(scene, ctx->object, mesh, smd, required_mode)) {
subdiv_cache_cpu_evaluation_settings(ctx, mesh, smd);
return result;
}