Fix #136239: SubDiv: Read out of bounds

GPU subdivision shaders can read out of bound when evaluating
the last face. This seems to be always been the case, but Metal + Vulkan
has validation to detect these mis-usages.

Binary search was initialized with out of bound values so the last
face could select out of bound index due to rounding.

Pull Request: https://projects.blender.org/blender/blender/pulls/136242
This commit is contained in:
Jeroen Bakker
2025-03-20 12:17:58 +01:00
parent 7aced80eec
commit 177bbf12df

View File

@@ -100,7 +100,7 @@ void add_newell_cross_v3_v3v3(inout vec3 n, vec3 v_prev, vec3 v_curr)
uint coarse_face_index_from_subdiv_quad_index(uint subdiv_quad_index, uint coarse_face_count)
{
uint first = 0;
uint last = coarse_face_count;
uint last = coarse_face_count - 1;
while (first != last) {
uint middle = (first + last) / 2;