Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD Instruction Set for OLC completed and tested. #318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Johnnyg63
Copy link

Phase 1 release
Hi Team, Yes its back! and working as expected now:
There are a bunch of new SIMD instruction for the team to play with and enjoy. I have added a few extra methods for merging of sprites, have fun.

You can see a demo here I will work on updates here, and you can get a preview of things to come.

Phase 2 will have NEON(ARM) support, I may introduce threading (using different CPUs to execute SIMD), but it may need a lot of changes to the engine, so I will need to reach out to @OneLoneCoder before I do anything, it may not be straight forward and my goal is to ensure backward compatibly.

This document should explain everything, I am continuously updating it and will also upload drafts to Discord

OLC PGE How to implement SIMD.docx

Finally please give it a good test, please please please break it and report bugs to me.

CHANGES:

  • #include <intrin.h>
    Public: Class Sprite

  • Updated ~Sprite to clear any stored vector sprites

  • Inline void: void setStoreSubSprites(bool bStore)

  • Inline bool: bool getStoreSubSprites()

  • Inline void: void setInsturctionSet(SIMD_INSTRUCTON_OPTION option)

  • Inline int: SIMD_INSTRUCTON_OPTION getInsturctionSet()

  • Inline: bool CheckForSSESupport()

  • Inline: bool CheckForAVXSupport()

  • Inline: bool CheckForAVX512Support()

  • Inline: bool CheckForARMSupport() Placeholder not implemented yet

  • olc::Sprite* Duplicate(olc::Sprite::Flip flip);

  • olc::Sprite* Duplicate(uint32_t scale);

  • olc::Sprite* DuplicateMerge(const olc::vi2d& vTargetPos, olc::Sprite* pTargetSprite, olc::Pixel p = olc::BLANK);

  • olc::Sprite* Duplicate_SIMD();

  • olc::Sprite* Duplicate_SIMD(olc::Sprite::Flip flip);

  • olc::Sprite* Duplicate_SIMD(uint32_t scale); // John Galvin

  • olc::Sprite* Duplicate_SIMD(const olc::vi2d& vPos, const olc::vi2d& vSize);

  • olc::Sprite* DrawToTarget_SIMD(const olc::vi2d& vPos, olc::Sprite* pdrawTarget);

  • olc::Sprite* DrawToTarget_SIMD(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint8_t flip);

  • olc::Sprite* DrawToTarget_SIMD(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint32_t scale, uint8_t flip);

  • olc::Sprite* DuplicateMerge_SIMD(const olc::vi2d& vTargetPos, olc::Sprite* pTargetSprite, olc::Pixel p = olc::BLANK);

  • std::vector<std::tuple<olc::vi2d, olc::vi2d, uint32_t, uint8_t, Sprite*>> vecSubSprites;

    Private: Class Sprite

    • olc::Sprite* Duplicate_SSE(olc::Sprite::Flip flip)
    • olc::Sprite* Duplicate_AVX256(olc::Sprite::Flip flip)
    • olc::Sprite* Duplicate_AVX512(olc::Sprite::Flip flip)
    • olc::Sprite* Duplicate_SSE(uint32_t scale)
    • olc::Sprite* Duplicate_AVX256(uint32_t scale)
    • olc::Sprite* Duplicate_AVX512(uint32_t scale)
    • olc::Sprite* Duplicate_SSE(const olc::vi2d& vPos, const olc::vi2d& vSize)
    • olc::Sprite* Duplicate_AVX256(const olc::vi2d& vPos, const olc::vi2d& vSize)
    • olc::Sprite* Duplicate_AVX512(const olc::vi2d& vPos, const olc::vi2d& vSize)
    • olc::Sprite* Duplicate_SSE(const olc::vi2d& vPos, olc::Sprite* pdrawTarget)
    • olc::Sprite* Duplicate_AVX256(const olc::vi2d& vPos, olc::Sprite* pdrawTarget)
    • olc::Sprite* Duplicate_AVX512(const olc::vi2d& vPos, olc::Sprite* pdrawTarget)
    • olc::Sprite* Duplicate_SSE(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint8_t flip)
    • olc::Sprite* Duplicate_AVX256(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint8_t flip)
    • olc::Sprite* Duplicate_AVX512(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint8_t flip)
    • olc::Sprite* Duplicate_SSE(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint32_t scale, uint8_t flip)
    • olc::Sprite* Duplicate_AVX256(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint32_t scale, uint8_t flip)
    • olc::Sprite* Duplicate_AVX512(const olc::vi2d& vPos, olc::Sprite* pdrawTarget, uint32_t scale, uint8_t flip)
    • olc::Sprite* DuplicateMerge_SSE(const olc::vi2d& vTargetPos, olc::Sprite* pTargetSprite, std::vector vecPositions, olc::Pixel p)
    • olc::Sprite* DuplicateMerge_AVX256(const olc::vi2d& vTargetPos, olc::Sprite* pTargetSprite, std::vector vecPositions, olc::Pixel p)
    • olc::Sprite* DuplicateMerge_AVX512(const olc::vi2d& vTargetPos, olc::Sprite* pTargetSprite, std::vector vecPositions, olc::Pixel p)

    Public: Class PixelGameEngine

    • Inline enum: enum INSTRUCTON_OPTION
    • Inline void: void setInsturctionSet(INSTRUCTON_OPTION option)
    • Inline bool: int getInsturctionSet()
    • static bool CheckForSSESupport()
    • static bool CheckForAVXSupport()
    • static bool CheckForAVX512Support()
    • void Clear_SIMD(Pixel p = olc::BLANK)
    • void FillCircle_SIMD(olc::vi2d pos, int32_t radius, Pixel p = olc::WHITE)
    • void FillCircle_SIMD(int32_t x, int32_t y, int32_t radius, Pixel p = olc::WHITE)
    • void FillTriangle_SIMD(const olc::vi2d& pos1, const olc::vi2d& pos2, const olc::vi2d& pos3, Pixel p = olc::WHITE)
    • void FillTriangle_SIMD(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p = olc::WHITE)
    • void FillRect_SIMD(const olc::vi2d& pos, const olc::vi2d& size, Pixel p = olc::WHITE)
    • void FillRect_SIMD(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p = olc::WHITE)
    • void DrawSprite_SIMD(const olc::vi2d& pos, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE)
    • void DrawSprite_SIMD(int32_t x, int32_t y, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE)
    • void DrawPartialSprite_SIMD(const olc::vi2d& pos, Sprite* sprite, const olc::vi2d& sourcepos, const olc::vi2d& size, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE)
    • void DrawPartialSprite_SIMD(int32_t x, int32_t y, Sprite* sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE)
    • void DrawMergeSprite_SIMD(const olc::vi2d& vPos, Sprite* pFromSprite, const olc::vi2d& vToSpritePos, Sprite* pToSprite, Pixel blendPixel = olc::BLANK, uint32_t scale = 1, olc::Sprite::Flip flip = olc::Sprite::NONE);
    • void DrawMergeSprite_SIMD(int32_t vPosx, int32_t vPosy, Sprite* pFromSprite, int32_t vToSpritePosx, int32_t vToSpritePosy, Sprite* pToSprite, Pixel blendPixel = olc::BLANK, uint32_t scale = 1, olc::Sprite::Flip flip = olc::Sprite::NONE);
    • void DrawMergeSprite(int32_t vPosx, int32_t vPosy, Sprite* pFromSprite, int32_t vToSpritePosx, int32_t vToSpritePosy, Sprite* pToSprite, Pixel blendPixel = olc::BLANK, uint32_t scale = 1, olc::Sprite::Flip flip = olc::Sprite::NONE);
    • void DrawMergeSprite(const olc::vi2d& vPos, Sprite* pFromSprite, const olc::vi2d& vToSpritePos, Sprite* pToSprite, Pixel blendPixel = olc::BLANK, uint32_t scale = 1, olc::Sprite::Flip flip = olc::Sprite::NONE);

    Private: Class PixelGameEngine

    • void Clear_SSE(int VecStartIndex, int VecEndIndex, Pixel p = olc::BLANK)
    • void Clear_AVX256(int VecStartIndex, int VecEndIndex, Pixel p = olc::BLANK)
    • void Clear_AVX512(int VecStartIndex, int VecEndIndex, Pixel p = olc::BLANK)
    • bool Draw_SIMD(int32_t sx, int32_t ex, int32_t ny, Pixel p = olc::WHITE)
    • void DrawFillLine_SSE(int sx, int ex, int ny, Pixel p = olc::WHITE)
    • void DrawFillLine_AVX256(int sx, int ex, int ny, Pixel p = olc::WHITE)
    • void DrawFillLine_AVX512(int sx, int ex, int ny, Pixel p = olc::WHITE)
    • void DrawFillLine_SIMD(int VecStartIndex, int VecEndIndex, int ny, Pixel p = olc::WHITE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant