Skip to content

Commit

Permalink
Merge remote-tracking branch 'b/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
youle31 committed Apr 5, 2024
2 parents 9066cb4 + 61b2822 commit 57247ac
Show file tree
Hide file tree
Showing 231 changed files with 20,018 additions and 18,108 deletions.
26 changes: 13 additions & 13 deletions intern/clog/clog.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ static void clg_str_vappendf(CLogStringBuf *cstr, const char *fmt, va_list args)
{
/* Use limit because windows may use '-1' for a formatting error. */
const uint len_max = 65535;
uint len_avail = cstr->len_alloc - cstr->len;
while (true) {
uint len_avail = cstr->len_alloc - cstr->len;

va_list args_cpy;
va_copy(args_cpy, args);
int retval = vsnprintf(cstr->data + cstr->len, len_avail, fmt, args_cpy);
Expand All @@ -188,22 +187,23 @@ static void clg_str_vappendf(CLogStringBuf *cstr, const char *fmt, va_list args)
* message. */
break;
}
else if ((uint)retval <= len_avail) {

if ((uint)retval <= len_avail) {
/* Copy was successful. */
cstr->len += (uint)retval;
break;
}
else {
/* vsnprintf was not successful, due to lack of allocated space, retval contains expected
* length of the formatted string, use it to allocate required amount of memory. */
uint len_alloc = cstr->len + (uint)retval;
if (len_alloc >= len_max) {
/* Safe upper-limit, just in case... */
break;
}
clg_str_reserve(cstr, len_alloc);
len_avail = cstr->len_alloc - cstr->len;

/* `vsnprintf` was not successful, due to lack of allocated space, `retval` contains expected
* length of the formatted string, use it to allocate required amount of memory. */
uint len_alloc = cstr->len + (uint)retval;
if (len_alloc >= len_max) {
/* Safe upper-limit, just in case... */
break;
}

clg_str_reserve(cstr, len_alloc);
len_avail = cstr->len_alloc - cstr->len;
}
}

Expand Down
5 changes: 5 additions & 0 deletions intern/cycles/blender/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,11 @@ void BlenderSync::free_data_after_sync(BL::Depsgraph &b_depsgraph)
* but that will need some API support first.
*/
for (BL::Object &b_ob : b_depsgraph.objects) {
/* Grease pencil render requires all evaluated objects available as-is after Cycles is done
* with its part. */
if (b_ob.type() == BL::Object::type_GREASEPENCIL || b_ob.type() == BL::Object::type_GPENCIL) {
continue;
}
b_ob.cache_release();
}
}
Expand Down
27 changes: 17 additions & 10 deletions intern/cycles/device/oneapi/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,9 @@ void OneapiDevice::get_adjusted_global_and_local_sizes(SyclQueue *queue,
size_t &kernel_local_size)
{
assert(queue);

const static size_t preferred_work_group_size_intersect_shading = 32;
const static size_t preferred_work_group_size_intersect = 128;
const static size_t preferred_work_group_size_shading = 256;
const static size_t preferred_work_group_size_shading_simd8 = 64;
/* Shader evaluation kernels seems to use some amount of shared memory, so better
* to avoid usage of maximum work group sizes for them. */
const static size_t preferred_work_group_size_shader_evaluation = 256;
Expand All @@ -783,6 +784,9 @@ void OneapiDevice::get_adjusted_global_and_local_sizes(SyclQueue *queue,
const static size_t preferred_work_group_size_cryptomatte = 512;
const static size_t preferred_work_group_size_default = 1024;

const sycl::device &device = reinterpret_cast<sycl::queue *>(queue)->get_device();
const size_t max_work_group_size = device.get_info<sycl::info::device::max_work_group_size>();

size_t preferred_work_group_size = 0;
switch (kernel) {
case DEVICE_KERNEL_INTEGRATOR_INIT_FROM_CAMERA:
Expand All @@ -792,16 +796,23 @@ void OneapiDevice::get_adjusted_global_and_local_sizes(SyclQueue *queue,
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE:
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK:
case DEVICE_KERNEL_INTEGRATOR_INTERSECT_DEDICATED_LIGHT:
preferred_work_group_size = preferred_work_group_size_intersect;
break;

case DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND:
case DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT:
case DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE:
case DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE:
case DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE:
case DEVICE_KERNEL_INTEGRATOR_SHADE_VOLUME:
case DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW:
case DEVICE_KERNEL_INTEGRATOR_SHADE_DEDICATED_LIGHT:
preferred_work_group_size = preferred_work_group_size_intersect_shading;
break;
case DEVICE_KERNEL_INTEGRATOR_SHADE_DEDICATED_LIGHT: {
const bool device_is_simd8 =
(device.has(sycl::aspect::ext_intel_gpu_eu_simd_width) &&
device.get_info<sycl::ext::intel::info::device::gpu_eu_simd_width>() == 8);
preferred_work_group_size = (device_is_simd8) ? preferred_work_group_size_shading_simd8 :
preferred_work_group_size_shading;
} break;

case DEVICE_KERNEL_CRYPTOMATTE_POSTPROCESS:
preferred_work_group_size = preferred_work_group_size_cryptomatte;
Expand Down Expand Up @@ -829,11 +840,7 @@ void OneapiDevice::get_adjusted_global_and_local_sizes(SyclQueue *queue,
preferred_work_group_size = preferred_work_group_size_default;
}

const size_t limit_work_group_size = reinterpret_cast<sycl::queue *>(queue)
->get_device()
.get_info<sycl::info::device::max_work_group_size>();

kernel_local_size = std::min(limit_work_group_size, preferred_work_group_size);
kernel_local_size = std::min(max_work_group_size, preferred_work_group_size);

/* NOTE(@nsirgien): As for now non-uniform work-groups don't work on most oneAPI devices,
* we extend work size to fit uniformity requirements. */
Expand Down
2 changes: 1 addition & 1 deletion intern/cycles/integrator/denoiser_oidn_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static const char *oidn_device_type_to_string(const OIDNDeviceType type)
return "HIP";
# endif

/* The Metal support was added in OIDN 2.2.*/
/* The Metal support was added in OIDN 2.2. */
# if (OIDN_VERSION_MAJOR > 2) || ((OIDN_VERSION_MAJOR == 2) && (OIDN_VERSION_MINOR >= 2))
case OIDN_DEVICE_TYPE_METAL:
return "METAL";
Expand Down
18 changes: 13 additions & 5 deletions intern/cycles/kernel/closure/bsdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ ccl_device_inline float bsdf_get_roughness_pass_squared(ccl_private const Shader
/* An additional term to smooth illumination on grazing angles when using bump mapping.
* Based on "Taming the Shadow Terminator" by Matt Jen-Yuan Chiang,
* Yining Karl Li and Brent Burley. */
ccl_device_inline float bump_shadowing_term(float3 Ng, float3 N, float3 I)
ccl_device_inline float bump_shadowing_term(ccl_private const ShaderData &sd,
float3 Ng,
float3 N,
float3 I)
{
const float cosNI = dot(N, I);
if (cosNI < 0.0f) {
Expand All @@ -78,6 +81,11 @@ ccl_device_inline float bump_shadowing_term(float3 Ng, float3 N, float3 I)
return 0.0f;
}

/* When bump map correction is not used do skip the smoothing. */
if ((sd.flag & SD_USE_BUMP_MAP_CORRECTION) == 0) {
return 1.0f;
}

/* Return smoothed value to avoid discontinuity at perpendicular angle. */
float g2 = sqr(g);
return -g2 * g + g2 + g;
Expand Down Expand Up @@ -235,8 +243,8 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
*eval *= shift_cos_in(cosNO, frequency_multiplier);
}
if (label & LABEL_DIFFUSE) {
if ((sd->flag & SD_USE_BUMP_MAP_CORRECTION) && !isequal(sc->N, sd->N)) {
*eval *= bump_shadowing_term(sd->N, sc->N, *wo);
if (!isequal(sc->N, sd->N)) {
*eval *= bump_shadowing_term(*sd, sd->N, sc->N, *wo);
}
}
}
Expand Down Expand Up @@ -531,8 +539,8 @@ ccl_device_inline
}

if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
if ((sd->flag & SD_USE_BUMP_MAP_CORRECTION) && !isequal(sc->N, sd->N)) {
eval *= bump_shadowing_term(sd->N, sc->N, wo);
if (!isequal(sc->N, sd->N)) {
eval *= bump_shadowing_term(*sd, sd->N, sc->N, wo);
}
}

Expand Down
2 changes: 1 addition & 1 deletion intern/cycles/kernel/closure/bsdf_principled_hair_huang.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef struct HuangHairExtra {
/* Optional modulation factors. */
float R, TT, TRT;

/* Local coordinate system. X is stored as `bsdf->N`.*/
/* Local coordinate system. X is stored as `bsdf->N`. */
float3 Y, Z;

/* Incident direction in local coordinate system. */
Expand Down
2 changes: 1 addition & 1 deletion intern/cycles/kernel/integrator/shade_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce(
/* Update path state */
if (!(label & LABEL_TRANSPARENT)) {
INTEGRATOR_STATE_WRITE(state, path, mis_ray_pdf) = mis_pdf;
INTEGRATOR_STATE_WRITE(state, path, mis_origin_n) = sc->N;
INTEGRATOR_STATE_WRITE(state, path, mis_origin_n) = sd->N;
INTEGRATOR_STATE_WRITE(state, path, min_ray_pdf) = fminf(
unguided_bsdf_pdf, INTEGRATOR_STATE(state, path, min_ray_pdf));

Expand Down
3 changes: 0 additions & 3 deletions intern/ghost/intern/GHOST_WindowWin32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
}
#endif

/* Force an initial paint of the window. */
::UpdateWindow(m_hWnd);

/* Initialize WINTAB. */
if (system->getTabletAPI() != GHOST_kTabletWinPointer) {
loadWintab(GHOST_kWindowStateMinimized != state);
Expand Down
16 changes: 8 additions & 8 deletions intern/guardedalloc/intern/mallocn_lockfree_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ void *MEM_lockfree_dupallocN(const void *vmemh)
{
void *newp = NULL;
if (vmemh) {
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t prev_size = MEM_lockfree_allocN_len(vmemh);
if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
newp = MEM_lockfree_mallocN_aligned(
prev_size, (size_t)memh_aligned->alignment, "dupli_malloc");
}
Expand All @@ -135,14 +135,14 @@ void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str)
void *newp = NULL;

if (vmemh) {
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
size_t old_len = MEM_lockfree_allocN_len(vmemh);
const MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t old_len = MEM_lockfree_allocN_len(vmemh);

if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
newp = MEM_lockfree_mallocN(len, "realloc");
}
else {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "realloc");
}

Expand Down Expand Up @@ -171,14 +171,14 @@ void *MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str)
void *newp = NULL;

if (vmemh) {
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
size_t old_len = MEM_lockfree_allocN_len(vmemh);
const MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t old_len = MEM_lockfree_allocN_len(vmemh);

if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
newp = MEM_lockfree_mallocN(len, "recalloc");
}
else {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
const MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
newp = MEM_lockfree_mallocN_aligned(len, (size_t)memh_aligned->alignment, "recalloc");
}

Expand Down
2 changes: 1 addition & 1 deletion locale/languages
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
13:Simplified Chinese (简体中文):zh_HANS
#
0:In Progress:
11:Czech (Čeština):cs_CZ
5:German (Deutsch):de_DE
4:Italian (Italiano):it_IT
48:Georgian (ქართული):ka
Expand All @@ -39,6 +38,7 @@
21:Arabic (ﺔﻴﺑﺮﻌﻟﺍ):ar_EG
52:Belarusian (беларуску):be
22:Bulgarian (Български):bg_BG
11:Czech (Čeština):cs_CZ
53:Danish (Dansk):da
23:Greek (Ελληνικά):el_GR
35:Esperanto (Esperanto):eo
Expand Down
2 changes: 1 addition & 1 deletion locale/po/ab.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

msgid ""
msgstr ""
"Project-Id-Version: Blender 4.1.0 Release Candidate (b'64bfe491645f')\n"
"Project-Id-Version: Blender 4.2.0 Alpha (b'cb66cc3028dd')\n"
"Report-Msgid-Bugs-To: \n"
"\"POT-Creation-Date: 2019-02-25 20:41:30\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
Expand Down

0 comments on commit 57247ac

Please sign in to comment.