Move tables to their own file to stop lagging clion to hell

faster-single-tables
Andrew Cassidy 3 years ago
parent 085ed385df
commit 8171e0f45a

@ -1,13 +1,16 @@
cmake_minimum_required(VERSION 3.17)
project(python_rgbcx)
# Setup pybind
add_subdirectory(extern/pybind11)
# Make the python_rgbcx module
add_library(python_rgbcx MODULE src/main.cpp src/rgbcx.cpp)
set(C_FILES
src/main.cpp
src/rgbcx.cpp
src/tables.cpp
)
add_library(python_rgbcx MODULE ${C_FILES})
# Link to Pybind
add_subdirectory(extern/pybind11)
target_link_libraries(python_rgbcx PRIVATE pybind11::module pybind11::lto)
pybind11_extension(python_rgbcx)

File diff suppressed because it is too large Load Diff

@ -47,18 +47,19 @@
//
// - chan0 and chan1 are the source channels. Typically they will be 0 and 1.
//
// All encoding and decoding functions are threade-safe.
// All encoding and decoding functions are thread-safe.
//
// To reduce the compiled size of the encoder, set #define RGBCX_USE_SMALLER_TABLES to 1 before including this header.
//
#ifndef RGBCX_INCLUDE_H
#define RGBCX_INCLUDE_H
#pragma once
#include <algorithm>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include "tables.h"
// By default, the table used to accelerate cluster fit on 4 color blocks uses a 969x128 entry table.
// To reduce the executable size, set RGBCX_USE_SMALLER_TABLES to 1, which selects the smaller 969x32 entry table.
@ -151,14 +152,6 @@ enum {
cEncodeBC1EndpointSearchRoundsMask = 1023U << cEncodeBC1EndpointSearchRoundsShift,
};
const uint32_t MIN_TOTAL_ORDERINGS = 1;
const uint32_t MAX_TOTAL_ORDERINGS3 = 32;
#if RGBCX_USE_SMALLER_TABLES
const uint32_t MAX_TOTAL_ORDERINGS4 = 32;
#else
const uint32_t MAX_TOTAL_ORDERINGS4 = 128;
#endif
// DEFAULT_TOTAL_ORDERINGS_TO_TRY is around 3x faster than libsquish at slightly higher average quality. 10-16 is a good range to start to compete against
// libsquish.
@ -171,7 +164,7 @@ const uint32_t DEFAULT_TOTAL_ORDERINGS_TO_TRY3 = 1;
// The pixels are in RGBA format, where R is first in memory. The BC1 encoder completely ignores the alpha channel (i.e. there is no punchthrough alpha
// support). This is the recommended function to use for BC1 encoding, becuase it configures the encoder for you in the best possible way (on average). Note
// that the 3 color modes won't be used at all until level 5 or higher. No transparency supported, however if you set use_transparent_texels_for_black to true
// the encocer will use transparent selectors on very dark/black texels to reduce MSE.
// the encoder will use transparent selectors on very dark/black texels to reduce MSE.
const uint32_t MIN_LEVEL = 0, MAX_LEVEL = 18;
void encode_bc1(uint32_t level, void *pDst, const uint8_t *pPixels, bool allow_3color, bool use_transparent_texels_for_black);
@ -210,7 +203,6 @@ bool unpack_bc3(const void *pBlock_bits, void *pPixels, bc1_approx_mode mode = b
void unpack_bc5(const void *pBlock_bits, void *pPixels, uint32_t chan0 = 0, uint32_t chan1 = 1, uint32_t stride = 4);
} // namespace rgbcx
#endif // #ifndef RGBCX_INCLUDE_H
/*
------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

@ -0,0 +1,66 @@
// rgbcx.h v1.12
// High-performance scalar BC1-5 encoders. Public Domain or MIT license (you choose - see below), written by Richard Geldreich 2020 <richgel99@gmail.com>.
#pragma once
#include <cstdint>
const uint32_t MIN_TOTAL_ORDERINGS = 1;
const uint32_t MAX_TOTAL_ORDERINGS3 = 32;
#if RGBCX_USE_SMALLER_TABLES
const uint32_t MAX_TOTAL_ORDERINGS4 = 32;
#else
const uint32_t MAX_TOTAL_ORDERINGS4 = 128;
#endif
const uint32_t NUM_UNIQUE_TOTAL_ORDERINGS4 = 969;
extern const uint8_t g_unique_total_orders4[NUM_UNIQUE_TOTAL_ORDERINGS4][4];
const uint32_t NUM_UNIQUE_TOTAL_ORDERINGS3 = 153;
extern const uint8_t g_unique_total_orders3[NUM_UNIQUE_TOTAL_ORDERINGS3][3];
extern const uint16_t g_best_total_orderings4[NUM_UNIQUE_TOTAL_ORDERINGS4][MAX_TOTAL_ORDERINGS4];
extern const uint8_t g_best_total_orderings3[NUM_UNIQUE_TOTAL_ORDERINGS3][32];
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright(c) 2020 Richard Geldreich, Jr.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files(the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain(www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non - commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain.We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors.We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/
Loading…
Cancel
Save