shader: Implement NDC [-1, 1], attribute types and default varying initialization

This commit is contained in:
ReinUsesLisp 2021-03-24 01:33:45 -03:00 committed by ameerj
parent 1d2db78398
commit 68a9505d8a
15 changed files with 186 additions and 43 deletions

View file

@ -92,6 +92,14 @@ void IREmitter::DemoteToHelperInvocation(Block* continue_label) {
Inst(Opcode::DemoteToHelperInvocation, continue_label);
}
void IREmitter::Prologue() {
Inst(Opcode::Prologue);
}
void IREmitter::Epilogue() {
Inst(Opcode::Epilogue);
}
U32 IREmitter::GetReg(IR::Reg reg) {
return Inst<U32>(Opcode::GetRegister, reg);
}

View file

@ -39,6 +39,9 @@ public:
void Return();
void DemoteToHelperInvocation(Block* continue_label);
void Prologue();
void Epilogue();
[[nodiscard]] U32 GetReg(IR::Reg reg);
void SetReg(IR::Reg reg, const U32& value);

View file

@ -56,6 +56,8 @@ bool Inst::MayHaveSideEffects() const noexcept {
case Opcode::SelectionMerge:
case Opcode::Return:
case Opcode::DemoteToHelperInvocation:
case Opcode::Prologue:
case Opcode::Epilogue:
case Opcode::SetAttribute:
case Opcode::SetAttributeIndexed:
case Opcode::SetFragColor:

View file

@ -15,6 +15,10 @@ OPCODE(SelectionMerge, Void, Labe
OPCODE(Return, Void, )
OPCODE(DemoteToHelperInvocation, Void, Label, )
// Special operations
OPCODE(Prologue, Void, )
OPCODE(Epilogue, Void, )
// Context getters/setters
OPCODE(GetRegister, U32, Reg, )
OPCODE(SetRegister, Void, Reg, U32, )

View file

@ -634,6 +634,9 @@ public:
: stmt_pool{stmt_pool_}, inst_pool{inst_pool_}, block_pool{block_pool_}, env{env_},
block_list{block_list_} {
Visit(root_stmt, nullptr, nullptr);
IR::IREmitter ir{*block_list.front()};
ir.Prologue();
}
private:
@ -734,7 +737,9 @@ private:
current_block = block_pool.Create(inst_pool);
block_list.push_back(current_block);
}
IR::IREmitter{*current_block}.Return();
IR::IREmitter ir{*current_block};
ir.Epilogue();
ir.Return();
current_block = nullptr;
break;
}