From 35d742677a59b4340b24f703bad666f3700b14b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 11 Feb 2016 21:21:36 +0300 Subject: Use inline attribute in some critial performance functions. --- src/render/graphicsdef.hpp | 17 +++++++++++------ src/render/mobileopengl2graphics.h | 27 ++++++++++++++++----------- src/render/mobileopenglgraphics.cpp | 5 +++-- src/render/mobileopenglgraphics.h | 9 +++++---- src/render/modernopenglgraphics.h | 27 ++++++++++++++++----------- src/render/normalopenglgraphics.cpp | 13 +++++++++++-- src/render/normalopenglgraphics.h | 16 ++++++++-------- src/render/nullopenglgraphics.h | 12 ++++++------ src/render/openglgraphicsdef.hpp | 4 ++-- src/render/openglgraphicsdefadvanced.hpp | 2 +- src/render/safeopenglgraphics.cpp | 5 +++-- 11 files changed, 82 insertions(+), 55 deletions(-) (limited to 'src/render') diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp index 0b077d373..e7b775ff0 100644 --- a/src/render/graphicsdef.hpp +++ b/src/render/graphicsdef.hpp @@ -52,7 +52,7 @@ public: void inline drawPatternInline(const Image *restrict const image, const int x, const int y, - const int w, const int h) restrict2; + const int w, const int h) restrict2 A_INLINE; void drawRescaledPattern(const Image *restrict const image, const int x, const int y, @@ -128,16 +128,21 @@ private: void inline calcImageRect(ImageVertexes *restrict const vert, int x, int y, int w, int h, - const ImageRect &restrict imgRect) restrict2; + const ImageRect &restrict imgRect) + restrict2 A_INLINE; void inline calcPatternInline(ImageVertexes *restrict const vert, const Image *restrict const image, - const int x, const int y, - const int w, const int h) const restrict2; + const int x, + const int y, + const int w, + const int h) const restrict2 A_INLINE; void inline calcTileVertexesInline(ImageVertexes *restrict const vert, const Image *restrict const image, - int x, int y) const restrict2; + int x, + int y) const restrict2 A_INLINE; void inline drawImageInline(const Image *restrict const image, - int dstX, int dstY) restrict2; + int dstX, + int dstY) restrict2 A_INLINE; diff --git a/src/render/mobileopengl2graphics.h b/src/render/mobileopengl2graphics.h index 5fbf32045..599c6fe80 100644 --- a/src/render/mobileopengl2graphics.h +++ b/src/render/mobileopengl2graphics.h @@ -85,31 +85,36 @@ class MobileOpenGL2Graphics final : public Graphics private: void deleteGLObjects() restrict2; - inline void drawQuad(const int srcX, const int srcY, - const int dstX, const int dstY, - const int width, const int height) restrict2; + inline void drawQuad(const int srcX, + const int srcY, + const int dstX, + const int dstY, + const int width, + const int height) restrict2 A_INLINE; inline void drawRescaledQuad(const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, - const int desiredHeight) restrict2; + const int desiredHeight) + restrict2 A_INLINE; - inline void drawTriangleArray(const int size) restrict2; + inline void drawTriangleArray(const int size) restrict2 A_INLINE; inline void drawTriangleArray(const GLfloat *restrict const array, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawLineArrays(const int size) restrict2; + inline void drawLineArrays(const int size) restrict2 A_INLINE; - inline void bindArrayBuffer(const GLuint vbo) restrict2; + inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE; - inline void bindArrayBufferAndAttributes(const GLuint vbo) restrict2; + inline void bindArrayBufferAndAttributes(const GLuint vbo) + restrict2 A_INLINE; - inline void bindAttributes() restrict2; + inline void bindAttributes() restrict2 A_INLINE; static void bindTexture2(const GLenum target, - const Image *restrict const image); + const Image *restrict const image) A_INLINE; static GLuint mTextureSizeUniform; static int mTextureWidth; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index f703ff667..fb4651409 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -163,7 +163,7 @@ static inline void drawQuad(const Image *restrict const image, const int dstX, const int dstY, const int width, - const int height) A_NONNULL(1); + const int height) A_NONNULL(1) A_INLINE; static inline void drawQuad(const Image *restrict const image, const int srcX, @@ -215,7 +215,8 @@ static inline void drawRescaledQuad(const Image *restrict const image, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, - const int desiredHeight) A_NONNULL(1); + const int desiredHeight) + A_NONNULL(1) A_INLINE; static inline void drawRescaledQuad(const Image *restrict const image, const int srcX, const int srcY, diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index d6356d8ce..7af81a4c8 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -61,13 +61,14 @@ class MobileOpenGLGraphics final : public Graphics shortVertArray, const GLfloat *restrict const floatTexArray, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawTriangleArrayfs(const int size) restrict2; + inline void drawTriangleArrayfs(const int size) restrict2 A_INLINE; - inline void drawTriangleArrayfsCached(const int size) restrict2; + inline void drawTriangleArrayfsCached(const int size) + restrict2 A_INLINE; - inline void drawLineArrays(const int size) restrict2; + inline void drawLineArrays(const int size) restrict2 A_INLINE; #include "render/graphicsdef.hpp" diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h index 9f2467a76..0c7d0d5c9 100644 --- a/src/render/modernopenglgraphics.h +++ b/src/render/modernopenglgraphics.h @@ -85,30 +85,35 @@ class ModernOpenGLGraphics final : public Graphics private: void deleteGLObjects() restrict2; - inline void drawQuad(const int srcX, const int srcY, - const int dstX, const int dstY, - const int width, const int height) restrict2; + inline void drawQuad(const int srcX, + const int srcY, + const int dstX, + const int dstY, + const int width, + const int height) restrict2 A_INLINE; inline void drawRescaledQuad(const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, - const int desiredHeight) restrict2; + const int desiredHeight) + restrict2 A_INLINE; - inline void drawTriangleArray(const int size) restrict2; + inline void drawTriangleArray(const int size) restrict2 A_INLINE; inline void drawTriangleArray(const GLint *restrict const array, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawLineArrays(const int size) restrict2; + inline void drawLineArrays(const int size) restrict2 A_INLINE; - inline void bindArrayBuffer(const GLuint vbo) restrict2; + inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE; - inline void bindArrayBufferAndAttributes(const GLuint vbo) restrict2; + inline void bindArrayBufferAndAttributes(const GLuint vbo) + restrict2 A_INLINE; - inline void bindAttributes() restrict2; + inline void bindAttributes() restrict2 A_INLINE; - inline void bindElementBuffer(const GLuint ebo) restrict2; + inline void bindElementBuffer(const GLuint ebo) restrict2 A_INLINE; GLint *mIntArray A_NONNULLPOINTER; GLint *mIntArrayCached A_NONNULLPOINTER; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 0e6419c21..74ba1d403 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -179,6 +179,10 @@ bool NormalOpenGLGraphics::setVideoMode(const int w, const int h, return setOpenGLMode(); } +static inline void bindPointerIntFloat(const GLint *restrict const vert, + const GLfloat *restrict const tex) + A_INLINE; + static inline void bindPointerIntFloat(const GLint *restrict const vert, const GLfloat *restrict const tex) { @@ -190,6 +194,9 @@ static inline void bindPointerIntFloat(const GLint *restrict const vert, } } +static inline void bindPointerInt(const GLint *restrict const vert, + const GLint *restrict const tex) A_INLINE; + static inline void bindPointerInt(const GLint *restrict const vert, const GLint *restrict const tex) { @@ -204,7 +211,8 @@ static inline void bindPointerInt(const GLint *restrict const vert, static inline void drawQuad(const Image *restrict const image, const int srcX, const int srcY, const int dstX, const int dstY, - const int width, const int height) A_NONNULL(1); + const int width, const int height) + A_NONNULL(1) A_INLINE; static inline void drawQuad(const Image *restrict const image, const int srcX, const int srcY, @@ -273,7 +281,8 @@ static inline void drawRescaledQuad(const Image *restrict const image, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, - const int desiredHeight) A_NONNULL(1); + const int desiredHeight) + A_NONNULL(1) A_INLINE; static inline void drawRescaledQuad(const Image *restrict const image, const int srcX, const int srcY, diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 4262b5aab..05014deed 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -55,26 +55,26 @@ class NormalOpenGLGraphics final : public Graphics ~NormalOpenGLGraphics(); - inline void drawQuadArrayfi(const int size) restrict2; + inline void drawQuadArrayfi(const int size) restrict2 A_INLINE; - inline void drawQuadArrayfiCached(const int size) restrict2; + inline void drawQuadArrayfiCached(const int size) restrict2 A_INLINE; inline void drawQuadArrayfi(const GLint *restrict const intVertArray, const GLfloat *restrict const floatTexArray, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawQuadArrayii(const int size) restrict2; + inline void drawQuadArrayii(const int size) restrict2 A_INLINE; - inline void drawQuadArrayiiCached(const int size) restrict2; + inline void drawQuadArrayiiCached(const int size) restrict2 A_INLINE; inline void drawQuadArrayii(const GLint *restrict const intVertArray, const GLint *restrict const intTexArray, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawLineArrayi(const int size) restrict2; + inline void drawLineArrayi(const int size) restrict2 A_INLINE; - inline void drawLineArrayf(const int size) restrict2; + inline void drawLineArrayf(const int size) restrict2 A_INLINE; void testDraw() restrict2 override final; diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index 57506125c..fb7cdc806 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -55,22 +55,22 @@ class NullOpenGLGraphics final : public Graphics ~NullOpenGLGraphics(); - inline void drawQuadArrayfi(const int size) restrict2; + inline void drawQuadArrayfi(const int size) restrict2 A_INLINE; inline void drawQuadArrayfi(const GLint *restrict const intVertArray, const GLfloat *restrict const floatTexArray, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawQuadArrayii(const int size) restrict2; + inline void drawQuadArrayii(const int size) restrict2 A_INLINE; inline void drawQuadArrayii(const GLint *restrict const intVertArray, const GLint *restrict const intTexArray, - const int size) restrict2; + const int size) restrict2 A_INLINE; - inline void drawLineArrayi(const int size) restrict2; + inline void drawLineArrayi(const int size) restrict2 A_INLINE; - inline void drawLineArrayf(const int size) restrict2; + inline void drawLineArrayf(const int size) restrict2 A_INLINE; #include "render/graphicsdef.hpp" diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 4b32c6442..42f61c2be 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -49,6 +49,6 @@ protected: void setTexturingAndBlending(const bool enable) restrict2; private: - void inline setColorAlpha(const float alpha) restrict2; + void inline setColorAlpha(const float alpha) restrict2 A_INLINE; - void inline restoreColor() restrict2; + void inline restoreColor() restrict2 A_INLINE; diff --git a/src/render/openglgraphicsdefadvanced.hpp b/src/render/openglgraphicsdefadvanced.hpp index 7e1017c23..c63c6ba7f 100644 --- a/src/render/openglgraphicsdefadvanced.hpp +++ b/src/render/openglgraphicsdefadvanced.hpp @@ -22,7 +22,7 @@ public: inline void drawVertexes(const OpenGLGraphicsVertexes &restrict ogl) - restrict2; + restrict2 A_INLINE; void initArrays(const int vertCount) restrict2 override final; diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 2a507808a..48fe5e2d2 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -74,7 +74,7 @@ static inline void drawQuad(const Image *restrict image, const int dstX, const int dstY, const int width, - const int height) A_NONNULL(1); + const int height) A_NONNULL(1) A_INLINE; static inline void drawQuad(const Image *restrict image, const int srcX, @@ -121,7 +121,8 @@ static inline void drawRescaledQuad(const Image *restrict const image, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, - const int desiredHeight) A_NONNULL(1); + const int desiredHeight) + A_NONNULL(1) A_INLINE; static inline void drawRescaledQuad(const Image *restrict const image, const int srcX, const int srcY, -- cgit v1.2.3-70-g09d2