| … | … | @@ -332,14 +332,23 @@ void main() { |
| 332 | 332 | // live state cost register pressure (and so occupancy) on every hit shader, |
| 333 | 333 | // including the ones that never touch CUSTOM. fetch_custom early-outs on |
| 334 | 334 | // surfaces without the array, so this is cheap when unused. |
| 335 | // Skip the whole block -- including re-deriving the triangle indices -- when |
| 336 | // the surface carries no CUSTOM arrays at all, which is the common case. |
| 335 | 337 | GeometryData rt_cgeom = geometries[h.geometry_idx]; |
| 336 | | uint rt_ci0, rt_ci1, rt_ci2; |
| 337 | | get_triangle_indices(rt_cgeom, rt_ci0, rt_ci1, rt_ci2); |
| 338 | | vec3 rt_cbary = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y); |
| 339 | | vec4 rt_custom0 = fetch_custom(rt_cgeom, 0u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 340 | | vec4 rt_custom1 = fetch_custom(rt_cgeom, 1u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 341 | | vec4 rt_custom2 = fetch_custom(rt_cgeom, 2u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 342 | | vec4 rt_custom3 = fetch_custom(rt_cgeom, 3u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 338 | vec4 rt_custom0 = vec4(0.0); |
| 339 | vec4 rt_custom1 = vec4(0.0); |
| 340 | vec4 rt_custom2 = vec4(0.0); |
| 341 | vec4 rt_custom3 = vec4(0.0); |
| 342 | if (rt_cgeom.custom_packed[0] != OFFSET_NONE || rt_cgeom.custom_packed[1] != OFFSET_NONE || |
| 343 | rt_cgeom.custom_packed[2] != OFFSET_NONE || rt_cgeom.custom_packed[3] != OFFSET_NONE) { |
| 344 | uint rt_ci0, rt_ci1, rt_ci2; |
| 345 | get_triangle_indices(rt_cgeom, rt_ci0, rt_ci1, rt_ci2); |
| 346 | vec3 rt_cbary = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y); |
| 347 | rt_custom0 = fetch_custom(rt_cgeom, 0u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 348 | rt_custom1 = fetch_custom(rt_cgeom, 1u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 349 | rt_custom2 = fetch_custom(rt_cgeom, 2u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 350 | rt_custom3 = fetch_custom(rt_cgeom, 3u, rt_ci0, rt_ci1, rt_ci2, rt_cbary); |
| 351 | } |
| 343 | 352 | vec3 rt_normal = h.geometry_normal; |
| 344 | 353 | vec3 rt_tangent = h.tangent; |
| 345 | 354 | vec3 rt_bitangent = h.bitangent; |