mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 06:38:34 +02:00
Use shift operations for dynamic bit extraction for better performance
This commit is contained in:
parent
a8e40bac07
commit
e6cd1033e9
1 changed files with 6 additions and 4 deletions
|
|
@ -285,11 +285,13 @@ Id IsScaled(EmitContext& ctx, const IR::Value& index, Id member_index, u32 base_
|
||||||
if (base_index != 0) {
|
if (base_index != 0) {
|
||||||
index_value = ctx.OpIAdd(ctx.U32[1], index_value, ctx.Const(base_index));
|
index_value = ctx.OpIAdd(ctx.U32[1], index_value, ctx.Const(base_index));
|
||||||
}
|
}
|
||||||
const Id word_index{ctx.OpUDiv(ctx.U32[1], index_value, ctx.Const(32u))};
|
const Id word_index{ctx.OpShiftRightLogical(ctx.U32[1], index_value, ctx.Const(5u))};
|
||||||
const Id pointer{ctx.OpAccessChain(push_constant_u32, ctx.rescaling_push_constants, member_index, word_index)};
|
|
||||||
const Id word{ctx.OpLoad(ctx.U32[1], pointer)};
|
|
||||||
const Id bit_index{ctx.OpBitwiseAnd(ctx.U32[1], index_value, ctx.Const(31u))};
|
const Id bit_index{ctx.OpBitwiseAnd(ctx.U32[1], index_value, ctx.Const(31u))};
|
||||||
bit = ctx.OpBitFieldUExtract(ctx.U32[1], word, bit_index, ctx.Const(1u));
|
const Id pointer{ctx.OpAccessChain(push_constant_u32, ctx.rescaling_push_constants,
|
||||||
|
member_index, word_index)};
|
||||||
|
const Id word{ctx.OpLoad(ctx.U32[1], pointer)};
|
||||||
|
const Id bit_index_mask{ctx.OpShiftLeft(ctx.U32[1], ctx.Const(1u), bit_index)};
|
||||||
|
bit = ctx.OpBitwiseAnd(ctx.U32[1], word, bit_index_mask);
|
||||||
}
|
}
|
||||||
return ctx.OpINotEqual(ctx.U1, bit, ctx.u32_zero_value);
|
return ctx.OpINotEqual(ctx.U1, bit, ctx.u32_zero_value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue