| 2256 | return !mip_disjoint && !arr_disjoint; |
| 2257 | } |
| 2258 | auto ImageMipArraySlice::intersect(ImageMipArraySlice const & slice) const -> ImageMipArraySlice |
| 2259 | { |
| 2260 | u32 const a_mip_p0 = this->base_mip_level; |
| 2261 | u32 const a_mip_p1 = this->base_mip_level + this->level_count - 1; |
| 2262 | u32 const b_mip_p0 = slice.base_mip_level; |
| 2263 | u32 const b_mip_p1 = slice.base_mip_level + slice.level_count - 1; |
| 2264 | u32 const max_mip_p0 = std::max(a_mip_p0, b_mip_p0); |
| 2265 | u32 const min_mip_p1 = std::min(a_mip_p1, b_mip_p1); |
| 2266 | |
| 2267 | u32 const a_arr_p0 = this->base_array_layer; |
| 2268 | u32 const a_arr_p1 = this->base_array_layer + this->layer_count - 1; |
| 2269 | u32 const b_arr_p0 = slice.base_array_layer; |
| 2270 | u32 const b_arr_p1 = slice.base_array_layer + slice.layer_count - 1; |
| 2271 | u32 const max_arr_p0 = std::max(a_arr_p0, b_arr_p0); |
| 2272 | u32 const min_arr_p1 = std::min(a_arr_p1, b_arr_p1); |
| 2273 | |
| 2274 | // NOTE(grundlett): This multiplication at the end is to cancel out |
| 2275 | // the potential underflow of unsigned integers. Since the p1 could |
| 2276 | // could technically be less than the p0, this means that after doing |
| 2277 | // p1 + 1 - p0, you should get a "negative" number. |
| 2278 | u32 const mip_n = (min_mip_p1 + 1 - max_mip_p0) * static_cast<u32>(max_mip_p0 <= min_mip_p1); |
| 2279 | u32 const arr_n = (min_arr_p1 + 1 - max_arr_p0) * static_cast<u32>(max_arr_p0 <= min_arr_p1); |
| 2280 | |
| 2281 | return ImageMipArraySlice{ |
| 2282 | .base_mip_level = max_mip_p0, |
| 2283 | .level_count = mip_n, |
| 2284 | .base_array_layer = max_arr_p0, |
| 2285 | .layer_count = arr_n, |
| 2286 | }; |
| 2287 | } |
| 2288 | auto ImageMipArraySlice::subtract(ImageMipArraySlice const & slice) const -> std::tuple<std::array<ImageMipArraySlice, 4>, usize> |
| 2289 | { |
| 2290 | u32 const a_mip_p0 = this->base_mip_level; |
nothing calls this directly
no outgoing calls
no test coverage detected