shader: Add partial rasterizer integration
This commit is contained in:
parent
72990df7ba
commit
260743f371
54 changed files with 1929 additions and 568 deletions
|
@ -13,7 +13,7 @@ bool IsGeneric(Attribute attribute) noexcept {
|
|||
return attribute >= Attribute::Generic0X && attribute <= Attribute::Generic31X;
|
||||
}
|
||||
|
||||
int GenericAttributeIndex(Attribute attribute) {
|
||||
u32 GenericAttributeIndex(Attribute attribute) {
|
||||
if (!IsGeneric(attribute)) {
|
||||
throw InvalidArgument("Attribute is not generic {}", attribute);
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ enum class Attribute : u64 {
|
|||
|
||||
[[nodiscard]] bool IsGeneric(Attribute attribute) noexcept;
|
||||
|
||||
[[nodiscard]] int GenericAttributeIndex(Attribute attribute);
|
||||
[[nodiscard]] u32 GenericAttributeIndex(Attribute attribute);
|
||||
|
||||
[[nodiscard]] std::string NameOf(Attribute attribute);
|
||||
|
||||
|
|
|
@ -82,6 +82,12 @@ void IREmitter::Return() {
|
|||
Inst(Opcode::Return);
|
||||
}
|
||||
|
||||
void IREmitter::DemoteToHelperInvocation(Block* continue_label) {
|
||||
block->SetBranch(continue_label);
|
||||
continue_label->AddImmediatePredecessor(block);
|
||||
Inst(Opcode::DemoteToHelperInvocation, continue_label);
|
||||
}
|
||||
|
||||
U32 IREmitter::GetReg(IR::Reg reg) {
|
||||
return Inst<U32>(Opcode::GetRegister, reg);
|
||||
}
|
||||
|
@ -248,6 +254,14 @@ void IREmitter::SetAttribute(IR::Attribute attribute, const F32& value) {
|
|||
Inst(Opcode::SetAttribute, attribute, value);
|
||||
}
|
||||
|
||||
void IREmitter::SetFragColor(u32 index, u32 component, const F32& value) {
|
||||
Inst(Opcode::SetFragColor, Imm32(index), Imm32(component), value);
|
||||
}
|
||||
|
||||
void IREmitter::SetFragDepth(const F32& value) {
|
||||
Inst(Opcode::SetFragDepth, value);
|
||||
}
|
||||
|
||||
U32 IREmitter::WorkgroupIdX() {
|
||||
return U32{CompositeExtract(Inst(Opcode::WorkgroupId), 0)};
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
void LoopMerge(Block* merge_block, Block* continue_target);
|
||||
void SelectionMerge(Block* merge_block);
|
||||
void Return();
|
||||
void DemoteToHelperInvocation(Block* continue_label);
|
||||
|
||||
[[nodiscard]] U32 GetReg(IR::Reg reg);
|
||||
void SetReg(IR::Reg reg, const U32& value);
|
||||
|
@ -67,6 +68,9 @@ public:
|
|||
[[nodiscard]] F32 GetAttribute(IR::Attribute attribute);
|
||||
void SetAttribute(IR::Attribute attribute, const F32& value);
|
||||
|
||||
void SetFragColor(u32 index, u32 component, const F32& value);
|
||||
void SetFragDepth(const F32& value);
|
||||
|
||||
[[nodiscard]] U32 WorkgroupIdX();
|
||||
[[nodiscard]] U32 WorkgroupIdY();
|
||||
[[nodiscard]] U32 WorkgroupIdZ();
|
||||
|
|
|
@ -55,8 +55,11 @@ bool Inst::MayHaveSideEffects() const noexcept {
|
|||
case Opcode::LoopMerge:
|
||||
case Opcode::SelectionMerge:
|
||||
case Opcode::Return:
|
||||
case Opcode::DemoteToHelperInvocation:
|
||||
case Opcode::SetAttribute:
|
||||
case Opcode::SetAttributeIndexed:
|
||||
case Opcode::SetFragColor:
|
||||
case Opcode::SetFragDepth:
|
||||
case Opcode::WriteGlobalU8:
|
||||
case Opcode::WriteGlobalS8:
|
||||
case Opcode::WriteGlobalU16:
|
||||
|
|
|
@ -13,6 +13,7 @@ OPCODE(BranchConditional, Void, U1,
|
|||
OPCODE(LoopMerge, Void, Label, Label, )
|
||||
OPCODE(SelectionMerge, Void, Label, )
|
||||
OPCODE(Return, Void, )
|
||||
OPCODE(DemoteToHelperInvocation, Void, Label, )
|
||||
|
||||
// Context getters/setters
|
||||
OPCODE(GetRegister, U32, Reg, )
|
||||
|
@ -28,10 +29,12 @@ OPCODE(GetCbufS16, U32, U32,
|
|||
OPCODE(GetCbufU32, U32, U32, U32, )
|
||||
OPCODE(GetCbufF32, F32, U32, U32, )
|
||||
OPCODE(GetCbufU64, U64, U32, U32, )
|
||||
OPCODE(GetAttribute, U32, Attribute, )
|
||||
OPCODE(SetAttribute, Void, Attribute, U32, )
|
||||
OPCODE(GetAttributeIndexed, U32, U32, )
|
||||
OPCODE(SetAttributeIndexed, Void, U32, U32, )
|
||||
OPCODE(GetAttribute, F32, Attribute, )
|
||||
OPCODE(SetAttribute, Void, Attribute, F32, )
|
||||
OPCODE(GetAttributeIndexed, F32, U32, )
|
||||
OPCODE(SetAttributeIndexed, Void, U32, F32, )
|
||||
OPCODE(SetFragColor, Void, U32, U32, F32, )
|
||||
OPCODE(SetFragDepth, Void, F32, )
|
||||
OPCODE(GetZFlag, U1, Void, )
|
||||
OPCODE(GetSFlag, U1, Void, )
|
||||
OPCODE(GetCFlag, U1, Void, )
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||
#include "shader_recompiler/shader_info.h"
|
||||
#include "shader_recompiler/stage.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
|
@ -17,6 +18,7 @@ struct Program {
|
|||
BlockList blocks;
|
||||
BlockList post_order_blocks;
|
||||
Info info;
|
||||
Stage stage{};
|
||||
};
|
||||
|
||||
[[nodiscard]] std::string DumpProgram(const Program& program);
|
||||
|
|
|
@ -293,12 +293,12 @@ constexpr size_t NUM_REGS = 256;
|
|||
return reg + (-num);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Reg operator++(Reg& reg) {
|
||||
constexpr Reg operator++(Reg& reg) {
|
||||
reg = reg + 1;
|
||||
return reg;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Reg operator++(Reg& reg, int) {
|
||||
constexpr Reg operator++(Reg& reg, int) {
|
||||
const Reg copy{reg};
|
||||
reg = reg + 1;
|
||||
return copy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue