summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/ShaderGenCommon.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-08-26 13:58:45 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-11-17 20:04:33 -0800
commitd2041b4c2a8562073ab905e2aea3b05c678aa962 (patch)
treeceaf1bbc79e519a3b45dd24172d3aeda08eea218 /Source/Core/VideoCommon/ShaderGenCommon.cpp
parent555a93057c07f045cc71c4652c54eebb990021b7 (diff)
VideoCommon: Add signed version of BitfieldExtract
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.cpp')
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp
index cbc17f0772..72a7e0d14f 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.cpp
+++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp
@@ -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");
}
}