[GPU] Another attempt to fix memleaks caused by depth_bias_slope_scaled

This commit is contained in:
Gliniak 2024-03-16 19:31:00 +01:00
parent 3d4bdc9023
commit 8c44649f01
2 changed files with 15 additions and 0 deletions

View File

@ -597,6 +597,19 @@ inline T sat_sub(T a, T b) {
}
return T(result);
}
template <typename T>
inline T roundToNearestOrderOfMagnitude(T value) {
if (!value) {
return value;
}
const double order = std::pow(10, std::floor(std::log10(std::fabs(value))));
const double rounded = std::round(value / order) * order;
return static_cast<T>(rounded);
}
namespace divisors {
union IDivExtraInfo {
uint32_t value_;

View File

@ -95,6 +95,8 @@ void GetPreferredFacePolygonOffset(const RegisterFile& regs,
!pa_su_sc_mode_cntl.cull_front) {
scale = regs[XE_GPU_REG_PA_SU_POLY_OFFSET_FRONT_SCALE].f32;
offset = regs[XE_GPU_REG_PA_SU_POLY_OFFSET_FRONT_OFFSET].f32;
scale = roundToNearestOrderOfMagnitude(scale);
}
if (pa_su_sc_mode_cntl.poly_offset_back_enable &&
!pa_su_sc_mode_cntl.cull_back && !scale && !offset) {