Fix 107322: MacOS/ATI Crash When Starting Eevee #109358

Merged
Jeroen Bakker merged 2 commits from Jeroen-Bakker/blender:macos-raytrace-infinitive-loop into blender-v3.6-release 2023-06-26 14:12:51 +02:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 5b6867816d - Show all commits

View File

@ -118,7 +118,7 @@ float search_horizon(vec3 vI,
}
float prev_time, time = 0.0;
for (float iter = 0.0; time < ssray.max_time && iter < sample_count; iter++) {
Jeroen-Bakker marked this conversation as resolved Outdated

My apologies @Jeroen-Bakker , after testing the patch locally, one omission was that we also need to tag the function with no inline, though this should only be done for AMD platforms on Metal. Without this, the crash can still occur for certain material variants it appears.

I hope this is okay to include.

raytrace_lib.glsl

#ifdef METAL_AMD_RAYTRACE_WORKAROUND
__attribute__((noinline))
#endif
bool raytrace(Ray ray,
              RayTraceParameters params,
              const bool discard_backface,
              const bool allow_self_intersection,
              out vec3 hit_position)
{

and

#if (defined(GPU_METAL) && defined(GPU_ATI))
__attribute__((noinline))
#endif
float search_horizon(vec3 vI,
                     vec3 vP,
                     float noise,
                     ScreenSpaceRay ssray,
                     sampler2D depth_tx,
                     const float inverted,
                     float radius,
                     const float sample_count)
{
My apologies @Jeroen-Bakker , after testing the patch locally, one omission was that we also need to tag the function with no inline, though this should only be done for AMD platforms on Metal. Without this, the crash can still occur for certain material variants it appears. I hope this is okay to include. raytrace_lib.glsl ``` #ifdef METAL_AMD_RAYTRACE_WORKAROUND __attribute__((noinline)) #endif bool raytrace(Ray ray, RayTraceParameters params, const bool discard_backface, const bool allow_self_intersection, out vec3 hit_position) { ``` and ``` #if (defined(GPU_METAL) && defined(GPU_ATI)) __attribute__((noinline)) #endif float search_horizon(vec3 vI, vec3 vP, float noise, ScreenSpaceRay ssray, sampler2D depth_tx, const float inverted, float radius, const float sample_count) { ```
for (int iter = 0; time < ssray.max_time && iter < sample_count; iter++) {
Jeroen-Bakker marked this conversation as resolved Outdated

sample_count needs to be declared as int. Better do the conversion out of the loop const int i_sample_count = int(sample_count)

`sample_count` needs to be declared as int. Better do the conversion out of the loop `const int i_sample_count = int(sample_count)`
prev_time = time;
/* Gives us good precision at center and ensure we cross at least one pixel per iteration. */
time = 1.0 + iter + sqr((iter + noise) / sample_count) * ssray.max_time;
Jeroen-Bakker marked this conversation as resolved Outdated

iter needs to be explicitly converted to float here.

`iter` needs to be explicitly converted to float here.

View File

@ -137,8 +137,8 @@ bool raytrace(Ray ray,
#ifdef METAL_AMD_RAYTRACE_WORKAROUND
bool hit_failsafe = true;
#endif
const float max_steps = 255.0;
for (float iter = 1.0; !hit && (time < ssray.max_time) && (iter < max_steps); iter++) {
const int max_steps = 255;
for (int iter = 1; !hit && (time < ssray.max_time) && (iter < max_steps); iter++) {
float stride = 1.0 + iter * params.trace_quality;
Jeroen-Bakker marked this conversation as resolved Outdated

iter needs to be explicitly converted to float here.

`iter` needs to be explicitly converted to float here.
float lod = log2(stride) * lod_fac;
@ -210,8 +210,8 @@ bool raytrace_planar(Ray ray, RayTraceParameters params, int planar_ref_id, out
/* On very sharp reflections, the ray can be perfectly aligned with the view direction
* making the tracing useless. Bypass tracing in this case. */
bool hit = false;
const float max_steps = 255.0;
for (float iter = 1.0; !hit && (time < ssray.max_time) && (iter < max_steps); iter++) {
const int max_steps = 255;
for (int iter = 1; !hit && (time < ssray.max_time) && (iter < max_steps); iter++) {
float stride = 1.0 + iter * params.trace_quality;
Jeroen-Bakker marked this conversation as resolved Outdated

iter needs to be explicitly converted to float here.

`iter` needs to be explicitly converted to float here.
prev_time = time;