diff options
| author | 2021-12-22 17:36:05 +0100 | |
|---|---|---|
| committer | 2021-12-22 17:36:05 +0100 | |
| commit | 648c7b4ed6fb86d6f98a6e19301c53c1ccfdd512 (patch) | |
| tree | 6e489900becbae18884335745d9e3409761c319e | |
| parent | Merge pull request #7599 from FernandoS27/primrestart-vulkan (diff) | |
| parent | Address format clang (diff) | |
| download | yuzu-648c7b4ed6fb86d6f98a6e19301c53c1ccfdd512.tar.gz yuzu-648c7b4ed6fb86d6f98a6e19301c53c1ccfdd512.tar.xz yuzu-648c7b4ed6fb86d6f98a6e19301c53c1ccfdd512.zip | |
Merge pull request #7375 from vonchenplus/convert_legacy
Convert all legacy attributes to generic attributes
Diffstat (limited to '')
12 files changed, 109 insertions, 293 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index 78b2eeaa2..b6b17a330 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -176,7 +176,7 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) { | |||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | std::string GlslVersionSpecifier(const EmitContext& ctx) { | 178 | std::string GlslVersionSpecifier(const EmitContext& ctx) { |
| 179 | if (ctx.uses_y_direction || ctx.info.stores.Legacy() || ctx.info.loads.Legacy()) { | 179 | if (ctx.uses_y_direction) { |
| 180 | return " compatibility"; | 180 | return " compatibility"; |
| 181 | } | 181 | } |
| 182 | return ""; | 182 | return ""; |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 1920047f4..6477bd192 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -98,10 +98,6 @@ void GetCbuf16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const | |||
| 98 | GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); | 98 | GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | |||
| 102 | u32 TexCoordIndex(IR::Attribute attr) { | ||
| 103 | return (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 104 | } | ||
| 105 | } // Anonymous namespace | 101 | } // Anonymous namespace |
| 106 | 102 | ||
| 107 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 103 | void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| @@ -190,18 +186,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 190 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); | 186 | ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); |
| 191 | return; | 187 | return; |
| 192 | } | 188 | } |
| 193 | // GLSL only exposes 8 legacy texcoords | ||
| 194 | if (attr >= IR::Attribute::FixedFncTexture8S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 195 | LOG_WARNING(Shader_GLSL, "GLSL does not allow access to gl_TexCoord[{}]", | ||
| 196 | TexCoordIndex(attr)); | ||
| 197 | ctx.AddF32("{}=0.f;", inst); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture7Q) { | ||
| 201 | const u32 index{TexCoordIndex(attr)}; | ||
| 202 | ctx.AddF32("{}=gl_TexCoord[{}].{};", inst, index, swizzle); | ||
| 203 | return; | ||
| 204 | } | ||
| 205 | switch (attr) { | 189 | switch (attr) { |
| 206 | case IR::Attribute::PrimitiveId: | 190 | case IR::Attribute::PrimitiveId: |
| 207 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); | 191 | ctx.AddF32("{}=itof(gl_PrimitiveID);", inst); |
| @@ -215,16 +199,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 215 | ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); | 199 | ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); |
| 216 | break; | 200 | break; |
| 217 | } | 201 | } |
| 218 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 219 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 220 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 221 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 222 | if (ctx.stage == Stage::Fragment) { | ||
| 223 | ctx.AddF32("{}=gl_Color.{};", inst, swizzle); | ||
| 224 | } else { | ||
| 225 | ctx.AddF32("{}=gl_FrontColor.{};", inst, swizzle); | ||
| 226 | } | ||
| 227 | break; | ||
| 228 | case IR::Attribute::PointSpriteS: | 202 | case IR::Attribute::PointSpriteS: |
| 229 | case IR::Attribute::PointSpriteT: | 203 | case IR::Attribute::PointSpriteT: |
| 230 | ctx.AddF32("{}=gl_PointCoord.{};", inst, swizzle); | 204 | ctx.AddF32("{}=gl_PointCoord.{};", inst, swizzle); |
| @@ -264,17 +238,6 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val | |||
| 264 | } | 238 | } |
| 265 | const u32 element{static_cast<u32>(attr) % 4}; | 239 | const u32 element{static_cast<u32>(attr) % 4}; |
| 266 | const char swizzle{"xyzw"[element]}; | 240 | const char swizzle{"xyzw"[element]}; |
| 267 | // GLSL only exposes 8 legacy texcoords | ||
| 268 | if (attr >= IR::Attribute::FixedFncTexture8S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 269 | LOG_WARNING(Shader_GLSL, "GLSL does not allow access to gl_TexCoord[{}]", | ||
| 270 | TexCoordIndex(attr)); | ||
| 271 | return; | ||
| 272 | } | ||
| 273 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture7Q) { | ||
| 274 | const u32 index{TexCoordIndex(attr)}; | ||
| 275 | ctx.Add("gl_TexCoord[{}].{}={};", index, swizzle, value); | ||
| 276 | return; | ||
| 277 | } | ||
| 278 | switch (attr) { | 241 | switch (attr) { |
| 279 | case IR::Attribute::Layer: | 242 | case IR::Attribute::Layer: |
| 280 | if (ctx.stage != Stage::Geometry && | 243 | if (ctx.stage != Stage::Geometry && |
| @@ -312,33 +275,6 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val | |||
| 312 | case IR::Attribute::PositionW: | 275 | case IR::Attribute::PositionW: |
| 313 | ctx.Add("gl_Position.{}={};", swizzle, value); | 276 | ctx.Add("gl_Position.{}={};", swizzle, value); |
| 314 | break; | 277 | break; |
| 315 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 316 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 317 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 318 | case IR::Attribute::ColorFrontDiffuseA: | ||
| 319 | ctx.Add("gl_FrontColor.{}={};", swizzle, value); | ||
| 320 | break; | ||
| 321 | case IR::Attribute::ColorFrontSpecularR: | ||
| 322 | case IR::Attribute::ColorFrontSpecularG: | ||
| 323 | case IR::Attribute::ColorFrontSpecularB: | ||
| 324 | case IR::Attribute::ColorFrontSpecularA: | ||
| 325 | ctx.Add("gl_FrontSecondaryColor.{}={};", swizzle, value); | ||
| 326 | break; | ||
| 327 | case IR::Attribute::ColorBackDiffuseR: | ||
| 328 | case IR::Attribute::ColorBackDiffuseG: | ||
| 329 | case IR::Attribute::ColorBackDiffuseB: | ||
| 330 | case IR::Attribute::ColorBackDiffuseA: | ||
| 331 | ctx.Add("gl_BackColor.{}={};", swizzle, value); | ||
| 332 | break; | ||
| 333 | case IR::Attribute::ColorBackSpecularR: | ||
| 334 | case IR::Attribute::ColorBackSpecularG: | ||
| 335 | case IR::Attribute::ColorBackSpecularB: | ||
| 336 | case IR::Attribute::ColorBackSpecularA: | ||
| 337 | ctx.Add("gl_BackSecondaryColor.{}={};", swizzle, value); | ||
| 338 | break; | ||
| 339 | case IR::Attribute::FogCoordinate: | ||
| 340 | ctx.Add("gl_FogFragCoord={};", value); | ||
| 341 | break; | ||
| 342 | case IR::Attribute::ClipDistance0: | 278 | case IR::Attribute::ClipDistance0: |
| 343 | case IR::Attribute::ClipDistance1: | 279 | case IR::Attribute::ClipDistance1: |
| 344 | case IR::Attribute::ClipDistance2: | 280 | case IR::Attribute::ClipDistance2: |
diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp index 1de017e76..bc9d2a904 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp | |||
| @@ -211,27 +211,6 @@ std::string_view OutputPrimitive(OutputTopology topology) { | |||
| 211 | throw InvalidArgument("Invalid output topology {}", topology); | 211 | throw InvalidArgument("Invalid output topology {}", topology); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | void SetupLegacyOutPerVertex(EmitContext& ctx, std::string& header) { | ||
| 215 | if (!ctx.info.stores.Legacy()) { | ||
| 216 | return; | ||
| 217 | } | ||
| 218 | if (ctx.info.stores.FixedFunctionTexture()) { | ||
| 219 | header += "vec4 gl_TexCoord[8];"; | ||
| 220 | } | ||
| 221 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 222 | header += "vec4 gl_FrontColor;"; | ||
| 223 | } | ||
| 224 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | ||
| 225 | header += "vec4 gl_FrontSecondaryColor;"; | ||
| 226 | } | ||
| 227 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 228 | header += "vec4 gl_BackColor;"; | ||
| 229 | } | ||
| 230 | if (ctx.info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 231 | header += "vec4 gl_BackSecondaryColor;"; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | 214 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { |
| 236 | if (!StoresPerVertexAttributes(ctx.stage)) { | 215 | if (!StoresPerVertexAttributes(ctx.stage)) { |
| 237 | return; | 216 | return; |
| @@ -250,7 +229,6 @@ void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | |||
| 250 | ctx.profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { | 229 | ctx.profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { |
| 251 | header += "int gl_ViewportIndex;"; | 230 | header += "int gl_ViewportIndex;"; |
| 252 | } | 231 | } |
| 253 | SetupLegacyOutPerVertex(ctx, header); | ||
| 254 | header += "};"; | 232 | header += "};"; |
| 255 | if (ctx.info.stores[IR::Attribute::ViewportIndex] && ctx.stage == Stage::Geometry) { | 233 | if (ctx.info.stores[IR::Attribute::ViewportIndex] && ctx.stage == Stage::Geometry) { |
| 256 | header += "out int gl_ViewportIndex;"; | 234 | header += "out int gl_ViewportIndex;"; |
| @@ -282,21 +260,6 @@ void SetupInPerVertex(EmitContext& ctx, std::string& header) { | |||
| 282 | } | 260 | } |
| 283 | header += "}gl_in[gl_MaxPatchVertices];"; | 261 | header += "}gl_in[gl_MaxPatchVertices];"; |
| 284 | } | 262 | } |
| 285 | |||
| 286 | void SetupLegacyInPerFragment(EmitContext& ctx, std::string& header) { | ||
| 287 | if (!ctx.info.loads.Legacy()) { | ||
| 288 | return; | ||
| 289 | } | ||
| 290 | header += "in gl_PerFragment{"; | ||
| 291 | if (ctx.info.loads.FixedFunctionTexture()) { | ||
| 292 | header += "vec4 gl_TexCoord[8];"; | ||
| 293 | } | ||
| 294 | if (ctx.info.loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 295 | header += "vec4 gl_Color;"; | ||
| 296 | } | ||
| 297 | header += "};"; | ||
| 298 | } | ||
| 299 | |||
| 300 | } // Anonymous namespace | 263 | } // Anonymous namespace |
| 301 | 264 | ||
| 302 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 265 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| @@ -361,7 +324,6 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 361 | } | 324 | } |
| 362 | SetupOutPerVertex(*this, header); | 325 | SetupOutPerVertex(*this, header); |
| 363 | SetupInPerVertex(*this, header); | 326 | SetupInPerVertex(*this, header); |
| 364 | SetupLegacyInPerFragment(*this, header); | ||
| 365 | 327 | ||
| 366 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 328 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 367 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { | 329 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index ad84966b5..14f470812 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -44,14 +44,6 @@ Id AttrPointer(EmitContext& ctx, Id pointer_type, Id vertex, Id base, Args&&... | |||
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | bool IsLegacyAttribute(IR::Attribute attribute) { | ||
| 48 | return (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 49 | attribute <= IR::Attribute::ColorBackSpecularA) || | ||
| 50 | attribute == IR::Attribute::FogCoordinate || | ||
| 51 | (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 52 | attribute <= IR::Attribute::FixedFncTexture9Q); | ||
| 53 | } | ||
| 54 | |||
| 55 | template <typename... Args> | 47 | template <typename... Args> |
| 56 | Id OutputAccessChain(EmitContext& ctx, Id result_type, Id base, Args&&... args) { | 48 | Id OutputAccessChain(EmitContext& ctx, Id result_type, Id base, Args&&... args) { |
| 57 | if (ctx.stage == Stage::TessellationControl) { | 49 | if (ctx.stage == Stage::TessellationControl) { |
| @@ -83,17 +75,6 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 83 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); | 75 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); |
| 84 | } | 76 | } |
| 85 | } | 77 | } |
| 86 | if (IsLegacyAttribute(attr)) { | ||
| 87 | if (attr == IR::Attribute::FogCoordinate) { | ||
| 88 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), | ||
| 89 | ctx.Const(0u)); | ||
| 90 | } else { | ||
| 91 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 92 | const Id element_id{ctx.Const(element)}; | ||
| 93 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), | ||
| 94 | element_id); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | switch (attr) { | 78 | switch (attr) { |
| 98 | case IR::Attribute::PointSize: | 79 | case IR::Attribute::PointSize: |
| 99 | return ctx.output_point_size; | 80 | return ctx.output_point_size; |
| @@ -327,18 +308,6 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 327 | const Id value{ctx.OpLoad(type->id, pointer)}; | 308 | const Id value{ctx.OpLoad(type->id, pointer)}; |
| 328 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 309 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 329 | } | 310 | } |
| 330 | if (IsLegacyAttribute(attr)) { | ||
| 331 | if (attr == IR::Attribute::FogCoordinate) { | ||
| 332 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, | ||
| 333 | ctx.InputLegacyAttribute(attr), ctx.Const(0u))}; | ||
| 334 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | ||
| 335 | } else { | ||
| 336 | const Id element_id{ctx.Const(element)}; | ||
| 337 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, | ||
| 338 | ctx.InputLegacyAttribute(attr), element_id)}; | ||
| 339 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | ||
| 340 | } | ||
| 341 | } | ||
| 342 | switch (attr) { | 311 | switch (attr) { |
| 343 | case IR::Attribute::PrimitiveId: | 312 | case IR::Attribute::PrimitiveId: |
| 344 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); | 313 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 4b6f792bf..d3ba66569 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -18,8 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | namespace Shader::Backend::SPIRV { | 19 | namespace Shader::Backend::SPIRV { |
| 20 | namespace { | 20 | namespace { |
| 21 | constexpr size_t NUM_FIXEDFNCTEXTURE = 10; | ||
| 22 | |||
| 23 | enum class Operation { | 21 | enum class Operation { |
| 24 | Increment, | 22 | Increment, |
| 25 | Decrement, | 23 | Decrement, |
| @@ -432,34 +430,6 @@ Id DescType(EmitContext& ctx, Id sampled_type, Id pointer_type, u32 count) { | |||
| 432 | return pointer_type; | 430 | return pointer_type; |
| 433 | } | 431 | } |
| 434 | } | 432 | } |
| 435 | |||
| 436 | size_t FindAndSetNextUnusedLocation(std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 437 | size_t& start_offset) { | ||
| 438 | for (size_t location = start_offset; location < used_locations.size(); ++location) { | ||
| 439 | if (!used_locations.test(location)) { | ||
| 440 | start_offset = location; | ||
| 441 | used_locations.set(location); | ||
| 442 | return location; | ||
| 443 | } | ||
| 444 | } | ||
| 445 | throw RuntimeError("Unable to get an unused location for legacy attribute"); | ||
| 446 | } | ||
| 447 | |||
| 448 | Id DefineLegacyInput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 449 | size_t& start_offset) { | ||
| 450 | const Id id{DefineInput(ctx, ctx.F32[4], true)}; | ||
| 451 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 452 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 453 | return id; | ||
| 454 | } | ||
| 455 | |||
| 456 | Id DefineLegacyOutput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 457 | size_t& start_offset, std::optional<u32> invocations) { | ||
| 458 | const Id id{DefineOutput(ctx, ctx.F32[4], invocations)}; | ||
| 459 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 460 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 461 | return id; | ||
| 462 | } | ||
| 463 | } // Anonymous namespace | 433 | } // Anonymous namespace |
| 464 | 434 | ||
| 465 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { | 435 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { |
| @@ -543,64 +513,6 @@ Id EmitContext::BitOffset16(const IR::Value& offset) { | |||
| 543 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); | 513 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); |
| 544 | } | 514 | } |
| 545 | 515 | ||
| 546 | Id EmitContext::InputLegacyAttribute(IR::Attribute attribute) { | ||
| 547 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 548 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 549 | return input_front_color; | ||
| 550 | } | ||
| 551 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 552 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 553 | return input_front_secondary_color; | ||
| 554 | } | ||
| 555 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 556 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 557 | return input_back_color; | ||
| 558 | } | ||
| 559 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 560 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 561 | return input_back_secondary_color; | ||
| 562 | } | ||
| 563 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 564 | return input_fog_frag_coord; | ||
| 565 | } | ||
| 566 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 567 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 568 | u32 index = | ||
| 569 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 570 | return input_fixed_fnc_textures[index]; | ||
| 571 | } | ||
| 572 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 573 | } | ||
| 574 | |||
| 575 | Id EmitContext::OutputLegacyAttribute(IR::Attribute attribute) { | ||
| 576 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 577 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 578 | return output_front_color; | ||
| 579 | } | ||
| 580 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 581 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 582 | return output_front_secondary_color; | ||
| 583 | } | ||
| 584 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 585 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 586 | return output_back_color; | ||
| 587 | } | ||
| 588 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 589 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 590 | return output_back_secondary_color; | ||
| 591 | } | ||
| 592 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 593 | return output_fog_frag_coord; | ||
| 594 | } | ||
| 595 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 596 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 597 | u32 index = | ||
| 598 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 599 | return output_fixed_fnc_textures[index]; | ||
| 600 | } | ||
| 601 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 602 | } | ||
| 603 | |||
| 604 | void EmitContext::DefineCommonTypes(const Info& info) { | 516 | void EmitContext::DefineCommonTypes(const Info& info) { |
| 605 | void_id = TypeVoid(); | 517 | void_id = TypeVoid(); |
| 606 | 518 | ||
| @@ -1389,7 +1301,6 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1389 | loads[IR::Attribute::TessellationEvaluationPointV]) { | 1301 | loads[IR::Attribute::TessellationEvaluationPointV]) { |
| 1390 | tess_coord = DefineInput(*this, F32[3], false, spv::BuiltIn::TessCoord); | 1302 | tess_coord = DefineInput(*this, F32[3], false, spv::BuiltIn::TessCoord); |
| 1391 | } | 1303 | } |
| 1392 | std::bitset<IR::NUM_GENERICS> used_locations{}; | ||
| 1393 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 1304 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 1394 | const AttributeType input_type{runtime_info.generic_input_types[index]}; | 1305 | const AttributeType input_type{runtime_info.generic_input_types[index]}; |
| 1395 | if (!runtime_info.previous_stage_stores.Generic(index)) { | 1306 | if (!runtime_info.previous_stage_stores.Generic(index)) { |
| @@ -1401,7 +1312,6 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1401 | if (input_type == AttributeType::Disabled) { | 1312 | if (input_type == AttributeType::Disabled) { |
| 1402 | continue; | 1313 | continue; |
| 1403 | } | 1314 | } |
| 1404 | used_locations.set(index); | ||
| 1405 | const Id type{GetAttributeType(*this, input_type)}; | 1315 | const Id type{GetAttributeType(*this, input_type)}; |
| 1406 | const Id id{DefineInput(*this, type, true)}; | 1316 | const Id id{DefineInput(*this, type, true)}; |
| 1407 | Decorate(id, spv::Decoration::Location, static_cast<u32>(index)); | 1317 | Decorate(id, spv::Decoration::Location, static_cast<u32>(index)); |
| @@ -1427,30 +1337,6 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1427 | break; | 1337 | break; |
| 1428 | } | 1338 | } |
| 1429 | } | 1339 | } |
| 1430 | size_t previous_unused_location = 0; | ||
| 1431 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 1432 | input_front_color = DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1433 | } | ||
| 1434 | if (loads.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | ||
| 1435 | input_front_secondary_color = | ||
| 1436 | DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1437 | } | ||
| 1438 | if (loads.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1439 | input_back_color = DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1440 | } | ||
| 1441 | if (loads.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 1442 | input_back_secondary_color = | ||
| 1443 | DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1444 | } | ||
| 1445 | if (loads.AnyComponent(IR::Attribute::FogCoordinate)) { | ||
| 1446 | input_fog_frag_coord = DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1447 | } | ||
| 1448 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | ||
| 1449 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | ||
| 1450 | input_fixed_fnc_textures[index] = | ||
| 1451 | DefineLegacyInput(*this, used_locations, previous_unused_location); | ||
| 1452 | } | ||
| 1453 | } | ||
| 1454 | if (stage == Stage::TessellationEval) { | 1340 | if (stage == Stage::TessellationEval) { |
| 1455 | for (size_t index = 0; index < info.uses_patches.size(); ++index) { | 1341 | for (size_t index = 0; index < info.uses_patches.size(); ++index) { |
| 1456 | if (!info.uses_patches[index]) { | 1342 | if (!info.uses_patches[index]) { |
| @@ -1501,38 +1387,9 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1501 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, | 1387 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, |
| 1502 | spv::BuiltIn::ViewportMaskNV); | 1388 | spv::BuiltIn::ViewportMaskNV); |
| 1503 | } | 1389 | } |
| 1504 | std::bitset<IR::NUM_GENERICS> used_locations{}; | ||
| 1505 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 1390 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 1506 | if (info.stores.Generic(index)) { | 1391 | if (info.stores.Generic(index)) { |
| 1507 | DefineGenericOutput(*this, index, invocations); | 1392 | DefineGenericOutput(*this, index, invocations); |
| 1508 | used_locations.set(index); | ||
| 1509 | } | ||
| 1510 | } | ||
| 1511 | size_t previous_unused_location = 0; | ||
| 1512 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 1513 | output_front_color = | ||
| 1514 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1515 | } | ||
| 1516 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | ||
| 1517 | output_front_secondary_color = | ||
| 1518 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1519 | } | ||
| 1520 | if (info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | ||
| 1521 | output_back_color = | ||
| 1522 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1523 | } | ||
| 1524 | if (info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | ||
| 1525 | output_back_secondary_color = | ||
| 1526 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1527 | } | ||
| 1528 | if (info.stores.AnyComponent(IR::Attribute::FogCoordinate)) { | ||
| 1529 | output_fog_frag_coord = | ||
| 1530 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1531 | } | ||
| 1532 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | ||
| 1533 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | ||
| 1534 | output_fixed_fnc_textures[index] = | ||
| 1535 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); | ||
| 1536 | } | 1393 | } |
| 1537 | } | 1394 | } |
| 1538 | switch (stage) { | 1395 | switch (stage) { |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index 63f8185d9..f87138f7e 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h | |||
| @@ -113,9 +113,6 @@ public: | |||
| 113 | [[nodiscard]] Id BitOffset8(const IR::Value& offset); | 113 | [[nodiscard]] Id BitOffset8(const IR::Value& offset); |
| 114 | [[nodiscard]] Id BitOffset16(const IR::Value& offset); | 114 | [[nodiscard]] Id BitOffset16(const IR::Value& offset); |
| 115 | 115 | ||
| 116 | Id InputLegacyAttribute(IR::Attribute attribute); | ||
| 117 | Id OutputLegacyAttribute(IR::Attribute attribute); | ||
| 118 | |||
| 119 | Id Const(u32 value) { | 116 | Id Const(u32 value) { |
| 120 | return Constant(U32[1], value); | 117 | return Constant(U32[1], value); |
| 121 | } | 118 | } |
| @@ -281,22 +278,10 @@ public: | |||
| 281 | Id write_global_func_u32x4{}; | 278 | Id write_global_func_u32x4{}; |
| 282 | 279 | ||
| 283 | Id input_position{}; | 280 | Id input_position{}; |
| 284 | Id input_front_color{}; | ||
| 285 | Id input_front_secondary_color{}; | ||
| 286 | Id input_back_color{}; | ||
| 287 | Id input_back_secondary_color{}; | ||
| 288 | Id input_fog_frag_coord{}; | ||
| 289 | std::array<Id, 10> input_fixed_fnc_textures{}; | ||
| 290 | std::array<Id, 32> input_generics{}; | 281 | std::array<Id, 32> input_generics{}; |
| 291 | 282 | ||
| 292 | Id output_point_size{}; | 283 | Id output_point_size{}; |
| 293 | Id output_position{}; | 284 | Id output_position{}; |
| 294 | Id output_front_color{}; | ||
| 295 | Id output_front_secondary_color{}; | ||
| 296 | Id output_back_color{}; | ||
| 297 | Id output_back_secondary_color{}; | ||
| 298 | Id output_fog_frag_coord{}; | ||
| 299 | std::array<Id, 10> output_fixed_fnc_textures{}; | ||
| 300 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 285 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 301 | 286 | ||
| 302 | Id output_tess_level_outer{}; | 287 | Id output_tess_level_outer{}; |
diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index ca1199494..3bbd38a03 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h | |||
| @@ -224,6 +224,8 @@ enum class Attribute : u64 { | |||
| 224 | 224 | ||
| 225 | constexpr size_t NUM_GENERICS = 32; | 225 | constexpr size_t NUM_GENERICS = 32; |
| 226 | 226 | ||
| 227 | constexpr size_t NUM_FIXEDFNCTEXTURE = 10; | ||
| 228 | |||
| 227 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; | 229 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; |
| 228 | 230 | ||
| 229 | [[nodiscard]] u32 GenericAttributeIndex(Attribute attribute); | 231 | [[nodiscard]] u32 GenericAttributeIndex(Attribute attribute); |
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp index 267ebe4af..248ad3ced 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | #include <queue> | ||
| 8 | 9 | ||
| 9 | #include "common/settings.h" | 10 | #include "common/settings.h" |
| 10 | #include "shader_recompiler/exception.h" | 11 | #include "shader_recompiler/exception.h" |
| @@ -127,6 +128,42 @@ void AddNVNStorageBuffers(IR::Program& program) { | |||
| 127 | }); | 128 | }); |
| 128 | } | 129 | } |
| 129 | } | 130 | } |
| 131 | |||
| 132 | bool IsLegacyAttribute(IR::Attribute attribute) { | ||
| 133 | return (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 134 | attribute <= IR::Attribute::ColorBackSpecularA) || | ||
| 135 | attribute == IR::Attribute::FogCoordinate || | ||
| 136 | (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 137 | attribute <= IR::Attribute::FixedFncTexture9Q); | ||
| 138 | } | ||
| 139 | |||
| 140 | std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings( | ||
| 141 | const VaryingState& state, std::queue<IR::Attribute> ununsed_generics) { | ||
| 142 | std::map<IR::Attribute, IR::Attribute> mapping; | ||
| 143 | for (size_t index = 0; index < 4; ++index) { | ||
| 144 | auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4; | ||
| 145 | if (state.AnyComponent(attr)) { | ||
| 146 | for (size_t i = 0; i < 4; ++i) { | ||
| 147 | mapping.insert({attr + i, ununsed_generics.front() + i}); | ||
| 148 | } | ||
| 149 | ununsed_generics.pop(); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | if (state[IR::Attribute::FogCoordinate]) { | ||
| 153 | mapping.insert({IR::Attribute::FogCoordinate, ununsed_generics.front()}); | ||
| 154 | ununsed_generics.pop(); | ||
| 155 | } | ||
| 156 | for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) { | ||
| 157 | auto attr = IR::Attribute::FixedFncTexture0S + index * 4; | ||
| 158 | if (state.AnyComponent(attr)) { | ||
| 159 | for (size_t i = 0; i < 4; ++i) { | ||
| 160 | mapping.insert({attr + i, ununsed_generics.front() + i}); | ||
| 161 | } | ||
| 162 | ununsed_generics.pop(); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | return mapping; | ||
| 166 | } | ||
| 130 | } // Anonymous namespace | 167 | } // Anonymous namespace |
| 131 | 168 | ||
| 132 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, | 169 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, |
| @@ -226,4 +263,62 @@ IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b | |||
| 226 | return result; | 263 | return result; |
| 227 | } | 264 | } |
| 228 | 265 | ||
| 266 | void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& runtime_info) { | ||
| 267 | auto& stores = program.info.stores; | ||
| 268 | if (stores.Legacy()) { | ||
| 269 | std::queue<IR::Attribute> ununsed_output_generics{}; | ||
| 270 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | ||
| 271 | if (!stores.Generic(index)) { | ||
| 272 | ununsed_output_generics.push(IR::Attribute::Generic0X + index * 4); | ||
| 273 | } | ||
| 274 | } | ||
| 275 | auto mappings = GenerateLegacyToGenericMappings(stores, ununsed_output_generics); | ||
| 276 | for (IR::Block* const block : program.post_order_blocks) { | ||
| 277 | for (IR::Inst& inst : block->Instructions()) { | ||
| 278 | switch (inst.GetOpcode()) { | ||
| 279 | case IR::Opcode::SetAttribute: { | ||
| 280 | const auto attr = inst.Arg(0).Attribute(); | ||
| 281 | if (IsLegacyAttribute(attr)) { | ||
| 282 | stores.Set(mappings[attr], true); | ||
| 283 | inst.SetArg(0, Shader::IR::Value(mappings[attr])); | ||
| 284 | } | ||
| 285 | break; | ||
| 286 | } | ||
| 287 | default: | ||
| 288 | break; | ||
| 289 | } | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | auto& loads = program.info.loads; | ||
| 295 | if (loads.Legacy()) { | ||
| 296 | std::queue<IR::Attribute> ununsed_input_generics{}; | ||
| 297 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | ||
| 298 | const AttributeType input_type{runtime_info.generic_input_types[index]}; | ||
| 299 | if (!runtime_info.previous_stage_stores.Generic(index) || !loads.Generic(index) || | ||
| 300 | input_type == AttributeType::Disabled) { | ||
| 301 | ununsed_input_generics.push(IR::Attribute::Generic0X + index * 4); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | auto mappings = GenerateLegacyToGenericMappings(loads, ununsed_input_generics); | ||
| 305 | for (IR::Block* const block : program.post_order_blocks) { | ||
| 306 | for (IR::Inst& inst : block->Instructions()) { | ||
| 307 | switch (inst.GetOpcode()) { | ||
| 308 | case IR::Opcode::GetAttribute: { | ||
| 309 | const auto attr = inst.Arg(0).Attribute(); | ||
| 310 | if (IsLegacyAttribute(attr)) { | ||
| 311 | loads.Set(mappings[attr], true); | ||
| 312 | inst.SetArg(0, Shader::IR::Value(mappings[attr])); | ||
| 313 | } | ||
| 314 | break; | ||
| 315 | } | ||
| 316 | default: | ||
| 317 | break; | ||
| 318 | } | ||
| 319 | } | ||
| 320 | } | ||
| 321 | } | ||
| 322 | } | ||
| 323 | |||
| 229 | } // namespace Shader::Maxwell | 324 | } // namespace Shader::Maxwell |
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.h b/src/shader_recompiler/frontend/maxwell/translate_program.h index a84814811..cd535f20d 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.h +++ b/src/shader_recompiler/frontend/maxwell/translate_program.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "shader_recompiler/frontend/maxwell/control_flow.h" | 10 | #include "shader_recompiler/frontend/maxwell/control_flow.h" |
| 11 | #include "shader_recompiler/host_translate_info.h" | 11 | #include "shader_recompiler/host_translate_info.h" |
| 12 | #include "shader_recompiler/object_pool.h" | 12 | #include "shader_recompiler/object_pool.h" |
| 13 | #include "shader_recompiler/runtime_info.h" | ||
| 13 | 14 | ||
| 14 | namespace Shader::Maxwell { | 15 | namespace Shader::Maxwell { |
| 15 | 16 | ||
| @@ -20,4 +21,7 @@ namespace Shader::Maxwell { | |||
| 20 | [[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b, | 21 | [[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b, |
| 21 | Environment& env_vertex_b); | 22 | Environment& env_vertex_b); |
| 22 | 23 | ||
| 24 | [[nodiscard]] void ConvertLegacyToGeneric(IR::Program& program, | ||
| 25 | const Shader::RuntimeInfo& runtime_info); | ||
| 26 | |||
| 23 | } // namespace Shader::Maxwell | 27 | } // namespace Shader::Maxwell |
diff --git a/src/shader_recompiler/varying_state.h b/src/shader_recompiler/varying_state.h index 9d7b24a76..bc4f273c8 100644 --- a/src/shader_recompiler/varying_state.h +++ b/src/shader_recompiler/varying_state.h | |||
| @@ -53,7 +53,8 @@ struct VaryingState { | |||
| 53 | return AnyComponent(IR::Attribute::ColorFrontDiffuseR) || | 53 | return AnyComponent(IR::Attribute::ColorFrontDiffuseR) || |
| 54 | AnyComponent(IR::Attribute::ColorFrontSpecularR) || | 54 | AnyComponent(IR::Attribute::ColorFrontSpecularR) || |
| 55 | AnyComponent(IR::Attribute::ColorBackDiffuseR) || | 55 | AnyComponent(IR::Attribute::ColorBackDiffuseR) || |
| 56 | AnyComponent(IR::Attribute::ColorBackSpecularR) || FixedFunctionTexture(); | 56 | AnyComponent(IR::Attribute::ColorBackSpecularR) || FixedFunctionTexture() || |
| 57 | mask[static_cast<size_t>(IR::Attribute::FogCoordinate)]; | ||
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | [[nodiscard]] bool FixedFunctionTexture() const noexcept { | 60 | [[nodiscard]] bool FixedFunctionTexture() const noexcept { |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 42ef67628..29c6e1a5f 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -42,6 +42,7 @@ namespace { | |||
| 42 | using Shader::Backend::GLASM::EmitGLASM; | 42 | using Shader::Backend::GLASM::EmitGLASM; |
| 43 | using Shader::Backend::GLSL::EmitGLSL; | 43 | using Shader::Backend::GLSL::EmitGLSL; |
| 44 | using Shader::Backend::SPIRV::EmitSPIRV; | 44 | using Shader::Backend::SPIRV::EmitSPIRV; |
| 45 | using Shader::Maxwell::ConvertLegacyToGeneric; | ||
| 45 | using Shader::Maxwell::MergeDualVertexPrograms; | 46 | using Shader::Maxwell::MergeDualVertexPrograms; |
| 46 | using Shader::Maxwell::TranslateProgram; | 47 | using Shader::Maxwell::TranslateProgram; |
| 47 | using VideoCommon::ComputeEnvironment; | 48 | using VideoCommon::ComputeEnvironment; |
| @@ -462,12 +463,14 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline( | |||
| 462 | MakeRuntimeInfo(key, program, previous_program, glasm_use_storage_buffers, use_glasm)}; | 463 | MakeRuntimeInfo(key, program, previous_program, glasm_use_storage_buffers, use_glasm)}; |
| 463 | switch (device.GetShaderBackend()) { | 464 | switch (device.GetShaderBackend()) { |
| 464 | case Settings::ShaderBackend::GLSL: | 465 | case Settings::ShaderBackend::GLSL: |
| 466 | ConvertLegacyToGeneric(program, runtime_info); | ||
| 465 | sources[stage_index] = EmitGLSL(profile, runtime_info, program, binding); | 467 | sources[stage_index] = EmitGLSL(profile, runtime_info, program, binding); |
| 466 | break; | 468 | break; |
| 467 | case Settings::ShaderBackend::GLASM: | 469 | case Settings::ShaderBackend::GLASM: |
| 468 | sources[stage_index] = EmitGLASM(profile, runtime_info, program, binding); | 470 | sources[stage_index] = EmitGLASM(profile, runtime_info, program, binding); |
| 469 | break; | 471 | break; |
| 470 | case Settings::ShaderBackend::SPIRV: | 472 | case Settings::ShaderBackend::SPIRV: |
| 473 | ConvertLegacyToGeneric(program, runtime_info); | ||
| 471 | sources_spirv[stage_index] = EmitSPIRV(profile, runtime_info, program, binding); | 474 | sources_spirv[stage_index] = EmitSPIRV(profile, runtime_info, program, binding); |
| 472 | break; | 475 | break; |
| 473 | } | 476 | } |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index eb8b4e08b..2728353c8 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -48,6 +48,7 @@ MICROPROFILE_DECLARE(Vulkan_PipelineCache); | |||
| 48 | 48 | ||
| 49 | namespace { | 49 | namespace { |
| 50 | using Shader::Backend::SPIRV::EmitSPIRV; | 50 | using Shader::Backend::SPIRV::EmitSPIRV; |
| 51 | using Shader::Maxwell::ConvertLegacyToGeneric; | ||
| 51 | using Shader::Maxwell::MergeDualVertexPrograms; | 52 | using Shader::Maxwell::MergeDualVertexPrograms; |
| 52 | using Shader::Maxwell::TranslateProgram; | 53 | using Shader::Maxwell::TranslateProgram; |
| 53 | using VideoCommon::ComputeEnvironment; | 54 | using VideoCommon::ComputeEnvironment; |
| @@ -543,6 +544,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( | |||
| 543 | infos[stage_index] = &program.info; | 544 | infos[stage_index] = &program.info; |
| 544 | 545 | ||
| 545 | const auto runtime_info{MakeRuntimeInfo(programs, key, program, previous_stage)}; | 546 | const auto runtime_info{MakeRuntimeInfo(programs, key, program, previous_stage)}; |
| 547 | ConvertLegacyToGeneric(program, runtime_info); | ||
| 546 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; | 548 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; |
| 547 | device.SaveShader(code); | 549 | device.SaveShader(code); |
| 548 | modules[stage_index] = BuildShader(device, code); | 550 | modules[stage_index] = BuildShader(device, code); |