Merge branch 'blender-v3.2-release'
This commit is contained in:
@@ -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, ¶ms);
|
||||
|
||||
|
||||
@@ -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, ¶ms);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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, ¶ms);
|
||||
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, ¶ms);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, ¶ms); \
|
||||
sd->flag |= (bsdf) ? bsdf_##lower##_setup(bsdf) : 0; \
|
||||
} \
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user