diff options
| author | 2021-05-31 04:20:09 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:34 -0400 | |
| commit | cf9f88e5a7b884a417c91725b5cb9e500792e206 (patch) | |
| tree | 46407b602055305cb6e7238cfe33e75ceaeb6e6e /src/shader_recompiler/backend/glasm | |
| parent | shader: Track legacy varyings (diff) | |
| download | yuzu-cf9f88e5a7b884a417c91725b5cb9e500792e206.tar.gz yuzu-cf9f88e5a7b884a417c91725b5cb9e500792e206.tar.xz yuzu-cf9f88e5a7b884a417c91725b5cb9e500792e206.zip | |
glasm: Implement legacy varyings
Diffstat (limited to 'src/shader_recompiler/backend/glasm')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 9ad668b86..3236def25 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |||
| @@ -90,14 +90,20 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 90 | ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle); | 90 | ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle); |
| 91 | } | 91 | } |
| 92 | break; | 92 | break; |
| 93 | case IR::Attribute::TessellationEvaluationPointU: | 93 | case IR::Attribute::ColorFrontDiffuseR: |
| 94 | case IR::Attribute::TessellationEvaluationPointV: | 94 | case IR::Attribute::ColorFrontDiffuseG: |
| 95 | ctx.Add("MOV.F {}.x,vertex.tesscoord.{};", inst, swizzle); | 95 | case IR::Attribute::ColorFrontDiffuseB: |
| 96 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 97 | ctx.Add("MOV.F {}.x,{}.color.{};", inst, ctx.attrib_name, swizzle); | ||
| 96 | break; | 98 | break; |
| 97 | case IR::Attribute::PointSpriteS: | 99 | case IR::Attribute::PointSpriteS: |
| 98 | case IR::Attribute::PointSpriteT: | 100 | case IR::Attribute::PointSpriteT: |
| 99 | ctx.Add("MOV.F {}.x,{}.pointcoord.{};", inst, ctx.attrib_name, swizzle); | 101 | ctx.Add("MOV.F {}.x,{}.pointcoord.{};", inst, ctx.attrib_name, swizzle); |
| 100 | break; | 102 | break; |
| 103 | case IR::Attribute::TessellationEvaluationPointU: | ||
| 104 | case IR::Attribute::TessellationEvaluationPointV: | ||
| 105 | ctx.Add("MOV.F {}.x,vertex.tesscoord.{};", inst, swizzle); | ||
| 106 | break; | ||
| 101 | case IR::Attribute::InstanceId: | 107 | case IR::Attribute::InstanceId: |
| 102 | ctx.Add("MOV.S {}.x,{}.instance;", inst, ctx.attrib_name); | 108 | ctx.Add("MOV.S {}.x,{}.instance;", inst, ctx.attrib_name); |
| 103 | break; | 109 | break; |
| @@ -121,7 +127,27 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, | |||
| 121 | ctx.Add("MOV.F out_attr{}[0].{},{};", index, swizzle, value); | 127 | ctx.Add("MOV.F out_attr{}[0].{},{};", index, swizzle, value); |
| 122 | return; | 128 | return; |
| 123 | } | 129 | } |
| 130 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) { | ||
| 131 | const u32 index{ | ||
| 132 | (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4}; | ||
| 133 | ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value); | ||
| 134 | return; | ||
| 135 | } | ||
| 124 | switch (attr) { | 136 | switch (attr) { |
| 137 | case IR::Attribute::Layer: | ||
| 138 | if (ctx.stage == Stage::Geometry || ctx.profile.support_viewport_index_layer_non_geometry) { | ||
| 139 | ctx.Add("MOV.F result.layer.x,{};", value); | ||
| 140 | } else { | ||
| 141 | // LOG_WARNING | ||
| 142 | } | ||
| 143 | break; | ||
| 144 | case IR::Attribute::ViewportIndex: | ||
| 145 | if (ctx.stage == Stage::Geometry || ctx.profile.support_viewport_index_layer_non_geometry) { | ||
| 146 | ctx.Add("MOV.F result.viewport.x,{};", value); | ||
| 147 | } else { | ||
| 148 | // LOG_WARNING | ||
| 149 | } | ||
| 150 | break; | ||
| 125 | case IR::Attribute::PointSize: | 151 | case IR::Attribute::PointSize: |
| 126 | ctx.Add("MOV.F result.pointsize.x,{};", value); | 152 | ctx.Add("MOV.F result.pointsize.x,{};", value); |
| 127 | break; | 153 | break; |
| @@ -131,6 +157,33 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, | |||
| 131 | case IR::Attribute::PositionW: | 157 | case IR::Attribute::PositionW: |
| 132 | ctx.Add("MOV.F result.position.{},{};", swizzle, value); | 158 | ctx.Add("MOV.F result.position.{},{};", swizzle, value); |
| 133 | break; | 159 | break; |
| 160 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 161 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 162 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 163 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 164 | ctx.Add("MOV.F result.color.{},{};", swizzle, value); | ||
| 165 | break; | ||
| 166 | case IR::Attribute::ColorFrontSpecularR: | ||
| 167 | case IR::Attribute::ColorFrontSpecularG: | ||
| 168 | case IR::Attribute::ColorFrontSpecularB: | ||
| 169 | case IR::Attribute::ColorFrontSpecularA: | ||
| 170 | ctx.Add("MOV.F result.color.secondary.{},{};", swizzle, value); | ||
| 171 | break; | ||
| 172 | case IR::Attribute::ColorBackDiffuseR: | ||
| 173 | case IR::Attribute::ColorBackDiffuseG: | ||
| 174 | case IR::Attribute::ColorBackDiffuseB: | ||
| 175 | case IR::Attribute::ColorBackDiffuseA: | ||
| 176 | ctx.Add("MOV.F result.color.back.{},{};", swizzle, value); | ||
| 177 | break; | ||
| 178 | case IR::Attribute::ColorBackSpecularR: | ||
| 179 | case IR::Attribute::ColorBackSpecularG: | ||
| 180 | case IR::Attribute::ColorBackSpecularB: | ||
| 181 | case IR::Attribute::ColorBackSpecularA: | ||
| 182 | ctx.Add("MOV.F result.color.back.secondary.{},{};", swizzle, value); | ||
| 183 | break; | ||
| 184 | case IR::Attribute::FogCoordinate: | ||
| 185 | ctx.Add("MOV.F result.fogcoord.x,{};", value); | ||
| 186 | break; | ||
| 134 | case IR::Attribute::ClipDistance0: | 187 | case IR::Attribute::ClipDistance0: |
| 135 | case IR::Attribute::ClipDistance1: | 188 | case IR::Attribute::ClipDistance1: |
| 136 | case IR::Attribute::ClipDistance2: | 189 | case IR::Attribute::ClipDistance2: |
| @@ -143,20 +196,6 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value, | |||
| 143 | ctx.Add("MOV.F result.clip[{}].x,{};", index, value); | 196 | ctx.Add("MOV.F result.clip[{}].x,{};", index, value); |
| 144 | break; | 197 | break; |
| 145 | } | 198 | } |
| 146 | case IR::Attribute::Layer: | ||
| 147 | if (ctx.stage == Stage::Geometry || ctx.profile.support_viewport_index_layer_non_geometry) { | ||
| 148 | ctx.Add("MOV.F result.layer.x,{};", value); | ||
| 149 | } else { | ||
| 150 | // LOG_WARNING | ||
| 151 | } | ||
| 152 | break; | ||
| 153 | case IR::Attribute::ViewportIndex: | ||
| 154 | if (ctx.stage == Stage::Geometry || ctx.profile.support_viewport_index_layer_non_geometry) { | ||
| 155 | ctx.Add("MOV.F result.viewport.x,{};", value); | ||
| 156 | } else { | ||
| 157 | // LOG_WARNING | ||
| 158 | } | ||
| 159 | break; | ||
| 160 | default: | 199 | default: |
| 161 | throw NotImplementedException("Set attribute {}", attr); | 200 | throw NotImplementedException("Set attribute {}", attr); |
| 162 | } | 201 | } |