Change BitfieldExtract to use a pointer to the bitfield member

This commit is contained in:
Pokechu22
2021-04-10 19:34:20 -07:00
parent e7f68cf850
commit 0f7c9ef767
8 changed files with 164 additions and 79 deletions

View File

@ -10,6 +10,7 @@
#include <fmt/format.h>
#include "Common/CommonTypes.h"
#include "Common/TypeUtils.h"
class ShaderCode;
enum class APIType;
@ -29,10 +30,11 @@ void WriteVertexLighting(ShaderCode& out, APIType api_type, std::string_view wor
std::string_view out_color_1_var);
// bitfieldExtract generator for BitField types
template <typename T>
std::string BitfieldExtract(std::string_view source, T type)
template <auto ptr_to_bitfield_member>
std::string BitfieldExtract(std::string_view source)
{
return fmt::format("bitfieldExtract({}, {}, {})", source, static_cast<u32>(type.StartBit()),
static_cast<u32>(type.NumBits()));
using BitFieldT = Common::MemberType<ptr_to_bitfield_member>;
return fmt::format("bitfieldExtract({}, {}, {})", source, static_cast<u32>(BitFieldT::StartBit()),
static_cast<u32>(BitFieldT::NumBits()));
}
} // namespace UberShader