Bug 1632376 - just scale pixels to integer 255 before rounding. r=jimb

Differential Revision: https://phabricator.services.mozilla.com/D72095
This commit is contained in:
Lee Salzman 2020-04-25 17:20:01 +00:00
Родитель d36a6bffc4
Коммит 086657e157
2 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -1005,7 +1005,7 @@ void BlendFunc(GLenum srgb, GLenum drgb, GLenum sa, GLenum da) {
}
void BlendColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
I32 c = roundfast((Float){b, g, r, a}, 255.49f);
I32 c = round_pixel((Float){b, g, r, a});
ctx->blendcolor = CONVERT(c, U16).xyzwxyzw;
}
@ -1032,7 +1032,7 @@ void SetScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
}
void ClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
I32 c = roundfast((Float){b, g, r, a}, 255.49f);
I32 c = round_pixel((Float){b, g, r, a});
ctx->clearcolor = bit_cast<uint32_t>(CONVERT(c, U8));
}
@ -2329,7 +2329,7 @@ static ALWAYS_INLINE void discard_depth(uint16_t z, uint16_t* zbuf,
}
static inline WideRGBA8 pack_pixels_RGBA8(const vec4& v) {
ivec4 i = roundfast(v, 255.49f);
ivec4 i = round_pixel(v);
HalfRGBA8 xz = packRGBA8(i.z, i.x);
HalfRGBA8 yw = packRGBA8(i.y, i.w);
HalfRGBA8 xy = zipLow(xz, yw);
@ -2340,7 +2340,7 @@ static inline WideRGBA8 pack_pixels_RGBA8(const vec4& v) {
}
static inline WideRGBA8 pack_pixels_RGBA8(const vec4_scalar& v) {
I32 i = roundfast((Float){v.z, v.y, v.x, v.w}, 255.49f);
I32 i = round_pixel((Float){v.z, v.y, v.x, v.w});
HalfRGBA8 c = packRGBA8(i, i);
return combine(c, c);
}
@ -2476,7 +2476,7 @@ static inline void commit_output(uint32_t* buf, int span) {
}
static inline WideR8 pack_pixels_R8(Float c) {
return packR8(roundfast(c, 255.49f));
return packR8(round_pixel(c));
}
static inline WideR8 pack_pixels_R8() {

Просмотреть файл

@ -566,6 +566,8 @@ SI I32 roundfast(Float v, Float scale) {
#endif
}
template <typename T> SI auto round_pixel(T v) { return roundfast(v, 255.0f); }
#define round __glsl_round
float round(float a) { return roundf(a); }