quicktex/quicktex/s3tc/bc5/BC5Block.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.0 KiB
C
Raw Normal View History

2021-04-08 06:26:28 +00:00
/* Quicktex Texture Compression Library
2022-05-12 03:51:35 +00:00
Copyright (C) 2021-2022 Andrew Cassidy <drewcassidy@me.com>
2021-02-15 03:01:41 +00:00
Partially derived from rgbcx.h written by Richard Geldreich <richgel99@gmail.com>
and licenced under the public domain
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2021-04-03 02:24:54 +00:00
#include <utility>
2021-03-14 04:47:53 +00:00
#include "../bc4/BC4Block.h"
2021-02-15 03:01:41 +00:00
2021-03-28 09:36:47 +00:00
namespace quicktex::s3tc {
2021-02-15 03:01:41 +00:00
2021-04-01 23:37:15 +00:00
class alignas(8) BC5Block {
2021-02-15 03:01:41 +00:00
public:
2021-04-01 23:37:15 +00:00
static constexpr int Width = 4;
static constexpr int Height = 4;
2021-04-03 02:24:54 +00:00
using BlockPair = std::pair<BC4Block, BC4Block>;
BC4Block chan0_block;
BC4Block chan1_block;
constexpr BC5Block() : chan0_block(BC4Block()), chan1_block(BC4Block()) {
2021-04-01 23:37:15 +00:00
static_assert(sizeof(BC5Block) == 16);
static_assert(sizeof(std::array<BC5Block, 10>) == 16 * 10);
2021-04-02 05:37:25 +00:00
static_assert(alignof(BC5Block) >= 8);
2021-04-01 23:37:15 +00:00
}
2021-04-02 05:37:25 +00:00
BC5Block(const BC4Block &chan0, const BC4Block &chan1) {
2021-04-01 23:37:15 +00:00
chan0_block = chan0;
chan1_block = chan1;
}
2021-04-03 02:24:54 +00:00
BlockPair GetBlocks() const { return BlockPair(chan0_block, chan1_block); }
void SetBlocks(const BlockPair &pair) {
chan0_block = pair.first;
chan1_block = pair.second;
}
2021-04-05 09:44:56 +00:00
2021-05-08 23:50:05 +00:00
bool operator==(const BC5Block &Rhs) const { return chan0_block == Rhs.chan0_block && chan1_block == Rhs.chan1_block; }
bool operator!=(const BC5Block &Rhs) const { return !(Rhs == *this); }
2021-02-15 03:01:41 +00:00
};
2021-03-14 08:59:16 +00:00
} // namespace quicktex::s3tc