Bug 1915813 - Fix a crash with Microsoft TTD. r=gfx-reviewers,nical,jrmuizel

Microsoft TTD has a CPU emulation bug that makes Firefox crash when ran
under TTD. This patch mitigates the issue.

Differential Revision: https://phabricator.services.mozilla.com/D220829
This commit is contained in:
Yannis Juglaret 2024-09-09 09:00:48 +00:00
parent cf33b07bdd
commit eee6a74f78
2 changed files with 5 additions and 5 deletions

View File

@ -116,7 +116,7 @@ unsafe extern "C" fn qcms_transform_data_template_lut_avx<F: Format>(
}
/* crunch, crunch, crunch */
vec_r = _mm256_add_ps(vec_r, _mm256_add_ps(vec_g, vec_b));
vec_r = _mm256_max_ps(min, vec_r);
vec_r = _mm256_max_ps(vec_r, min);
vec_r = _mm256_min_ps(max, vec_r);
result = _mm256_mul_ps(vec_r, scale);
/* store calc'd output tables indices */
@ -158,7 +158,7 @@ unsafe extern "C" fn qcms_transform_data_template_lut_avx<F: Format>(
*dest.add(F::kAIndex + components as usize) = alpha2
}
vec_r = _mm256_add_ps(vec_r, _mm256_add_ps(vec_g, vec_b));
vec_r = _mm256_max_ps(min, vec_r);
vec_r = _mm256_max_ps(vec_r, min);
vec_r = _mm256_min_ps(max, vec_r);
result = _mm256_mul_ps(vec_r, scale);
_mm256_store_si256(output as *mut __m256i, _mm256_cvtps_epi32(result));
@ -187,7 +187,7 @@ unsafe extern "C" fn qcms_transform_data_template_lut_avx<F: Format>(
*dest.add(F::kAIndex) = *src.add(F::kAIndex)
}
vec_r0 = _mm_add_ps(vec_r0, _mm_add_ps(vec_g0, vec_b0));
vec_r0 = _mm_max_ps(_mm256_castps256_ps128(min), vec_r0);
vec_r0 = _mm_max_ps(vec_r0, _mm256_castps256_ps128(min));
vec_r0 = _mm_min_ps(_mm256_castps256_ps128(max), vec_r0);
vec_r0 = _mm_mul_ps(vec_r0, _mm256_castps256_ps128(scale));
_mm_store_si128(output as *mut __m128i, _mm_cvtps_epi32(vec_r0));

View File

@ -93,7 +93,7 @@ unsafe extern "C" fn qcms_transform_data_template_lut_sse2<F: Format>(
}
/* crunch, crunch, crunch */
vec_r = _mm_add_ps(vec_r, _mm_add_ps(vec_g, vec_b));
vec_r = _mm_max_ps(min, vec_r);
vec_r = _mm_max_ps(vec_r, min);
vec_r = _mm_min_ps(max, vec_r);
result = _mm_mul_ps(vec_r, scale);
/* store calc'd output tables indices */
@ -121,7 +121,7 @@ unsafe extern "C" fn qcms_transform_data_template_lut_sse2<F: Format>(
*dest.add(F::kAIndex) = alpha
}
vec_r = _mm_add_ps(vec_r, _mm_add_ps(vec_g, vec_b));
vec_r = _mm_max_ps(min, vec_r);
vec_r = _mm_max_ps(vec_r, min);
vec_r = _mm_min_ps(max, vec_r);
result = _mm_mul_ps(vec_r, scale);
_mm_store_si128(output as *mut __m128i, _mm_cvtps_epi32(result));