diff options
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 3bf4c6a9e..105602ccf 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -45,6 +45,8 @@ ArgType Arg(EmitContext& ctx, const IR::Value& arg) { | |||
| 45 | return arg.Label(); | 45 | return arg.Label(); |
| 46 | } else if constexpr (std::is_same_v<ArgType, IR::Attribute>) { | 46 | } else if constexpr (std::is_same_v<ArgType, IR::Attribute>) { |
| 47 | return arg.Attribute(); | 47 | return arg.Attribute(); |
| 48 | } else if constexpr (std::is_same_v<ArgType, IR::Patch>) { | ||
| 49 | return arg.Patch(); | ||
| 48 | } else if constexpr (std::is_same_v<ArgType, IR::Reg>) { | 50 | } else if constexpr (std::is_same_v<ArgType, IR::Reg>) { |
| 49 | return arg.Reg(); | 51 | return arg.Reg(); |
| 50 | } | 52 | } |
| @@ -120,6 +122,30 @@ Id DefineMain(EmitContext& ctx, IR::Program& program) { | |||
| 120 | return main; | 122 | return main; |
| 121 | } | 123 | } |
| 122 | 124 | ||
| 125 | spv::ExecutionMode ExecutionMode(TessPrimitive primitive) { | ||
| 126 | switch (primitive) { | ||
| 127 | case TessPrimitive::Isolines: | ||
| 128 | return spv::ExecutionMode::Isolines; | ||
| 129 | case TessPrimitive::Triangles: | ||
| 130 | return spv::ExecutionMode::Triangles; | ||
| 131 | case TessPrimitive::Quads: | ||
| 132 | return spv::ExecutionMode::Quads; | ||
| 133 | } | ||
| 134 | throw InvalidArgument("Tessellation primitive {}", primitive); | ||
| 135 | } | ||
| 136 | |||
| 137 | spv::ExecutionMode ExecutionMode(TessSpacing spacing) { | ||
| 138 | switch (spacing) { | ||
| 139 | case TessSpacing::Equal: | ||
| 140 | return spv::ExecutionMode::SpacingEqual; | ||
| 141 | case TessSpacing::FractionalOdd: | ||
| 142 | return spv::ExecutionMode::SpacingFractionalOdd; | ||
| 143 | case TessSpacing::FractionalEven: | ||
| 144 | return spv::ExecutionMode::SpacingFractionalEven; | ||
| 145 | } | ||
| 146 | throw InvalidArgument("Tessellation spacing {}", spacing); | ||
| 147 | } | ||
| 148 | |||
| 123 | void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) { | 149 | void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) { |
| 124 | const std::span interfaces(ctx.interfaces.data(), ctx.interfaces.size()); | 150 | const std::span interfaces(ctx.interfaces.data(), ctx.interfaces.size()); |
| 125 | spv::ExecutionModel execution_model{}; | 151 | spv::ExecutionModel execution_model{}; |
| @@ -134,6 +160,19 @@ void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) { | |||
| 134 | case Stage::VertexB: | 160 | case Stage::VertexB: |
| 135 | execution_model = spv::ExecutionModel::Vertex; | 161 | execution_model = spv::ExecutionModel::Vertex; |
| 136 | break; | 162 | break; |
| 163 | case Stage::TessellationControl: | ||
| 164 | execution_model = spv::ExecutionModel::TessellationControl; | ||
| 165 | ctx.AddCapability(spv::Capability::Tessellation); | ||
| 166 | ctx.AddExecutionMode(main, spv::ExecutionMode::OutputVertices, program.invocations); | ||
| 167 | break; | ||
| 168 | case Stage::TessellationEval: | ||
| 169 | execution_model = spv::ExecutionModel::TessellationEvaluation; | ||
| 170 | ctx.AddCapability(spv::Capability::Tessellation); | ||
| 171 | ctx.AddExecutionMode(main, ExecutionMode(ctx.profile.tess_primitive)); | ||
| 172 | ctx.AddExecutionMode(main, ExecutionMode(ctx.profile.tess_spacing)); | ||
| 173 | ctx.AddExecutionMode(main, ctx.profile.tess_clockwise ? spv::ExecutionMode::VertexOrderCw | ||
| 174 | : spv::ExecutionMode::VertexOrderCcw); | ||
| 175 | break; | ||
| 137 | case Stage::Geometry: | 176 | case Stage::Geometry: |
| 138 | execution_model = spv::ExecutionModel::Geometry; | 177 | execution_model = spv::ExecutionModel::Geometry; |
| 139 | ctx.AddCapability(spv::Capability::Geometry); | 178 | ctx.AddCapability(spv::Capability::Geometry); |