summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Romain TISSERAND <romain.tisserand@gmail.com>2020-11-18 09:16:55 +0100
committer GitHub <noreply@github.com>2020-11-18 19:16:55 +1100
commit310c5d02ce7c55b7ac6b3b2f5d52537a68a83266 (patch)
tree9f9b0ecce2195d996e895b17b23b32e3ec03a081
parent7b657d9b61f204d27db43d9f9c41fc58a6f6a683 (diff)
Move some rendering code to constexpr (#7491)
-rw-r--r--src/emu/drawgfx.cpp2
-rw-r--r--src/emu/rendersw.hxx40
-rw-r--r--src/emu/rendutil.h6
3 files changed, 24 insertions, 24 deletions
diff --git a/src/emu/drawgfx.cpp b/src/emu/drawgfx.cpp
index b0c85c26bc6..8a63d71467c 100644
--- a/src/emu/drawgfx.cpp
+++ b/src/emu/drawgfx.cpp
@@ -21,7 +21,7 @@
offset
-------------------------------------------------*/
-static inline int readbit(const u8 *src, unsigned int bitnum)
+constexpr int readbit(const u8 *src, unsigned int bitnum)
{
return src[bitnum / 8] & (0x80 >> (bitnum % 8));
}
diff --git a/src/emu/rendersw.hxx b/src/emu/rendersw.hxx
index 37cdbc5b736..db6b41f9bba 100644
--- a/src/emu/rendersw.hxx
+++ b/src/emu/rendersw.hxx
@@ -29,27 +29,27 @@ private:
};
// internal helpers
- static inline bool is_opaque(float alpha) { return (alpha >= (_NoDestRead ? 0.5f : 1.0f)); }
- static inline bool is_transparent(float alpha) { return (alpha < (_NoDestRead ? 0.5f : 0.0001f)); }
+ static constexpr bool is_opaque(float alpha) { return (alpha >= (_NoDestRead ? 0.5f : 1.0f)); }
+ static constexpr bool is_transparent(float alpha) { return (alpha < (_NoDestRead ? 0.5f : 0.0001f)); }
static inline rgb_t apply_intensity(int intensity, rgb_t color) { return color.scale8(intensity); }
static inline float round_nearest(float f) { return floor(f + 0.5f); }
// destination pixels are written based on the values of the template parameters
- static inline _PixelType dest_assemble_rgb(u32 r, u32 g, u32 b) { return (r << _DstShiftR) | (g << _DstShiftG) | (b << _DstShiftB); }
- static inline _PixelType dest_rgb_to_pixel(u32 r, u32 g, u32 b) { return dest_assemble_rgb(r >> _SrcShiftR, g >> _SrcShiftG, b >> _SrcShiftB); }
+ static constexpr _PixelType dest_assemble_rgb(u32 r, u32 g, u32 b) { return (r << _DstShiftR) | (g << _DstShiftG) | (b << _DstShiftB); }
+ static constexpr _PixelType dest_rgb_to_pixel(u32 r, u32 g, u32 b) { return dest_assemble_rgb(r >> _SrcShiftR, g >> _SrcShiftG, b >> _SrcShiftB); }
// source 32-bit pixels are in MAME standardized format
- static inline u32 source32_r(u32 pixel) { return (pixel >> (16 + _SrcShiftR)) & (0xff >> _SrcShiftR); }
- static inline u32 source32_g(u32 pixel) { return (pixel >> ( 8 + _SrcShiftG)) & (0xff >> _SrcShiftG); }
- static inline u32 source32_b(u32 pixel) { return (pixel >> ( 0 + _SrcShiftB)) & (0xff >> _SrcShiftB); }
+ static constexpr u32 source32_r(u32 pixel) { return (pixel >> (16 + _SrcShiftR)) & (0xff >> _SrcShiftR); }
+ static constexpr u32 source32_g(u32 pixel) { return (pixel >> ( 8 + _SrcShiftG)) & (0xff >> _SrcShiftG); }
+ static constexpr u32 source32_b(u32 pixel) { return (pixel >> ( 0 + _SrcShiftB)) & (0xff >> _SrcShiftB); }
// destination pixel masks are based on the template parameters as well
- static inline u32 dest_r(_PixelType pixel) { return (pixel >> _DstShiftR) & (0xff >> _SrcShiftR); }
- static inline u32 dest_g(_PixelType pixel) { return (pixel >> _DstShiftG) & (0xff >> _SrcShiftG); }
- static inline u32 dest_b(_PixelType pixel) { return (pixel >> _DstShiftB) & (0xff >> _SrcShiftB); }
+ static constexpr u32 dest_r(_PixelType pixel) { return (pixel >> _DstShiftR) & (0xff >> _SrcShiftR); }
+ static constexpr u32 dest_g(_PixelType pixel) { return (pixel >> _DstShiftG) & (0xff >> _SrcShiftG); }
+ static constexpr u32 dest_b(_PixelType pixel) { return (pixel >> _DstShiftB) & (0xff >> _SrcShiftB); }
// generic conversion with special optimization for destinations in the standard format
- static inline _PixelType source32_to_dest(u32 pixel)
+ static constexpr _PixelType source32_to_dest(u32 pixel)
{
if (_SrcShiftR == 0 && _SrcShiftG == 0 && _SrcShiftB == 0 && _DstShiftR == 16 && _DstShiftG == 8 && _DstShiftB == 0)
return pixel;
@@ -67,12 +67,12 @@ private:
// The document also contains the constants below as floats.
//-------------------------------------------------
- static inline u32 clamp16_shift8(u32 x)
+ static constexpr u32 clamp16_shift8(u32 x)
{
return ((s32(x) < 0) ? 0 : (x > 65535 ? 255: x >> 8));
}
- static inline u32 ycc_to_rgb(u32 ycc)
+ static constexpr u32 ycc_to_rgb(u32 ycc)
{
// original equations:
//
@@ -131,7 +131,7 @@ private:
static inline u32 get_texel_palette16(const render_texinfo &texture, s32 curu, s32 curv)
{
const rgb_t *palbase = texture.palette;
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
s32 u0 = curu >> 16;
s32 u1 = 1;
@@ -167,7 +167,7 @@ private:
static inline u32 get_texel_palette16a(const render_texinfo &texture, s32 curu, s32 curv)
{
const rgb_t *palbase = texture.palette;
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
s32 u0 = curu >> 16;
s32 u1 = 1;
@@ -198,7 +198,7 @@ private:
static inline u32 get_texel_yuy16(const render_texinfo &texture, s32 curu, s32 curv)
{
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
s32 u0 = curu >> 16;
s32 u1 = 1;
@@ -260,7 +260,7 @@ private:
static inline u32 get_texel_rgb32(const render_texinfo &texture, s32 curu, s32 curv)
{
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
s32 u0 = curu >> 16;
s32 u1 = 1;
@@ -291,7 +291,7 @@ private:
static inline u32 get_texel_argb32(const render_texinfo &texture, s32 curu, s32 curv)
{
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
s32 u0 = curu >> 16;
s32 u1 = 1;
@@ -901,7 +901,7 @@ private:
static void draw_quad_yuy16_add(const render_primitive &prim, _PixelType *dstdata, u32 pitch, const quad_setup_data&setup)
{
// simply can't do this without reading from the dest
- if (_NoDestRead)
+ if constexpr (_NoDestRead)
return;
// fast case: no coloring, no alpha
@@ -1738,7 +1738,7 @@ private:
setup.startv += (setup.dvdx + setup.dvdy) / 2;
// if we're bilinear filtering, we need to offset u/v by half a texel
- if (_BilinearFilter)
+ if constexpr (_BilinearFilter)
{
setup.startu -= 0x8000;
setup.startv -= 0x8000;
diff --git a/src/emu/rendutil.h b/src/emu/rendutil.h
index 9208d729352..c2d18d43f35 100644
--- a/src/emu/rendutil.h
+++ b/src/emu/rendutil.h
@@ -69,7 +69,7 @@ static inline float render_round_nearest(float f)
flip flags
-------------------------------------------------*/
-static inline int orientation_swap_flips(int orientation)
+constexpr int orientation_swap_flips(int orientation)
{
return (orientation & ORIENTATION_SWAP_XY) |
((orientation & ORIENTATION_FLIP_X) ? ORIENTATION_FLIP_Y : 0) |
@@ -82,7 +82,7 @@ static inline int orientation_swap_flips(int orientation)
that will undo another orientation
-------------------------------------------------*/
-static inline int orientation_reverse(int orientation)
+constexpr int orientation_reverse(int orientation)
{
/* if not swapping X/Y, then just apply the same transform to reverse */
if (!(orientation & ORIENTATION_SWAP_XY))
@@ -99,7 +99,7 @@ static inline int orientation_reverse(int orientation)
after applying two subsequent orientations
-------------------------------------------------*/
-static inline int orientation_add(int orientation1, int orientation2)
+constexpr int orientation_add(int orientation1, int orientation2)
{
/* if the 2nd transform doesn't swap, just XOR together */
if (!(orientation2 & ORIENTATION_SWAP_XY))