diff options
| author | 2021-11-01 12:00:13 +0800 | |
|---|---|---|
| committer | 2021-11-04 09:26:16 +0800 | |
| commit | f2a420424546fbc031594c5927b553b9d928b3a4 (patch) | |
| tree | a6c1a833d37ea156c4b2898283806690771e3e34 /src/shader_recompiler/backend/spirv | |
| parent | Support gl_FogFragCoord attribute (diff) | |
| download | yuzu-f2a420424546fbc031594c5927b553b9d928b3a4.tar.gz yuzu-f2a420424546fbc031594c5927b553b9d928b3a4.tar.xz yuzu-f2a420424546fbc031594c5927b553b9d928b3a4.zip | |
Simply legacy attribute implement
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
3 files changed, 125 insertions, 152 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 386c14ce5..3c84e6466 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -441,6 +441,22 @@ size_t FindAndSetNextUnusedLocation(std::bitset<IR::NUM_GENERICS>& used_location | |||
| 441 | } | 441 | } |
| 442 | throw RuntimeError("Unable to get an unused location for legacy attribute"); | 442 | throw RuntimeError("Unable to get an unused location for legacy attribute"); |
| 443 | } | 443 | } |
| 444 | |||
| 445 | Id DefineLegacyInput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 446 | size_t& start_offset) { | ||
| 447 | const Id id{DefineInput(ctx, ctx.F32[4], true)}; | ||
| 448 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 449 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 450 | return id; | ||
| 451 | } | ||
| 452 | |||
| 453 | Id DefineLegacyOutput(EmitContext& ctx, std::bitset<IR::NUM_GENERICS>& used_locations, | ||
| 454 | size_t& start_offset, std::optional<u32> invocations) { | ||
| 455 | const Id id{DefineOutput(ctx, ctx.F32[4], invocations)}; | ||
| 456 | const size_t location = FindAndSetNextUnusedLocation(used_locations, start_offset); | ||
| 457 | ctx.Decorate(id, spv::Decoration::Location, location); | ||
| 458 | return id; | ||
| 459 | } | ||
| 444 | } // Anonymous namespace | 460 | } // Anonymous namespace |
| 445 | 461 | ||
| 446 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { | 462 | void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { |
| @@ -522,6 +538,64 @@ Id EmitContext::BitOffset16(const IR::Value& offset) { | |||
| 522 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); | 538 | return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u)); |
| 523 | } | 539 | } |
| 524 | 540 | ||
| 541 | Id EmitContext::InputLegacyAttribute(IR::Attribute attribute) { | ||
| 542 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 543 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 544 | return input_front_color; | ||
| 545 | } | ||
| 546 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 547 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 548 | return input_front_secondary_color; | ||
| 549 | } | ||
| 550 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 551 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 552 | return input_back_color; | ||
| 553 | } | ||
| 554 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 555 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 556 | return input_back_secondary_color; | ||
| 557 | } | ||
| 558 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 559 | return input_fog_frag_coord; | ||
| 560 | } | ||
| 561 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 562 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 563 | u32 index = | ||
| 564 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 565 | return input_fixed_fnc_textures[index]; | ||
| 566 | } | ||
| 567 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 568 | } | ||
| 569 | |||
| 570 | Id EmitContext::OutputLegacyAttribute(IR::Attribute attribute) { | ||
| 571 | if (attribute >= IR::Attribute::ColorFrontDiffuseR && | ||
| 572 | attribute <= IR::Attribute::ColorFrontDiffuseA) { | ||
| 573 | return output_front_color; | ||
| 574 | } | ||
| 575 | if (attribute >= IR::Attribute::ColorFrontSpecularR && | ||
| 576 | attribute <= IR::Attribute::ColorFrontSpecularA) { | ||
| 577 | return output_front_secondary_color; | ||
| 578 | } | ||
| 579 | if (attribute >= IR::Attribute::ColorBackDiffuseR && | ||
| 580 | attribute <= IR::Attribute::ColorBackDiffuseA) { | ||
| 581 | return output_back_color; | ||
| 582 | } | ||
| 583 | if (attribute >= IR::Attribute::ColorBackSpecularR && | ||
| 584 | attribute <= IR::Attribute::ColorBackSpecularA) { | ||
| 585 | return output_back_secondary_color; | ||
| 586 | } | ||
| 587 | if (attribute == IR::Attribute::FogCoordinate) { | ||
| 588 | return output_fog_frag_coord; | ||
| 589 | } | ||
| 590 | if (attribute >= IR::Attribute::FixedFncTexture0S && | ||
| 591 | attribute <= IR::Attribute::FixedFncTexture9Q) { | ||
| 592 | u32 index = | ||
| 593 | (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4; | ||
| 594 | return output_fixed_fnc_textures[index]; | ||
| 595 | } | ||
| 596 | throw InvalidArgument("Attribute is not legacy attribute {}", attribute); | ||
| 597 | } | ||
| 598 | |||
| 525 | void EmitContext::DefineCommonTypes(const Info& info) { | 599 | void EmitContext::DefineCommonTypes(const Info& info) { |
| 526 | void_id = TypeVoid(); | 600 | void_id = TypeVoid(); |
| 527 | 601 | ||
| @@ -1281,41 +1355,26 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1281 | } | 1355 | } |
| 1282 | size_t previous_unused_location = 0; | 1356 | size_t previous_unused_location = 0; |
| 1283 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1357 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1284 | const Id id{DefineInput(*this, F32[4], true)}; | 1358 | input_front_color = DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1285 | Decorate(id, spv::Decoration::Location, | ||
| 1286 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1287 | input_front_color = id; | ||
| 1288 | } | 1359 | } |
| 1289 | if (loads.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | 1360 | if (loads.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { |
| 1290 | const Id id{DefineInput(*this, F32[4], true)}; | 1361 | input_front_secondary_color = |
| 1291 | Decorate(id, spv::Decoration::Location, | 1362 | DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1292 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1293 | input_front_secondary_color = id; | ||
| 1294 | } | 1363 | } |
| 1295 | if (loads.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | 1364 | if (loads.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { |
| 1296 | const Id id{DefineInput(*this, F32[4], true)}; | 1365 | input_back_color = DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1297 | Decorate(id, spv::Decoration::Location, | ||
| 1298 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1299 | input_back_color = id; | ||
| 1300 | } | 1366 | } |
| 1301 | if (loads.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | 1367 | if (loads.AnyComponent(IR::Attribute::ColorBackSpecularR)) { |
| 1302 | const Id id{DefineInput(*this, F32[4], true)}; | 1368 | input_back_secondary_color = |
| 1303 | Decorate(id, spv::Decoration::Location, | 1369 | DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1304 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1305 | input_back_secondary_color = id; | ||
| 1306 | } | 1370 | } |
| 1307 | if (loads.AnyComponent(IR::Attribute::FogCoordinate)) { | 1371 | if (loads.AnyComponent(IR::Attribute::FogCoordinate)) { |
| 1308 | const Id id{DefineInput(*this, F32[4], true)}; | 1372 | input_fog_frag_coord = DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1309 | Decorate(id, spv::Decoration::Location, | ||
| 1310 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1311 | input_fog_frag_coord = id; | ||
| 1312 | } | 1373 | } |
| 1313 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1374 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1314 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1375 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1315 | const Id id{DefineInput(*this, F32[4], true)}; | 1376 | input_fixed_fnc_textures[index] = |
| 1316 | Decorate(id, spv::Decoration::Location, | 1377 | DefineLegacyInput(*this, used_locations, previous_unused_location); |
| 1317 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1318 | input_fixed_fnc_textures[index] = id; | ||
| 1319 | } | 1378 | } |
| 1320 | } | 1379 | } |
| 1321 | if (stage == Stage::TessellationEval) { | 1380 | if (stage == Stage::TessellationEval) { |
| @@ -1377,46 +1436,29 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1377 | } | 1436 | } |
| 1378 | size_t previous_unused_location = 0; | 1437 | size_t previous_unused_location = 0; |
| 1379 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1438 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1380 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1439 | output_front_color = |
| 1381 | Decorate(id, spv::Decoration::Location, | 1440 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1382 | static_cast<u32>( | ||
| 1383 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location))); | ||
| 1384 | output_front_color = id; | ||
| 1385 | } | 1441 | } |
| 1386 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { | 1442 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontSpecularR)) { |
| 1387 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1443 | output_front_secondary_color = |
| 1388 | Decorate(id, spv::Decoration::Location, | 1444 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1389 | static_cast<u32>( | ||
| 1390 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location))); | ||
| 1391 | output_front_secondary_color = id; | ||
| 1392 | } | 1445 | } |
| 1393 | if (info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { | 1446 | if (info.stores.AnyComponent(IR::Attribute::ColorBackDiffuseR)) { |
| 1394 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1447 | output_back_color = |
| 1395 | Decorate(id, spv::Decoration::Location, | 1448 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1396 | static_cast<u32>( | ||
| 1397 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location))); | ||
| 1398 | output_back_color = id; | ||
| 1399 | } | 1449 | } |
| 1400 | if (info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { | 1450 | if (info.stores.AnyComponent(IR::Attribute::ColorBackSpecularR)) { |
| 1401 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1451 | output_back_secondary_color = |
| 1402 | Decorate(id, spv::Decoration::Location, | 1452 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1403 | static_cast<u32>( | ||
| 1404 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location))); | ||
| 1405 | output_back_secondary_color = id; | ||
| 1406 | } | 1453 | } |
| 1407 | if (info.stores.AnyComponent(IR::Attribute::FogCoordinate)) { | 1454 | if (info.stores.AnyComponent(IR::Attribute::FogCoordinate)) { |
| 1408 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1455 | output_fog_frag_coord = |
| 1409 | Decorate(id, spv::Decoration::Location, | 1456 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1410 | static_cast<u32>( | ||
| 1411 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location))); | ||
| 1412 | output_fog_frag_coord = id; | ||
| 1413 | } | 1457 | } |
| 1414 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1458 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1415 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1459 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1416 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1460 | output_fixed_fnc_textures[index] = |
| 1417 | Decorate(id, spv::Decoration::Location, | 1461 | DefineLegacyOutput(*this, used_locations, previous_unused_location, invocations); |
| 1418 | FindAndSetNextUnusedLocation(used_locations, previous_unused_location)); | ||
| 1419 | output_fixed_fnc_textures[index] = id; | ||
| 1420 | } | 1462 | } |
| 1421 | } | 1463 | } |
| 1422 | switch (stage) { | 1464 | switch (stage) { |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index e1af12a38..112c52382 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -113,6 +113,9 @@ 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 | |||
| 116 | Id Const(u32 value) { | 119 | Id Const(u32 value) { |
| 117 | return Constant(U32[1], value); | 120 | return Constant(U32[1], value); |
| 118 | } | 121 | } |
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 6fa99cc1a..d3a93d5f4 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 | |||
| @@ -43,23 +43,12 @@ Id AttrPointer(EmitContext& ctx, Id pointer_type, Id vertex, Id base, Args&&... | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool IsFixedFncTexture(IR::Attribute attribute) { | 46 | bool IsLegacyAttribute(IR::Attribute attribute) { |
| 47 | return attribute >= IR::Attribute::FixedFncTexture0S && | 47 | return (attribute >= IR::Attribute::ColorFrontDiffuseR && |
| 48 | attribute <= IR::Attribute::FixedFncTexture9Q; | 48 | attribute <= IR::Attribute::ColorBackSpecularA) || |
| 49 | } | 49 | attribute == IR::Attribute::FogCoordinate || |
| 50 | 50 | (attribute >= IR::Attribute::FixedFncTexture0S && | |
| 51 | u32 FixedFncTextureAttributeIndex(IR::Attribute attribute) { | 51 | attribute <= IR::Attribute::FixedFncTexture9Q); |
| 52 | if (!IsFixedFncTexture(attribute)) { | ||
| 53 | throw InvalidArgument("Attribute {} is not a FixedFncTexture", attribute); | ||
| 54 | } | ||
| 55 | return (static_cast<u32>(attribute) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4u; | ||
| 56 | } | ||
| 57 | |||
| 58 | u32 FixedFncTextureAttributeElement(IR::Attribute attribute) { | ||
| 59 | if (!IsFixedFncTexture(attribute)) { | ||
| 60 | throw InvalidArgument("Attribute {} is not a FixedFncTexture", attribute); | ||
| 61 | } | ||
| 62 | return static_cast<u32>(attribute) % 4u; | ||
| 63 | } | 52 | } |
| 64 | 53 | ||
| 65 | template <typename... Args> | 54 | template <typename... Args> |
| @@ -93,12 +82,16 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 93 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); | 82 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); |
| 94 | } | 83 | } |
| 95 | } | 84 | } |
| 96 | if (IsFixedFncTexture(attr)) { | 85 | if (IsLegacyAttribute(attr)) { |
| 97 | const u32 index{FixedFncTextureAttributeIndex(attr)}; | 86 | if (attr == IR::Attribute::FogCoordinate) { |
| 98 | const u32 element{FixedFncTextureAttributeElement(attr)}; | 87 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), |
| 99 | const Id element_id{ctx.Const(element)}; | 88 | ctx.Const(0u)); |
| 100 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_textures[index], | 89 | } else { |
| 101 | element_id); | 90 | const u32 element{static_cast<u32>(attr) % 4}; |
| 91 | const Id element_id{ctx.Const(element)}; | ||
| 92 | return OutputAccessChain(ctx, ctx.output_f32, ctx.OutputLegacyAttribute(attr), | ||
| 93 | element_id); | ||
| 94 | } | ||
| 102 | } | 95 | } |
| 103 | switch (attr) { | 96 | switch (attr) { |
| 104 | case IR::Attribute::PointSize: | 97 | case IR::Attribute::PointSize: |
| @@ -111,43 +104,6 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 111 | const Id element_id{ctx.Const(element)}; | 104 | const Id element_id{ctx.Const(element)}; |
| 112 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); | 105 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); |
| 113 | } | 106 | } |
| 114 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 115 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 116 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 117 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 118 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 119 | const Id element_id{ctx.Const(element)}; | ||
| 120 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_color, element_id); | ||
| 121 | } | ||
| 122 | case IR::Attribute::ColorFrontSpecularR: | ||
| 123 | case IR::Attribute::ColorFrontSpecularG: | ||
| 124 | case IR::Attribute::ColorFrontSpecularB: | ||
| 125 | case IR::Attribute::ColorFrontSpecularA: { | ||
| 126 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 127 | const Id element_id{ctx.Const(element)}; | ||
| 128 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_secondary_color, element_id); | ||
| 129 | } | ||
| 130 | case IR::Attribute::ColorBackDiffuseR: | ||
| 131 | case IR::Attribute::ColorBackDiffuseG: | ||
| 132 | case IR::Attribute::ColorBackDiffuseB: | ||
| 133 | case IR::Attribute::ColorBackDiffuseA: { | ||
| 134 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 135 | const Id element_id{ctx.Const(element)}; | ||
| 136 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_back_color, element_id); | ||
| 137 | } | ||
| 138 | case IR::Attribute::ColorBackSpecularR: | ||
| 139 | case IR::Attribute::ColorBackSpecularG: | ||
| 140 | case IR::Attribute::ColorBackSpecularB: | ||
| 141 | case IR::Attribute::ColorBackSpecularA: { | ||
| 142 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 143 | const Id element_id{ctx.Const(element)}; | ||
| 144 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_back_secondary_color, element_id); | ||
| 145 | } | ||
| 146 | case IR::Attribute::FogCoordinate: { | ||
| 147 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 148 | const Id element_id{ctx.Const(element)}; | ||
| 149 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fog_frag_coord, element_id); | ||
| 150 | } | ||
| 151 | case IR::Attribute::ClipDistance0: | 107 | case IR::Attribute::ClipDistance0: |
| 152 | case IR::Attribute::ClipDistance1: | 108 | case IR::Attribute::ClipDistance1: |
| 153 | case IR::Attribute::ClipDistance2: | 109 | case IR::Attribute::ClipDistance2: |
| @@ -370,11 +326,17 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 370 | const Id value{ctx.OpLoad(type->id, pointer)}; | 326 | const Id value{ctx.OpLoad(type->id, pointer)}; |
| 371 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 327 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 372 | } | 328 | } |
| 373 | if (IsFixedFncTexture(attr)) { | 329 | if (IsLegacyAttribute(attr)) { |
| 374 | const u32 index{FixedFncTextureAttributeIndex(attr)}; | 330 | if (attr == IR::Attribute::FogCoordinate) { |
| 375 | const Id attr_id{ctx.input_fixed_fnc_textures[index]}; | 331 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, |
| 376 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, attr_id, ctx.Const(element))}; | 332 | ctx.InputLegacyAttribute(attr), ctx.Const(0u))}; |
| 377 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | 333 | return ctx.OpLoad(ctx.F32[1], attr_ptr); |
| 334 | } else { | ||
| 335 | const Id element_id{ctx.Const(element)}; | ||
| 336 | const Id attr_ptr{AttrPointer(ctx, ctx.input_f32, vertex, | ||
| 337 | ctx.InputLegacyAttribute(attr), element_id)}; | ||
| 338 | return ctx.OpLoad(ctx.F32[1], attr_ptr); | ||
| 339 | } | ||
| 378 | } | 340 | } |
| 379 | switch (attr) { | 341 | switch (attr) { |
| 380 | case IR::Attribute::PrimitiveId: | 342 | case IR::Attribute::PrimitiveId: |
| @@ -385,40 +347,6 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 385 | case IR::Attribute::PositionW: | 347 | case IR::Attribute::PositionW: |
| 386 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, | 348 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, |
| 387 | ctx.Const(element))); | 349 | ctx.Const(element))); |
| 388 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 389 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 390 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 391 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 392 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_color, | ||
| 393 | ctx.Const(element))); | ||
| 394 | } | ||
| 395 | case IR::Attribute::ColorFrontSpecularR: | ||
| 396 | case IR::Attribute::ColorFrontSpecularG: | ||
| 397 | case IR::Attribute::ColorFrontSpecularB: | ||
| 398 | case IR::Attribute::ColorFrontSpecularA: { | ||
| 399 | return ctx.OpLoad(ctx.F32[1], | ||
| 400 | AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_secondary_color, | ||
| 401 | ctx.Const(element))); | ||
| 402 | } | ||
| 403 | case IR::Attribute::ColorBackDiffuseR: | ||
| 404 | case IR::Attribute::ColorBackDiffuseG: | ||
| 405 | case IR::Attribute::ColorBackDiffuseB: | ||
| 406 | case IR::Attribute::ColorBackDiffuseA: { | ||
| 407 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_back_color, | ||
| 408 | ctx.Const(element))); | ||
| 409 | } | ||
| 410 | case IR::Attribute::ColorBackSpecularR: | ||
| 411 | case IR::Attribute::ColorBackSpecularG: | ||
| 412 | case IR::Attribute::ColorBackSpecularB: | ||
| 413 | case IR::Attribute::ColorBackSpecularA: { | ||
| 414 | return ctx.OpLoad(ctx.F32[1], | ||
| 415 | AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_back_secondary_color, | ||
| 416 | ctx.Const(element))); | ||
| 417 | } | ||
| 418 | case IR::Attribute::FogCoordinate: { | ||
| 419 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, | ||
| 420 | ctx.input_fog_frag_coord, ctx.Const(element))); | ||
| 421 | } | ||
| 422 | case IR::Attribute::InstanceId: | 350 | case IR::Attribute::InstanceId: |
| 423 | if (ctx.profile.support_vertex_instance_id) { | 351 | if (ctx.profile.support_vertex_instance_id) { |
| 424 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); | 352 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); |