Skip to content

Commit

Permalink
Moved compressed blitting into its own class for readability & easier…
Browse files Browse the repository at this point in the history
… maintenance.
  • Loading branch information
hamsham committed Mar 21, 2022
1 parent c8aaec7 commit 798e6aa
Show file tree
Hide file tree
Showing 12 changed files with 1,939 additions and 1,551 deletions.
2 changes: 2 additions & 0 deletions softlight/CMakeLists.txt
Expand Up @@ -123,6 +123,7 @@ set(SL_LIB_HEADERS
include/softlight/SL_AnimationProperty.hpp
include/softlight/SL_Atlas.hpp
include/softlight/SL_BlitProcesor.hpp
include/softlight/SL_BlitCompressedProcesor.hpp
include/softlight/SL_BoundingBox.hpp
include/softlight/SL_Camera.hpp
include/softlight/SL_ClearProcesor.hpp
Expand Down Expand Up @@ -213,6 +214,7 @@ set(SL_LIB_SOURCES
src/SL_AnimationPlayer.cpp
src/SL_Atlas.cpp
src/SL_BlitProcessor.cpp
src/SL_BlitCompressedProcessor.cpp
src/SL_BoundingBox.cpp
src/SL_Camera.cpp
src/SL_ClearProcessor.cpp
Expand Down
86 changes: 86 additions & 0 deletions softlight/include/softlight/SL_BlitCompressedProcesor.hpp
@@ -0,0 +1,86 @@

#ifndef SL_BLIT_COMPRESSED_PROCESSOR_HPP
#define SL_BLIT_COMPRESSED_PROCESSOR_HPP

#include <cstdint>



/*-----------------------------------------------------------------------------
* Forward Declarations
-----------------------------------------------------------------------------*/
class SL_Texture;



/**----------------------------------------------------------------------------
* @brief The Blit Processor helps to perform texture blitting to the native
* window backbuffer on another thread.
*
* Much of the blitting routines are templated to support conversion between
* possible texture types and the backbuffer (which is an 8-bit RGBA buffer).
*
* Texture blitting uses nearest-neighbor filtering to increase or decrease the
* resolution and fit the backbuffer. Fixed-point calculation is used to avoid
* precision errors and increase ALU throughput. Benchmarks on x86 and ARM has
* shown that floating-point logic performs worse in this area.
-----------------------------------------------------------------------------*/
struct SL_BlitCompressedProcessor
{
enum : uint_fast32_t
{
NUM_FIXED_BITS = 16u
};

// 32 bits
uint16_t mThreadId;
uint16_t mNumThreads;

// 64-bits
uint16_t srcX0;
uint16_t srcY0;
uint16_t srcX1;
uint16_t srcY1;

// 64-bits
uint16_t dstX0;
uint16_t dstY0;
uint16_t dstX1;
uint16_t dstY1;

// 64-128 bits
const SL_Texture* mTexture;
SL_Texture* mBackBuffer;

// 224-288 bits total, 28-36 bytes

// Blit a single R channel
template<typename inColor_type>
void blit_src_r() noexcept;

// Blit a texture with only RG color channels
template<typename inColor_type>
void blit_src_rg() noexcept;

// Blit an RGB texture
template<typename inColor_type>
void blit_src_rgb() noexcept;

// Blit all 4 color components
template<typename inColor_type>
void blit_src_rgba() noexcept;

// Blit compressed color components
template<typename inColor_type>
void blit_src_compressed() noexcept;

// Blit all 4 color components
template<class BlitOp>
void blit_nearest() noexcept;

void execute() noexcept;
};



#endif /* SL_BLIT_COMPRESSED_PROCESSOR_HPP */

0 comments on commit 798e6aa

Please sign in to comment.