mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 10:04:39 +00:00
spirv: Merge ReadConstBuffer again
template function only has 1 user now
This commit is contained in:
parent
94da2786d3
commit
ec462bbcba
@ -148,27 +148,21 @@ Id EmitReadConst(EmitContext& ctx, IR::Inst* inst, Id addr, Id offset) {
|
||||
}
|
||||
}
|
||||
|
||||
template <PointerType type>
|
||||
Id ReadConstBuffer(EmitContext& ctx, u32 handle, Id index) {
|
||||
Id EmitReadConstBuffer(EmitContext& ctx, u32 handle, Id index) {
|
||||
const auto& buffer = ctx.buffers[handle];
|
||||
if (const Id offset = buffer.Offset(PointerSize::B32); Sirit::ValidId(offset)) {
|
||||
index = ctx.OpIAdd(ctx.U32[1], index, offset);
|
||||
}
|
||||
const auto [id, pointer_type] = buffer.Alias(type);
|
||||
const auto value_type = type == PointerType::U32 ? ctx.U32[1] : ctx.F32[1];
|
||||
const auto [id, pointer_type] = buffer.Alias(PointerType::U32);
|
||||
const Id ptr{ctx.OpAccessChain(pointer_type, id, ctx.u32_zero_value, index)};
|
||||
const Id result{ctx.OpLoad(value_type, ptr)};
|
||||
const Id result{ctx.OpLoad(ctx.U32[1], ptr)};
|
||||
if (const Id size = buffer.Size(PointerSize::B32); Sirit::ValidId(size)) {
|
||||
const Id in_bounds = ctx.OpULessThan(ctx.U1[1], index, size);
|
||||
return ctx.OpSelect(value_type, in_bounds, result, ctx.u32_zero_value);
|
||||
return ctx.OpSelect(ctx.U32[1], in_bounds, result, ctx.u32_zero_value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Id EmitReadConstBuffer(EmitContext& ctx, u32 handle, Id index) {
|
||||
return ReadConstBuffer<PointerType::U32>(ctx, handle, index);
|
||||
}
|
||||
|
||||
static Id EmitGetAttributeForGeometry(EmitContext& ctx, IR::Attribute attr, u32 comp, u32 index) {
|
||||
if (IR::IsPosition(attr)) {
|
||||
ASSERT(attr == IR::Attribute::Position0);
|
||||
|
Loading…
Reference in New Issue
Block a user