-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulkan: GPU Timeout on MacOS [tested multiple hardware] #67373
Comments
What rendering features do you have enabled in the project? Is there anything that stands out? |
This comment was marked as outdated.
This comment was marked as outdated.
I did more investigation into the issue with the xcode frame debugger, I have found two issues relevant with the same error: With the XCode frame debugger attached I could not reproduce the crash. However both those issue pertain and show exactly the same symptoms and log output. I believe changing the lighting configuration is a symptom of the problem but not the actual issue. The actual issue seems to be we cause some code to timeout with the compute shaders. |
I will writeup how to configure the frame debugger properly once I can get the "Show in source" button resolving to MoltenVK. |
I spent a few more hours on this, I debugged a lot, eventually I found that if shader validation in XCode is disabled then the crash will occur in xcode. This leads me to believe that the timeout IS inside the shader and some of the shader is triggering undefined behaviour and thus causing the GPU timeout. |
We added some prints today
|
RevoluPowered and I debugged this a little further today. We think that the issue is not reproducible on the mobile renderer which points to the root issue being in either the scene shader or in a compute shader. We analyzed typical draw calls in the xcode debugger and did not see anything totally out of the ordinary (although between Vulkan -> MoltenVK -> Metal a lot of debug info is lost so I am not confident in what we saw). My best guess is something is breaking in the cluster building resulting in pathological loops forming in the scene shader Next steps:
|
I noticed something potentially bad. We don't lock the version of the metal API we use as far as I can see. I posted this question in godot rendering chat, so putting here:
Our bug in this case could also be caused by a machine using an outdated version of metal. I don't believe it's the issue but I am going to try testing with a higher OS and XCode version. |
Thanks sir! We will be able to check today. |
from step one we get this crash (from our internal engine version) will test normal base godot tomorrow:
|
This appears to be related to the cluster builder:
|
|
TODO:
|
Patches to make to get MSAA to not crash and skeleton not to crash/hang@@ -1091,11 +1091,11 @@ void Skeleton3D::force_update_bone_children_transforms(int p_bone_idx) {
int child_bone_size = b.child_bones.size();
for (int i = 0; i < child_bone_size; i++) {
bones_to_process.push_back(b.child_bones[i]);
}
- emit_signal(SceneStringNames::get_singleton()->bone_pose_changed, current_bone_idx);
+ //emit_signal(SceneStringNames::get_singleton()->bone_pose_changed, current_bone_idx);
}
rest_dirty = false;
}
// Helper functions @@ -52,11 +52,11 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() {
cluster_render.cluster_render_shader.initialize(versions);
cluster_render.shader_version = cluster_render.cluster_render_shader.version_create();
cluster_render.shader = cluster_render.cluster_render_shader.version_get_shader(cluster_render.shader_version, 0);
cluster_render.shader_pipelines[ClusterRender::PIPELINE_NORMAL] = RD::get_singleton()->render_pipeline_create(cluster_render.shader, RD::get_singleton()->framebuffer_format_create_empty(), vertex_format, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState(), 0);
RD::PipelineMultisampleState ms;
- ms.sample_count = RD::TEXTURE_SAMPLES_4;
+ ms.sample_count = RD::TEXTURE_SAMPLES_1;
cluster_render.shader_pipelines[ClusterRender::PIPELINE_MSAA] = RD::get_singleton()->render_pipeline_create(cluster_render.shader, RD::get_singleton()->framebuffer_format_create_empty(), vertex_format, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), ms, RD::PipelineDepthStencilState(), RD::PipelineColorBlendState(), 0);
}
{
Vector<String> versions;
versions.push_back(""); @@ -5,11 +5,11 @@
#VERSION_DEFINES
#include "scene_forward_clustered_inc.glsl"
#define SHADER_IS_SRGB false
-
+#define MODE_UNSHADED
/* INPUT ATTRIBS */
layout(location = 0) in vec3 vertex_attrib;
//only for pure render depth when normal is not used
@@ -475,11 +475,11 @@ void main() {
#version 450
#VERSION_DEFINES
#define SHADER_IS_SRGB false
-
+#define MODE_UNSHADED
/* Specialization Constants (Toggles) */
layout(constant_id = 0) const bool sc_use_forward_gi = false;
layout(constant_id = 1) const bool sc_use_light_projector = false;
layout(constant_id = 2) const bool sc_use_light_soft_shadows = false; Required for ASAN / UBSAN to pass@@ -401,11 +401,11 @@ public:
_FORCE_INLINE_ uint32_t mesh_surface_get_lod(void *p_surface, float p_model_scale, float p_distance_threshold, float p_mesh_lod_threshold, uint32_t *r_index_count = nullptr) const {
Mesh::Surface *s = reinterpret_cast<Mesh::Surface *>(p_surface);
int32_t current_lod = -1;
if (r_index_count) {
- *r_index_count = s->index_count;
+ *(r_index_count) = s->index_count;
}
for (uint32_t i = 0; i < s->lod_count; i++) {
float screen_size = s->lods[i].edge_length * p_model_scale / p_distance_threshold;
if (screen_size > p_mesh_lod_threshold) {
break; |
Force disable lighting by adding #define MODE_UNSHADED to the top of the clustered rendering shader (vertex and fragment). We now know this prevents the crash New next steps:
godot/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl Lines 1886 to 1957 in 2b505b7
godot/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl Lines 934 to 1038 in 2b505b7
godot/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl Lines 1380 to 1447 in 2b505b7
|
L1832 of this file is sus as bad data could come from CPU and cause this to run infinitely and trigger timeout, will follow advised route. godot/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl |
Patch to correct datatypes to ensure using unsigned int (GLSL compiler complains they're int not uint): @@ -689,11 +687,11 @@ vec4 fog_process(vec3 vertex) {
return vec4(fog_color, fog_amount);
}
void cluster_get_item_range(uint p_offset, out uint item_min, out uint item_max, out uint item_from, out uint item_to) {
uint item_min_max = cluster_buffer.data[p_offset];
- item_min = item_min_max & 0xFFFF;
+ item_min = item_min_max & 0xFFFFu;
item_max = item_min_max >> 16;
item_from = item_min >> 5;
item_to = (item_max == 0) ? 0 : ((item_max - 1) >> 5) + 1; //side effect of how it is stored, as item_max 0 means no elements
}
@@ -956,13 +954,13 @@ void fragment_shader(in SceneData scene_data) {
uint merged_mask = mask;
#endif
while (merged_mask != 0) {
uint bit = findMSB(merged_mask);
- merged_mask &= ~(1 << bit);
+ merged_mask &= ~(1u << bit);
#ifdef USE_SUBGROUPS
- if (((1 << bit) & mask) == 0) { //do not process if not originally here
+ if (((1u << bit) & mask) == 0) { //do not process if not originally here
continue;
}
#endif
uint decal_index = 32 * i + bit;
@@ -1417,13 +1415,13 @@ void fragment_shader(in SceneData scene_data) {
uint merged_mask = mask;
#endif
while (merged_mask != 0) {
uint bit = findMSB(merged_mask);
- merged_mask &= ~(1 << bit);
+ merged_mask &= ~(1u << bit);
#ifdef USE_SUBGROUPS
- if (((1 << bit) & mask) == 0) { //do not process if not originally here
+ if (((1u << bit) & mask) == 0) { //do not process if not originally here
continue;
}
#endif
uint reflection_index = 32 * i + bit;
@@ -1773,13 +1771,13 @@ void fragment_shader(in SceneData scene_data) {
#endif
float shadow = 1.0;
#ifndef SHADOWS_DISABLED
if (i < 4) {
- shadow = float(shadow0 >> (i * 8) & 0xFF) / 255.0;
+ shadow = float(shadow0 >> (i * 8u) & 0xFFu) / 255.0;
} else {
- shadow = float(shadow1 >> ((i - 4) * 8) & 0xFF) / 255.0;
+ shadow = float(shadow1 >> ((i - 4u) * 8u) & 0xFFu) / 255.0;
}
shadow = shadow * directional_lights.data[i].shadow_opacity + 1.0 - directional_lights.data[i].shadow_opacity;
#endif
@@ -1837,13 +1835,13 @@ void fragment_shader(in SceneData scene_data) {
uint merged_mask = mask;
#endif
while (merged_mask != 0) {
uint bit = findMSB(merged_mask);
- merged_mask &= ~(1 << bit);
+ merged_mask &= ~(1u << bit);
#ifdef USE_SUBGROUPS
- if (((1 << bit) & mask) == 0) { //do not process if not originally here
+ if (((1u << bit) & mask) == 0) { //do not process if not originally here
continue;
}
#endif
uint light_index = 32 * i + bit;
@@ -1908,13 +1906,13 @@ void fragment_shader(in SceneData scene_data) {
uint merged_mask = mask;
#endif
while (merged_mask != 0) {
uint bit = findMSB(merged_mask);
- merged_mask &= ~(1 << bit);
+ merged_mask &= ~(1u << bit);
#ifdef USE_SUBGROUPS
- if (((1 << bit) & mask) == 0) { //do not process if not originally here
+ if (((1u << bit) & mask) == 0) { //do not process if not originally here
continue;
}
#endif
uint light_index = 32 * i + bit;
@@ -2063,11 +2061,11 @@ void fragment_shader(in SceneData scene_data) {
float sRed = floor((cRed / pow(2.0f, exps - B - N)) + 0.5f);
float sGreen = floor((cGreen / pow(2.0f, exps - B - N)) + 0.5f);
float sBlue = floor((cBlue / pow(2.0f, exps - B - N)) + 0.5f);
//store as 8985 to have 2 extra neighbour bits
- uint light_rgbe = ((uint(sRed) & 0x1FF) >> 1) | ((uint(sGreen) & 0x1FF) << 8) | (((uint(sBlue) & 0x1FF) >> 1) << 17) | ((uint(exps) & 0x1F) << 25);
+ uint light_rgbe = ((uint(sRed) & 0x1FFu) >> 1) | ((uint(sGreen) & 0x1FFu) << 8) | (((uint(sBlue) & 0x1FFu) >> 1) << 17) | ((uint(exps) & 0x1Fu) << 25);
imageStore(emission_grid, grid_pos, uvec4(light_rgbe));
imageStore(emission_aniso_grid, grid_pos, uvec4(light_aniso));
}
}
@@ -2097,12 +2095,12 @@ void fragment_shader(in SceneData scene_data) {
#ifdef MODE_RENDER_VOXEL_GI
if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_VOXEL_GI)) { // process voxel_gi_instances
uint index1 = instances.data[instance_index].gi_offset & 0xFFFF;
uint index2 = instances.data[instance_index].gi_offset >> 16;
- voxel_gi_buffer.x = index1 & 0xFF;
- voxel_gi_buffer.y = index2 & 0xFF;
+ voxel_gi_buffer.x = index1 & 0xFFu;
+ voxel_gi_buffer.y = index2 & 0xFFu;
} else {
voxel_gi_buffer.x = 0xFF;
voxel_gi_buffer.y = 0xFF;
}
#endif |
Patch I made to prevent the crash, this no longer crashes with these lines disabled @@ -1513,198 +1511,199 @@ void fragment_shader(in SceneData scene_data) {
continue; // Statically baked light and object uses lightmap, skip
}
float shadow = 1.0;
- if (directional_lights.data[i].shadow_opacity > 0.001) {
- float depth_z = -vertex.z;
- vec3 light_dir = directional_lights.data[i].direction;
- vec3 base_normal_bias = normalize(normal_interp) * (1.0 - max(0.0, dot(light_dir, -normalize(normal_interp))));
-
-#define BIAS_FUNC(m_var, m_idx) \
- m_var.xyz += light_dir * directional_lights.data[i].shadow_bias[m_idx]; \
- vec3 normal_bias = base_normal_bias * directional_lights.data[i].shadow_normal_bias[m_idx]; \
- normal_bias -= light_dir * dot(light_dir, normal_bias); \
- m_var.xyz += normal_bias;
-
- //version with soft shadows, more expensive
- if (sc_use_directional_soft_shadows && directional_lights.data[i].softshadow_angle > 0) {
- uint blend_count = 0;
- const uint blend_max = directional_lights.data[i].blend_splits ? 2 : 1;
-
- if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 0)
-
- vec4 pssm_coord = (directional_lights.data[i].shadow_matrix1 * v);
- pssm_coord /= pssm_coord.w;
-
- float range_pos = dot(directional_lights.data[i].direction, v.xyz);
- float range_begin = directional_lights.data[i].shadow_range_begin.x;
- float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
- vec2 tex_scale = directional_lights.data[i].uv_scale1 * test_radius;
- shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
- blend_count++;
- }
-
- if (blend_count < blend_max && depth_z < directional_lights.data[i].shadow_split_offsets.y) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 1)
-
- vec4 pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
- pssm_coord /= pssm_coord.w;
-
- float range_pos = dot(directional_lights.data[i].direction, v.xyz);
- float range_begin = directional_lights.data[i].shadow_range_begin.y;
- float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
- vec2 tex_scale = directional_lights.data[i].uv_scale2 * test_radius;
- float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
-
- if (blend_count == 0) {
- shadow = s;
- } else {
- //blend
- float blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z);
- shadow = mix(shadow, s, blend);
- }
-
- blend_count++;
- }
-
- if (blend_count < blend_max && depth_z < directional_lights.data[i].shadow_split_offsets.z) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 2)
-
- vec4 pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
- pssm_coord /= pssm_coord.w;
-
- float range_pos = dot(directional_lights.data[i].direction, v.xyz);
- float range_begin = directional_lights.data[i].shadow_range_begin.z;
- float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
- vec2 tex_scale = directional_lights.data[i].uv_scale3 * test_radius;
- float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
-
- if (blend_count == 0) {
- shadow = s;
- } else {
- //blend
- float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z);
- shadow = mix(shadow, s, blend);
- }
-
- blend_count++;
- }
-
- if (blend_count < blend_max) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 3)
-
- vec4 pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
- pssm_coord /= pssm_coord.w;
-
- float range_pos = dot(directional_lights.data[i].direction, v.xyz);
- float range_begin = directional_lights.data[i].shadow_range_begin.w;
- float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
- vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius;
- float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
-
- if (blend_count == 0) {
- shadow = s;
- } else {
- //blend
- float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z);
- shadow = mix(shadow, s, blend);
- }
- }
-
- } else { //no soft shadows
-
- vec4 pssm_coord;
- float blur_factor;
-
- if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 0)
-
- pssm_coord = (directional_lights.data[i].shadow_matrix1 * v);
- blur_factor = 1.0;
- } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 1)
-
- pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.y;
- } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 2)
-
- pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.z;
- } else {
- vec4 v = vec4(vertex, 1.0);
-
- BIAS_FUNC(v, 3)
-
- pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.w;
- }
-
- pssm_coord /= pssm_coord.w;
-
- shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * blur_factor, pssm_coord);
-
- if (directional_lights.data[i].blend_splits) {
- float pssm_blend;
- float blur_factor2;
-
- if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
- vec4 v = vec4(vertex, 1.0);
- BIAS_FUNC(v, 1)
- pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
- pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.y;
- } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
- vec4 v = vec4(vertex, 1.0);
- BIAS_FUNC(v, 2)
- pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
- pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.z;
- } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
- vec4 v = vec4(vertex, 1.0);
- BIAS_FUNC(v, 3)
- pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
- pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z);
- // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
- blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.w;
- } else {
- pssm_blend = 0.0; //if no blend, same coord will be used (divide by z will result in same value, and already cached)
- blur_factor2 = 1.0;
- }
-
- pssm_coord /= pssm_coord.w;
-
- float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * blur_factor2, pssm_coord);
- shadow = mix(shadow, shadow2, pssm_blend);
- }
- }
-
- shadow = mix(shadow, 1.0, smoothstep(directional_lights.data[i].fade_from, directional_lights.data[i].fade_to, vertex.z)); //done with negative values for performance
-
-#undef BIAS_FUNC
- } // shadows
+// if (directional_lights.data[i].shadow_opacity > 0.001) {
+// float depth_z = -vertex.z;
+// vec3 light_dir = directional_lights.data[i].direction;
+// vec3 base_normal_bias = normalize(normal_interp) * (1.0 - max(0.0, dot(light_dir, -normalize(normal_interp))));
+//
+////#define BIAS_FUNC(m_var, m_idx) \
+//// if(m_idx < directional_lights.data.length() ) { \
+//// m_var.xyz += light_dir * directional_lights.data[i].shadow_bias[m_idx]; \
+//// vec3 normal_bias = base_normal_bias * directional_lights.data[i].shadow_normal_bias[m_idx]; \
+//// normal_bias -= light_dir * dot(light_dir, normal_bias); \
+//// m_var.xyz += normal_bias; }
+//
+// //version with soft shadows, more expensive
+// if (sc_use_directional_soft_shadows && directional_lights.data[i].softshadow_angle > 0) {
+// uint blend_count = 0;
+// const uint blend_max = directional_lights.data[i].blend_splits ? 2 : 1;
+//
+// if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// vec4 pssm_coord = (directional_lights.data[i].shadow_matrix1 * v);
+// pssm_coord /= pssm_coord.w;
+//
+// float range_pos = dot(directional_lights.data[i].direction, v.xyz);
+// float range_begin = directional_lights.data[i].shadow_range_begin.x;
+// float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
+// vec2 tex_scale = directional_lights.data[i].uv_scale1 * test_radius;
+// shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
+// blend_count++;
+// }
+//
+// if (blend_count < blend_max && depth_z < directional_lights.data[i].shadow_split_offsets.y) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// vec4 pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
+// pssm_coord /= pssm_coord.w;
+//
+// float range_pos = dot(directional_lights.data[i].direction, v.xyz);
+// float range_begin = directional_lights.data[i].shadow_range_begin.y;
+// float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
+// vec2 tex_scale = directional_lights.data[i].uv_scale2 * test_radius;
+// float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
+//
+// if (blend_count == 0) {
+// shadow = s;
+// } else {
+// //blend
+// float blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z);
+// shadow = mix(shadow, s, blend);
+// }
+//
+// blend_count++;
+// }
+//
+// if (blend_count < blend_max && depth_z < directional_lights.data[i].shadow_split_offsets.z) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// vec4 pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
+// pssm_coord /= pssm_coord.w;
+//
+// float range_pos = dot(directional_lights.data[i].direction, v.xyz);
+// float range_begin = directional_lights.data[i].shadow_range_begin.z;
+// float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
+// vec2 tex_scale = directional_lights.data[i].uv_scale3 * test_radius;
+// float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
+//
+// if (blend_count == 0) {
+// shadow = s;
+// } else {
+// //blend
+// float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z);
+// shadow = mix(shadow, s, blend);
+// }
+//
+// blend_count++;
+// }
+//
+// if (blend_count < blend_max) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// vec4 pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
+// pssm_coord /= pssm_coord.w;
+//
+// float range_pos = dot(directional_lights.data[i].direction, v.xyz);
+// float range_begin = directional_lights.data[i].shadow_range_begin.w;
+// float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
+// vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius;
+// float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
+//
+// if (blend_count == 0) {
+// shadow = s;
+// } else {
+// //blend
+// float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z);
+// shadow = mix(shadow, s, blend);
+// }
+// }
+//
+// } else { //no soft shadows
+//
+// vec4 pssm_coord;
+// float blur_factor;
+//
+// if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// pssm_coord = (directional_lights.data[i].shadow_matrix1 * v);
+// blur_factor = 1.0;
+// } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.y;
+// } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.z;
+// } else {
+// vec4 v = vec4(vertex, 1.0);
+//
+//// BIAS_FUNC(v, i)
+//
+// pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.w;
+// }
+//
+// pssm_coord /= pssm_coord.w;
+//
+// shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * blur_factor, pssm_coord);
+//
+// if (directional_lights.data[i].blend_splits) {
+// float pssm_blend;
+// float blur_factor2;
+//
+// if (depth_z < directional_lights.data[i].shadow_split_offsets.x) {
+// vec4 v = vec4(vertex, 1.0);
+//// BIAS_FUNC(v, i)
+// pssm_coord = (directional_lights.data[i].shadow_matrix2 * v);
+// pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.y;
+// } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
+// vec4 v = vec4(vertex, 1.0);
+//// BIAS_FUNC(v, i)
+// pssm_coord = (directional_lights.data[i].shadow_matrix3 * v);
+// pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.z;
+// } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
+// vec4 v = vec4(vertex, 1.0);
+//// BIAS_FUNC(v, i)
+// pssm_coord = (directional_lights.data[i].shadow_matrix4 * v);
+// pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z);
+// // Adjust shadow blur with reference to the first split to reduce discrepancy between shadow splits.
+// blur_factor2 = directional_lights.data[i].shadow_split_offsets.x / directional_lights.data[i].shadow_split_offsets.w;
+// } else {
+// pssm_blend = 0.0; //if no blend, same coord will be used (divide by z will result in same value, and already cached)
+// blur_factor2 = 1.0;
+// }
+//
+// pssm_coord /= pssm_coord.w;
+//
+// float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * blur_factor2, pssm_coord);
+// shadow = mix(shadow, shadow2, pssm_blend);
+// }
+// }
+//
+// shadow = mix(shadow, 1.0, smoothstep(directional_lights.data[i].fade_from, directional_lights.data[i].fade_to, vertex.z)); //done with negative values for performance
+//
+//#undef BIAS_FUNC
+// } // shadows |
Patch to fix the issue is incoming, we found it was the subgroup support in moltenvk |
This comment was marked as off-topic.
This comment was marked as off-topic.
Fixed by #67915 |
Godot version
4.0.dev (we cut from 880a017)
@Zylann's terrain module on top
System information
multiple hardware tested
MacOS 12.4 intel i9
MacOS 12.2 intel i7
Issue description
Game crashes when a complex enough scene is provided and loaded.
No UBSAN/ASAN errors anymore either. (spent entire day literally fixing them all - patch incoming soon ™️)
Tried
MVK_ALLOW_METAL_EVENTS=1
as per some searches but gave me an additional 2 seconds after the scene had loaded before the GPU timeout.We're having this on ARM processors too. I will try a bisect tomorrow, but any help is appreciated.
This is for the Mirror.
Symptoms entire app hangs, no display output anymore, infinite swap issues or crash VK_DISPLAY_LOST etc.
Steps to reproduce
Honestly dug around a lot and don't know how to reproduce outside of our codebase due to complexity.
Minimal reproduction project
Unable to provide as unsure how to reproduce outside our game.
The text was updated successfully, but these errors were encountered: