mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-29 08:41:20 +00:00
shader: share descriptor dispatch for scalar and wide buffer stores
This commit is contained in:
1 parent
b6da068313
commit
7468e4f60a
1 file changed
+21
-31
@@ -851,20 +851,6 @@ void StoreFormattedPrepared(ValueEmitContext& ctx, const IR::Inst& inst,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormattedStore(ValueEmitContext& ctx, const IR::Inst& inst, const IR::MemoryInfo& mem) {
|
|
||||||
EmitIfCondition(ctx.state, ctx.Arg(inst, inst.NumArgs() - 1), [&]() {
|
|
||||||
const auto data = ctx.Arg(inst, inst.NumArgs() - 2);
|
|
||||||
EmitBufferAccess(ctx, inst, mem, 0u, [&](const auto& selected, const auto& resource) {
|
|
||||||
const auto info = Format::GetFormatInfo(BufferFormat(ctx, selected));
|
|
||||||
if (info.type == Format::ComponentType::Unknown) {
|
|
||||||
StoreWordPrepared(ctx, inst, RebaseRawComponent(selected, 0u), resource, data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StoreFormattedPrepared(ctx, inst, selected, resource, info, data, 1u);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t LoadIndirectScalarBuffer(ValueEmitContext& ctx, const IR::Inst& inst) {
|
uint32_t LoadIndirectScalarBuffer(ValueEmitContext& ctx, const IR::Inst& inst) {
|
||||||
auto& state = ctx.state;
|
auto& state = ctx.state;
|
||||||
const auto& handle = *inst.Arg(0).ResolveInstruction();
|
const auto& handle = *inst.Arg(0).ResolveInstruction();
|
||||||
@@ -1104,24 +1090,28 @@ uint32_t LoadBuffer(ValueEmitContext& ctx, const IR::Inst& inst, uint32_t compon
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreWideBuffer(ValueEmitContext& ctx, const IR::Inst& inst, uint32_t components) {
|
void StoreBuffer(ValueEmitContext& ctx, const IR::Inst& inst, uint32_t components) {
|
||||||
auto& state = ctx.state;
|
auto& state = ctx.state;
|
||||||
EmitIfCondition(state, ctx.Arg(inst, inst.NumArgs() - 1), [&]() {
|
EmitIfCondition(state, ctx.Arg(inst, inst.NumArgs() - 1), [&]() {
|
||||||
const auto mem = ctx.Memory(inst);
|
const auto mem = ctx.Memory(inst);
|
||||||
const auto resource = PrepareMemoryResourceAccess(state, mem);
|
|
||||||
const auto composite = ctx.Arg(inst, inst.NumArgs() - 2);
|
const auto composite = ctx.Arg(inst, inst.NumArgs() - 2);
|
||||||
const auto info = Format::GetFormatInfo(
|
EmitBufferAccess(ctx, inst, mem, 0u, [&](const auto& selected, const auto& resource) {
|
||||||
mem.formatted ? BufferFormat(ctx, mem) : Prospero::BufferFormat::kInvalid);
|
const auto info = Format::GetFormatInfo(
|
||||||
if (info.type != Format::ComponentType::Unknown) {
|
selected.formatted ? BufferFormat(ctx, selected) : Prospero::BufferFormat::kInvalid);
|
||||||
StoreFormattedPrepared(ctx, inst, mem, resource, info, composite, components);
|
if (info.type != Format::ComponentType::Unknown) {
|
||||||
return;
|
StoreFormattedPrepared(ctx, inst, selected, resource, info, composite, components);
|
||||||
}
|
return;
|
||||||
for (uint32_t component = 0; component < components; component++) {
|
}
|
||||||
const auto data = state.builder.AllocateId();
|
for (uint32_t component = 0; component < components; component++) {
|
||||||
state.builder.AddFunction(spv::OpCompositeExtract, TypeU32(state), data, composite,
|
auto data = composite;
|
||||||
component);
|
if (components != 1u) {
|
||||||
StoreWordPrepared(ctx, inst, RebaseRawComponent(mem, component), resource, data);
|
data = state.builder.AllocateId();
|
||||||
}
|
state.builder.AddFunction(spv::OpCompositeExtract, TypeU32(state), data, composite,
|
||||||
|
component);
|
||||||
|
}
|
||||||
|
StoreWordPrepared(ctx, inst, RebaseRawComponent(selected, component), resource, data);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1547,11 +1537,11 @@ void EmitStoreMemory(ValueEmitContext& ctx, const IR::Inst& inst) {
|
|||||||
if (mem.kind == IR::ResourceKind::FlatLocal)
|
if (mem.kind == IR::ResourceKind::FlatLocal)
|
||||||
StoreLocalFlat(ctx, inst);
|
StoreLocalFlat(ctx, inst);
|
||||||
else if (buffer_components > 1u)
|
else if (buffer_components > 1u)
|
||||||
StoreWideBuffer(ctx, inst, buffer_components);
|
StoreBuffer(ctx, inst, buffer_components);
|
||||||
else if (shared_components > 1u)
|
else if (shared_components > 1u)
|
||||||
StoreWideShared(ctx, inst, shared_components);
|
StoreWideShared(ctx, inst, shared_components);
|
||||||
else if (op == IR::ValueOpcode::StoreBufferU32 && mem.formatted)
|
else if (op == IR::ValueOpcode::StoreBufferU32 && mem.formatted)
|
||||||
FormattedStore(ctx, inst, mem);
|
StoreBuffer(ctx, inst, 1u);
|
||||||
else if (type == IR::Type::U8)
|
else if (type == IR::Type::U8)
|
||||||
StoreSubword(ctx, inst, mem, 8);
|
StoreSubword(ctx, inst, mem, 8);
|
||||||
else if (type == IR::Type::U16)
|
else if (type == IR::Type::U16)
|
||||||
|
|||||||
Reference in new issue
Block a user