mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
Merge branch 'master' into dynapica
This commit is contained in:
commit
bf125bf2cf
9 changed files with 180 additions and 147 deletions
|
@ -158,14 +158,14 @@ private:
|
|||
bool negate;
|
||||
|
||||
if constexpr (sourceIndex == 1) { // SRC1
|
||||
negate = ((opDescriptor >> 4) & 1) != 0;
|
||||
compSwizzle = (opDescriptor >> 5) & 0xff;
|
||||
negate = (Helpers::getBit<4>(opDescriptor)) != 0;
|
||||
compSwizzle = Helpers::getBits<5, 8>(opDescriptor);
|
||||
} else if constexpr (sourceIndex == 2) { // SRC2
|
||||
negate = ((opDescriptor >> 13) & 1) != 0;
|
||||
compSwizzle = (opDescriptor >> 14) & 0xff;
|
||||
negate = (Helpers::getBit<13>(opDescriptor)) != 0;
|
||||
compSwizzle = Helpers::getBits<14, 8>(opDescriptor);
|
||||
} else if constexpr (sourceIndex == 3) { // SRC3
|
||||
negate = ((opDescriptor >> 22) & 1) != 0;
|
||||
compSwizzle = (opDescriptor >> 23) & 0xff;
|
||||
negate = (Helpers::getBit<22>(opDescriptor)) != 0;
|
||||
compSwizzle = Helpers::getBits<23, 8>(opDescriptor);
|
||||
}
|
||||
|
||||
// Iterate through every component of the swizzled vector in reverse order
|
||||
|
@ -265,9 +265,9 @@ public:
|
|||
void uploadIntUniform(int index, u32 word) {
|
||||
auto& u = intUniforms[index];
|
||||
u.x() = word & 0xff;
|
||||
u.y() = (word >> 8) & 0xff;
|
||||
u.z() = (word >> 16) & 0xff;
|
||||
u.w() = (word >> 24) & 0xff;
|
||||
u.y() = Helpers::getBits<8, 8>(word);
|
||||
u.z() = Helpers::getBits<16, 8>(word);
|
||||
u.w() = Helpers::getBits<24, 8>(word);
|
||||
}
|
||||
|
||||
void run();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <cstdarg>
|
||||
#include <climits>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
@ -90,6 +91,30 @@ namespace Helpers {
|
|||
return (u16) (temp << bitsToShift >> bitsToShift);
|
||||
}
|
||||
|
||||
/// Create a mask with `count` number of one bits.
|
||||
template<typename T, usize count>
|
||||
static constexpr T ones () {
|
||||
constexpr usize bitsize = CHAR_BIT * sizeof(T);
|
||||
static_assert(count <= bitsize, "count larger than bitsize of T");
|
||||
|
||||
if (count == T(0)) {
|
||||
return T(0);
|
||||
}
|
||||
return static_cast<T>(~static_cast<T>(0)) >> (bitsize - count);
|
||||
}
|
||||
|
||||
/// Extract bits from an integer-type
|
||||
template<usize offset, typename T>
|
||||
static constexpr T getBit (T value) {
|
||||
return (value >> offset) & T(1);
|
||||
}
|
||||
|
||||
/// Extract bits from an integer-type
|
||||
template<usize offset, usize bits, typename T>
|
||||
static constexpr T getBits (T value) {
|
||||
return (value >> offset) & ones<T, bits>();
|
||||
}
|
||||
|
||||
/// Check if a bit "bit" of value is set
|
||||
static constexpr bool isBitSet (u32 value, int bit) {
|
||||
return (value >> bit) & 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue