Fix bitfield functions.
This commit is contained in:
parent
f4749df09a
commit
6801af4dce
19
reference/shaders/comp/bitfield.comp
Normal file
19
reference/shaders/comp/bitfield.comp
Normal file
@ -0,0 +1,19 @@
|
||||
#version 310 es
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
int signed_value = 0;
|
||||
uint unsigned_value = 0u;
|
||||
int s = bitfieldExtract(signed_value, 5, 20);
|
||||
uint u = bitfieldExtract(unsigned_value, 6, 21);
|
||||
s = bitfieldInsert(s, 40, 5, 4);
|
||||
u = bitfieldInsert(u, 60u, 5, 4);
|
||||
u = bitfieldReverse(u);
|
||||
s = bitfieldReverse(s);
|
||||
int v0 = bitCount(u);
|
||||
int v1 = bitCount(s);
|
||||
int v2 = findMSB(u);
|
||||
int v3 = findMSB(s);
|
||||
}
|
||||
|
21
shaders/comp/bitfield.comp
Normal file
21
shaders/comp/bitfield.comp
Normal file
@ -0,0 +1,21 @@
|
||||
#version 310 es
|
||||
|
||||
void main()
|
||||
{
|
||||
int signed_value = 0;
|
||||
uint unsigned_value = 0u;
|
||||
|
||||
int s = bitfieldExtract(signed_value, 5, 20);
|
||||
uint u = bitfieldExtract(unsigned_value, 6, 21);
|
||||
s = bitfieldInsert(s, 40, 5, 4);
|
||||
u = bitfieldInsert(u, 60u, 5, 4);
|
||||
|
||||
u = bitfieldReverse(u);
|
||||
s = bitfieldReverse(s);
|
||||
|
||||
int v0 = bitCount(u);
|
||||
int v1 = bitCount(s);
|
||||
|
||||
int v2 = findMSB(u);
|
||||
int v3 = findMSB(s);
|
||||
}
|
@ -5103,12 +5103,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
|
||||
// Bitfield
|
||||
case OpBitFieldInsert:
|
||||
// TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary.
|
||||
QFOP(bitfieldInsert);
|
||||
break;
|
||||
|
||||
case OpBitFieldSExtract:
|
||||
case OpBitFieldUExtract:
|
||||
QFOP(bitfieldExtract);
|
||||
// TODO: The signedness of inputs is strict in GLSL, but not in SPIR-V, bitcast if necessary.
|
||||
TFOP(bitfieldExtract);
|
||||
break;
|
||||
|
||||
case OpBitReverse:
|
||||
|
Loading…
Reference in New Issue
Block a user