mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
VideoCommon: Add signed version of BitfieldExtract
This commit is contained in:
@ -120,6 +120,12 @@ void WriteBitfieldExtractHeader(ShaderCode& out, APIType api_type,
|
||||
" uint mask = uint((1 << size) - 1);\n"
|
||||
" return uint(val >> off) & mask;\n"
|
||||
"}}\n\n");
|
||||
out.Write("int bitfieldExtract(int val, int off, int size) {{\n"
|
||||
" // This built-in function is only supported in OpenGL 4.0+ and ES 3.1+\n"
|
||||
" // Microsoft's HLSL compiler automatically optimises this to a bitfield extract "
|
||||
"instruction.\n"
|
||||
" return ((val << (32 - size - off)) >> (32 - size));\n"
|
||||
"}}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,8 @@ template <auto ptr_to_bitfield_member>
|
||||
std::string BitfieldExtract(std::string_view source)
|
||||
{
|
||||
using BitFieldT = Common::MemberType<ptr_to_bitfield_member>;
|
||||
return fmt::format("bitfieldExtract({}, {}, {})", source, static_cast<u32>(BitFieldT::StartBit()),
|
||||
return fmt::format("bitfieldExtract({}({}), {}, {})", BitFieldT::IsSigned() ? "int" : "uint",
|
||||
source, static_cast<u32>(BitFieldT::StartBit()),
|
||||
static_cast<u32>(BitFieldT::NumBits()));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user