Replace IROUND_POS with _mesa_roundevenf
Which has the same behavior as long as you don't change the FPU rounding mode. Other code in mesa makes the same assumption so it should be safe to make that assumption more generally. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
This commit is contained in:
parent
9d9a2819ee
commit
64014c8302
|
@ -84,7 +84,6 @@
|
|||
#include "tnl/t_pipeline.h"
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "drivers/common/meta.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
/**
|
||||
* Global X driver lock
|
||||
|
@ -117,7 +116,7 @@ static int host_byte_order( void )
|
|||
*/
|
||||
static int check_for_xshm( XMesaDisplay *display )
|
||||
{
|
||||
#if defined(USE_XSHM)
|
||||
#if defined(USE_XSHM)
|
||||
int ignore;
|
||||
|
||||
if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) {
|
||||
|
@ -151,7 +150,7 @@ gamma_adjust( GLfloat gamma, GLint value, GLint max )
|
|||
}
|
||||
else {
|
||||
double x = (double) value / (double) max;
|
||||
return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
|
||||
return lroundf((GLfloat) max * pow(x, 1.0F/gamma));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +327,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
|
|||
b->backxrb->Parent = b;
|
||||
/* determine back buffer implementation */
|
||||
b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
|
||||
|
||||
|
||||
_mesa_attach_and_own_rb(&b->mesa_buffer, BUFFER_BACK_LEFT,
|
||||
&b->backxrb->Base.Base);
|
||||
}
|
||||
|
@ -686,12 +685,12 @@ xmesa_color_to_pixel(struct gl_context *ctx,
|
|||
|
||||
/**
|
||||
* Convert an X visual type to a GLX visual type.
|
||||
*
|
||||
*
|
||||
* \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
|
||||
* to be converted.
|
||||
* \return If \c visualType is a valid X visual type, a GLX visual type will
|
||||
* be returned. Otherwise \c GLX_NONE will be returned.
|
||||
*
|
||||
*
|
||||
* \note
|
||||
* This code was lifted directly from lib/GL/glx/glcontextmodes.c in the
|
||||
* DRI CVS tree.
|
||||
|
@ -1333,7 +1332,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
|
|||
if (b->db_mode) {
|
||||
if (b->backxrb->ximage) {
|
||||
/* Copy Ximage (back buf) from client memory to server window */
|
||||
#if defined(USE_XSHM)
|
||||
#if defined(USE_XSHM)
|
||||
if (b->shm) {
|
||||
/*mtx_lock(&_xmesa_lock);*/
|
||||
XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
|
||||
|
@ -1387,14 +1386,14 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
|
|||
|
||||
if (!b->backxrb) {
|
||||
/* single buffered */
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (b->db_mode) {
|
||||
int yTop = b->mesa_buffer.Height - y - height;
|
||||
if (b->backxrb->ximage) {
|
||||
/* Copy Ximage from host's memory to server's window */
|
||||
#if defined(USE_XSHM)
|
||||
#if defined(USE_XSHM)
|
||||
if (b->shm) {
|
||||
/* XXX assuming width and height aren't too large! */
|
||||
XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "c99_math.h"
|
||||
#include "main/glheader.h"
|
||||
#include "util/imports.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/teximage.h"
|
||||
|
@ -181,7 +180,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
|
|||
return 0;
|
||||
else if (z > CHAN_MAX)
|
||||
return CHAN_MAX;
|
||||
return (GLchan) IROUND_POS(z);
|
||||
return (GLchan) lroundf(z);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -327,7 +326,7 @@ compute_coveragef(const struct LineInfo *info,
|
|||
|
||||
typedef void (*plot_func)(struct gl_context *ctx, struct LineInfo *line,
|
||||
int ix, int iy);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "main/glheader.h"
|
||||
#include "main/context.h"
|
||||
#include "main/macros.h"
|
||||
#include "util/imports.h"
|
||||
#include "main/state.h"
|
||||
#include "s_aatriangle.h"
|
||||
#include "s_context.h"
|
||||
|
@ -124,7 +123,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
|
|||
return 0;
|
||||
else if (z > CHAN_MAX)
|
||||
return CHAN_MAX;
|
||||
return (GLchan) IROUND_POS(z);
|
||||
return (GLchan) lroundf(z);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -120,16 +120,6 @@ static inline int64_t IROUND64(float f)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert positive float to int by rounding to nearest integer.
|
||||
*/
|
||||
static inline int IROUND_POS(float f)
|
||||
{
|
||||
assert(f >= 0.0F);
|
||||
return (int) (f + 0.5F);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Functions
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue