mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-23 21:43:04 +00:00
shader: Implement SampleMask
This commit is contained in:
parent
95815a3883
commit
80940b1706
11 changed files with 22 additions and 2 deletions
|
@ -1179,7 +1179,10 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
|
|||
if (info.stores_frag_depth) {
|
||||
frag_depth = DefineOutput(*this, F32[1], std::nullopt);
|
||||
Decorate(frag_depth, spv::Decoration::BuiltIn, spv::BuiltIn::FragDepth);
|
||||
Name(frag_depth, "frag_depth");
|
||||
}
|
||||
if (info.stores_sample_mask) {
|
||||
sample_mask = DefineOutput(*this, U32[1], std::nullopt);
|
||||
Decorate(sample_mask, spv::Decoration::BuiltIn, spv::BuiltIn::SampleMask);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -215,6 +215,7 @@ public:
|
|||
std::array<Id, 30> patches{};
|
||||
|
||||
std::array<Id, 8> frag_color{};
|
||||
Id sample_mask{};
|
||||
Id frag_depth{};
|
||||
|
||||
std::vector<Id> interfaces;
|
||||
|
|
|
@ -58,6 +58,7 @@ void EmitSetAttributeIndexed(EmitContext& ctx, Id offset, Id value, Id vertex);
|
|||
Id EmitGetPatch(EmitContext& ctx, IR::Patch patch);
|
||||
void EmitSetPatch(EmitContext& ctx, IR::Patch patch, Id value);
|
||||
void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, Id value);
|
||||
void EmitSetSampleMask(EmitContext& ctx, Id value);
|
||||
void EmitSetFragDepth(EmitContext& ctx, Id value);
|
||||
void EmitGetZFlag(EmitContext& ctx);
|
||||
void EmitGetSFlag(EmitContext& ctx);
|
||||
|
|
|
@ -343,6 +343,10 @@ void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, Id value) {
|
|||
ctx.OpStore(pointer, value);
|
||||
}
|
||||
|
||||
void EmitSetSampleMask(EmitContext& ctx, Id value) {
|
||||
ctx.OpStore(ctx.sample_mask, value);
|
||||
}
|
||||
|
||||
void EmitSetFragDepth(EmitContext& ctx, Id value) {
|
||||
ctx.OpStore(ctx.frag_depth, value);
|
||||
}
|
||||
|
|
|
@ -343,6 +343,10 @@ void IREmitter::SetFragColor(u32 index, u32 component, const F32& value) {
|
|||
Inst(Opcode::SetFragColor, Imm32(index), Imm32(component), value);
|
||||
}
|
||||
|
||||
void IREmitter::SetSampleMask(const U32& value) {
|
||||
Inst(Opcode::SetSampleMask, value);
|
||||
}
|
||||
|
||||
void IREmitter::SetFragDepth(const F32& value) {
|
||||
Inst(Opcode::SetFragDepth, value);
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
void SetPatch(Patch patch, const F32& value);
|
||||
|
||||
void SetFragColor(u32 index, u32 component, const F32& value);
|
||||
void SetSampleMask(const U32& value);
|
||||
void SetFragDepth(const F32& value);
|
||||
|
||||
[[nodiscard]] U32 WorkgroupIdX();
|
||||
|
|
|
@ -75,6 +75,7 @@ bool Inst::MayHaveSideEffects() const noexcept {
|
|||
case Opcode::SetAttributeIndexed:
|
||||
case Opcode::SetPatch:
|
||||
case Opcode::SetFragColor:
|
||||
case Opcode::SetSampleMask:
|
||||
case Opcode::SetFragDepth:
|
||||
case Opcode::WriteGlobalU8:
|
||||
case Opcode::WriteGlobalS8:
|
||||
|
|
|
@ -51,6 +51,7 @@ OPCODE(SetAttributeIndexed, Void, U32,
|
|||
OPCODE(GetPatch, F32, Patch, )
|
||||
OPCODE(SetPatch, Void, Patch, F32, )
|
||||
OPCODE(SetFragColor, Void, U32, U32, F32, )
|
||||
OPCODE(SetSampleMask, Void, U32, )
|
||||
OPCODE(SetFragDepth, Void, F32, )
|
||||
OPCODE(GetZFlag, U1, Void, )
|
||||
OPCODE(GetSFlag, U1, Void, )
|
||||
|
|
|
@ -22,7 +22,7 @@ void ExitFragment(TranslatorVisitor& v) {
|
|||
}
|
||||
}
|
||||
if (sph.ps.omap.sample_mask != 0) {
|
||||
throw NotImplementedException("Sample mask");
|
||||
v.ir.SetSampleMask(v.X(src_reg));
|
||||
}
|
||||
if (sph.ps.omap.depth != 0) {
|
||||
v.ir.SetFragDepth(v.F(src_reg + 1));
|
||||
|
|
|
@ -403,6 +403,9 @@ void VisitUsages(Info& info, IR::Inst& inst) {
|
|||
case IR::Opcode::SetFragColor:
|
||||
info.stores_frag_color[inst.Arg(0).U32()] = true;
|
||||
break;
|
||||
case IR::Opcode::SetSampleMask:
|
||||
info.stores_sample_mask = true;
|
||||
break;
|
||||
case IR::Opcode::SetFragDepth:
|
||||
info.stores_frag_depth = true;
|
||||
break;
|
||||
|
|
|
@ -118,6 +118,7 @@ struct Info {
|
|||
bool loads_indexed_attributes{};
|
||||
|
||||
std::array<bool, 8> stores_frag_color{};
|
||||
bool stores_sample_mask{};
|
||||
bool stores_frag_depth{};
|
||||
std::array<bool, 32> stores_generics{};
|
||||
bool stores_position{};
|
||||
|
|
Loading…
Reference in a new issue