mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Address some of the more annoying gcc warnings
This commit is contained in:
parent
3a27a89155
commit
6afe4851bd
@ -48,16 +48,16 @@ template <typename T> class BlockEncoder : public Encoder<T> {
|
||||
virtual T Encode(const RawTexture &decoded) const override {
|
||||
auto encoded = T(decoded.width, decoded.height);
|
||||
|
||||
int blocks_x = encoded.bwidth();
|
||||
int blocks_y = encoded.bheight();
|
||||
unsigned blocks_x = encoded.bwidth();
|
||||
unsigned blocks_y = encoded.bheight();
|
||||
|
||||
// from experimentation, multithreading this using OpenMP sometimes actually makes encoding slower
|
||||
// due to thread creation/teardown taking longer than the encoding process itself.
|
||||
// As a result, this is sometimes left as a serial operation despite being embarassingly parallelizable
|
||||
// threshold for number of blocks before multithreading is set by overriding MTThreshold()
|
||||
#pragma omp parallel for if (blocks_x * blocks_y >= MTThreshold())
|
||||
for (int y = 0; y < blocks_y; y++) {
|
||||
for (int x = 0; x < blocks_x; x++) {
|
||||
for (unsigned y = 0; y < blocks_y; y++) {
|
||||
for (unsigned x = 0; x < blocks_x; x++) {
|
||||
auto pixels = decoded.get_block<BlockWidth, BlockHeight>(x, y);
|
||||
auto block = EncodeBlock(pixels);
|
||||
encoded.set_block(x, y, block);
|
||||
|
@ -300,7 +300,7 @@ template <typename B> py::class_<B> BindBlock(py::module_& m, const char* name)
|
||||
"tobytes", [](const B& b) { return py::bytes(reinterpret_cast<const char*>(&b), sizeof(B)); },
|
||||
Format(tobytes_doc, name, std::to_string(sizeof(B))).c_str());
|
||||
|
||||
return std::move(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
template <typename B> py::class_<BlockTexture<B>> BindBlockTexture(py::module_& m, const char* name) {
|
||||
@ -337,6 +337,6 @@ template <typename B> py::class_<BlockTexture<B>> BindBlockTexture(py::module_&
|
||||
|
||||
DefSubscript2D(block_texture, &BTex::get_block, &BTex::set_block, &BTex::bsize);
|
||||
|
||||
return std::move(block_texture);
|
||||
return block_texture;
|
||||
}
|
||||
} // namespace quicktex::bindings
|
@ -541,7 +541,7 @@ void BC1Encoder::FindEndpoints(EncodeResults &result, const CBlock &pixels, cons
|
||||
float denominator = (float)(16 * sum_xx) - (float)(sum_x * sum_x);
|
||||
|
||||
// once per secondary axis, calculate high and low using least squares
|
||||
if (fabs(denominator) > 1e-8f) {
|
||||
if (abs(denominator) > 1e-8f) {
|
||||
for (unsigned i = 1; i < 3; i++) {
|
||||
/* each secondary axis is fitted with a linear formula of the form
|
||||
* y = ax + b
|
||||
@ -835,7 +835,7 @@ bool BC1Encoder::RefineEndpointsLS(EncodeResults &result, const CBlock &pixels,
|
||||
|
||||
// invert matrix
|
||||
float det = matrix.Determinant2x2(); // z00 * z11 - z01 * z10;
|
||||
if (fabs(det) < 1e-8f) {
|
||||
if (abs(det) < 1e-8f) {
|
||||
result.color_mode = ColorMode::Incomplete;
|
||||
return false;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "Histogram.h"
|
||||
#include "Vector4.h"
|
||||
#include "util/math.h"
|
||||
|
||||
namespace quicktex::s3tc {
|
||||
template <size_t N> class OrderTable {
|
||||
@ -73,7 +74,7 @@ template <size_t N> class OrderTable {
|
||||
for (unsigned sel = 0; sel < N; sel++) factor_matrix += (Weights[sel] * h[sel]);
|
||||
|
||||
float det = factor_matrix.Determinant2x2();
|
||||
if (fabs(det) < 1e-8f) {
|
||||
if (abs(det) < 1e-8f) {
|
||||
factors->at(i) = Vector4(0);
|
||||
} else {
|
||||
std::swap(factor_matrix[0], factor_matrix[3]);
|
||||
|
@ -40,7 +40,7 @@ template <typename B> class BlockTexture final : public Texture {
|
||||
* @param width width of the texture in pixels. must be divisible by B::width
|
||||
* @param height height of the texture in pixels. must be divisible by B::height
|
||||
*/
|
||||
BlockTexture(int width, int height) : Base(width, height) {
|
||||
BlockTexture(int w, int h) : Base(w, h) {
|
||||
_width_b = (width + B::Width - 1) / B::Width;
|
||||
_height_b = (height + B::Height - 1) / B::Height;
|
||||
_blocks = std::vector<B>(_width_b * _height_b);
|
||||
|
@ -20,14 +20,14 @@
|
||||
#include "RawTexture.h"
|
||||
|
||||
namespace quicktex {
|
||||
Color RawTexture::pixel(unsigned int x, unsigned int y) const {
|
||||
if (x < 0 || x >= width) throw std::invalid_argument("x value out of range.");
|
||||
if (y < 0 || y >= height) throw std::invalid_argument("y value out of range.");
|
||||
Color RawTexture::pixel(unsigned x, unsigned y) const {
|
||||
if (x >= width) throw std::invalid_argument("x value out of range.");
|
||||
if (y >= height) throw std::invalid_argument("y value out of range.");
|
||||
return _pixels.at(x + (y * width));
|
||||
}
|
||||
quicktex::Color& RawTexture::pixel(unsigned int x, unsigned int y) {
|
||||
if (x < 0 || x >= width) throw std::invalid_argument("x value out of range.");
|
||||
if (y < 0 || y >= height) throw std::invalid_argument("y value out of range.");
|
||||
quicktex::Color& RawTexture::pixel(unsigned x, unsigned y) {
|
||||
if (x >= width) throw std::invalid_argument("x value out of range.");
|
||||
if (y >= height) throw std::invalid_argument("y value out of range.");
|
||||
return _pixels.at(x + (y * width));
|
||||
}
|
||||
} // namespace quicktex
|
@ -45,7 +45,7 @@ class RawTexture : public Texture {
|
||||
* @param width width of the texture in pixels
|
||||
* @param height height of the texture in pixels
|
||||
*/
|
||||
RawTexture(int width, int height) : Base(width, height), _pixels(width * height) {}
|
||||
RawTexture(int w, int h) : Base(w, h), _pixels(w* h) {}
|
||||
|
||||
quicktex::Color pixel(unsigned x, unsigned y) const;
|
||||
|
||||
|
@ -56,9 +56,7 @@ class Texture {
|
||||
virtual uint8_t *data() noexcept = 0;
|
||||
|
||||
protected:
|
||||
Texture(unsigned width, unsigned height) : width(width), height(height) {}
|
||||
Texture(unsigned w, unsigned h) : width(w), height(h) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace quicktex
|
@ -24,8 +24,8 @@
|
||||
namespace quicktex {
|
||||
|
||||
// Window
|
||||
Window::Window(RawTexture& texture, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
|
||||
: width(width), height(height), x(x), y(y), _texture(texture) {
|
||||
Window::Window(RawTexture& texture, unsigned w, unsigned h, unsigned px, unsigned py)
|
||||
: width(w), height(h), x(px), y(py), _texture(texture) {
|
||||
assert(x < texture.width);
|
||||
assert(y < texture.height);
|
||||
}
|
||||
@ -51,7 +51,7 @@ bool Window::operator==(const Window& rhs) const {
|
||||
|
||||
// WindowIterator
|
||||
|
||||
WindowIterator::WindowIterator(Window& view, unsigned int x, unsigned int y) : x(x), y(y), _view(&view) {
|
||||
WindowIterator::WindowIterator(Window& view, unsigned px, unsigned py) : x(px), y(py), _view(&view) {
|
||||
assert(x < view.width);
|
||||
assert(y < view.height || (y == view.height && x == 0));
|
||||
// if y == the height, and x == 0, then this is a sentinel for the end of iteration, and cannot be dereferenced
|
||||
@ -85,6 +85,6 @@ bool WindowIterator::operator==(const WindowIterator& rhs) const {
|
||||
}
|
||||
|
||||
static_assert(std::forward_iterator<WindowIterator>);
|
||||
//static_assert(sized_range<Window>);
|
||||
// static_assert(sized_range<Window>);
|
||||
|
||||
} // namespace quicktex
|
||||
|
@ -37,7 +37,7 @@ class Window {
|
||||
const unsigned width, height;
|
||||
const unsigned x, y;
|
||||
|
||||
Window(RawTexture &texture, unsigned width, unsigned height, unsigned x, unsigned y);
|
||||
Window(RawTexture &texture, unsigned w, unsigned h, unsigned x, unsigned y);
|
||||
|
||||
Color &pixel(unsigned px, unsigned py);
|
||||
Color pixel(unsigned px, unsigned py) const;
|
||||
|
@ -244,7 +244,7 @@ inline constexpr P pack(II start, II end, WI widths, bool little_endian = true)
|
||||
auto w = *(widths++);
|
||||
|
||||
val &= ((1 << w) - 1);
|
||||
assert(val < (1 << w)); // ensure value can fit in W bits
|
||||
assert(val < (1u << w)); // ensure value can fit in W bits
|
||||
|
||||
if (little_endian) {
|
||||
packed |= static_cast<P>(val) << offset; // first element is in the least significant place of packed
|
||||
|
@ -17,8 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
@ -97,9 +95,9 @@ struct chunker_impl<T, serial> {
|
||||
|
||||
static constexpr std::array<size_t, 1> chunk_sizes = {1};
|
||||
|
||||
template <size_t step> static constexpr size_t chunk_count(const T& r) { return 1; }
|
||||
template <size_t step> static constexpr auto get_chunk(const T& r, size_t i) { return r; }
|
||||
template <size_t step> static constexpr void set_chunk(T& r, size_t i, const T& c) { r = c; }
|
||||
template <size_t step> static constexpr size_t chunk_count(const T&) { return 1; }
|
||||
template <size_t step> static constexpr auto get_chunk(const T& r, size_t) { return r; }
|
||||
template <size_t step> static constexpr void set_chunk(T& r, size_t, const T& c) { r = c; }
|
||||
};
|
||||
|
||||
template <typename T, bool serial = false, size_t step = 0>
|
||||
@ -177,5 +175,4 @@ inline auto map(Op f, const T& in, const Args&... args) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace quicktex
|
||||
#pragma clang diagnostic pop
|
||||
} // namespace quicktex
|
Loading…
Reference in New Issue
Block a user