summaryrefslogtreecommitdiff
path: root/src/video_core/shader/node.h
diff options
context:
space:
mode:
authorGravatar Levi2021-01-10 22:09:56 -0700
committerGravatar Levi2021-01-10 22:09:56 -0700
commit7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch)
tree5056f9406dec188439cb0deb87603498243a9412 /src/video_core/shader/node.h
parentMore forgetting... duh (diff)
parentMerge pull request #5229 from Morph1984/fullscreen-opt (diff)
downloadyuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/video_core/shader/node.h')
-rw-r--r--src/video_core/shader/node.h159
1 files changed, 80 insertions, 79 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 1b19a0673..c9840b75e 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -282,26 +282,27 @@ struct SeparateSamplerNode;
282using TrackSamplerData = std::variant<BindlessSamplerNode, SeparateSamplerNode, ArraySamplerNode>; 282using TrackSamplerData = std::variant<BindlessSamplerNode, SeparateSamplerNode, ArraySamplerNode>;
283using TrackSampler = std::shared_ptr<TrackSamplerData>; 283using TrackSampler = std::shared_ptr<TrackSamplerData>;
284 284
285struct Sampler { 285struct SamplerEntry {
286 /// Bound samplers constructor 286 /// Bound samplers constructor
287 constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, 287 explicit SamplerEntry(u32 index_, u32 offset_, Tegra::Shader::TextureType type_, bool is_array_,
288 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) 288 bool is_shadow_, bool is_buffer_, bool is_indexed_)
289 : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow}, 289 : index{index_}, offset{offset_}, type{type_}, is_array{is_array_}, is_shadow{is_shadow_},
290 is_buffer{is_buffer}, is_indexed{is_indexed} {} 290 is_buffer{is_buffer_}, is_indexed{is_indexed_} {}
291 291
292 /// Separate sampler constructor 292 /// Separate sampler constructor
293 constexpr explicit Sampler(u32 index, std::pair<u32, u32> offsets, std::pair<u32, u32> buffers, 293 explicit SamplerEntry(u32 index_, std::pair<u32, u32> offsets, std::pair<u32, u32> buffers,
294 Tegra::Shader::TextureType type, bool is_array, bool is_shadow, 294 Tegra::Shader::TextureType type_, bool is_array_, bool is_shadow_,
295 bool is_buffer) 295 bool is_buffer_)
296 : index{index}, offset{offsets.first}, secondary_offset{offsets.second}, 296 : index{index_}, offset{offsets.first}, secondary_offset{offsets.second},
297 buffer{buffers.first}, secondary_buffer{buffers.second}, type{type}, is_array{is_array}, 297 buffer{buffers.first}, secondary_buffer{buffers.second}, type{type_}, is_array{is_array_},
298 is_shadow{is_shadow}, is_buffer{is_buffer}, is_separated{true} {} 298 is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_separated{true} {}
299 299
300 /// Bindless samplers constructor 300 /// Bindless samplers constructor
301 constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, 301 explicit SamplerEntry(u32 index_, u32 offset_, u32 buffer_, Tegra::Shader::TextureType type_,
302 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) 302 bool is_array_, bool is_shadow_, bool is_buffer_, bool is_indexed_)
303 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, 303 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_array{is_array_},
304 is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {} 304 is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_bindless{true}, is_indexed{is_indexed_} {
305 }
305 306
306 u32 index = 0; ///< Emulated index given for the this sampler. 307 u32 index = 0; ///< Emulated index given for the this sampler.
307 u32 offset = 0; ///< Offset in the const buffer from where the sampler is being read. 308 u32 offset = 0; ///< Offset in the const buffer from where the sampler is being read.
@@ -338,15 +339,15 @@ struct BindlessSamplerNode {
338 u32 offset; 339 u32 offset;
339}; 340};
340 341
341struct Image { 342struct ImageEntry {
342public: 343public:
343 /// Bound images constructor 344 /// Bound images constructor
344 constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type) 345 explicit ImageEntry(u32 index_, u32 offset_, Tegra::Shader::ImageType type_)
345 : index{index}, offset{offset}, type{type} {} 346 : index{index_}, offset{offset_}, type{type_} {}
346 347
347 /// Bindless samplers constructor 348 /// Bindless samplers constructor
348 constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type) 349 explicit ImageEntry(u32 index_, u32 offset_, u32 buffer_, Tegra::Shader::ImageType type_)
349 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {} 350 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_bindless{true} {}
350 351
351 void MarkWrite() { 352 void MarkWrite() {
352 is_written = true; 353 is_written = true;
@@ -377,7 +378,7 @@ struct GlobalMemoryBase {
377 u32 cbuf_index = 0; 378 u32 cbuf_index = 0;
378 u32 cbuf_offset = 0; 379 u32 cbuf_offset = 0;
379 380
380 bool operator<(const GlobalMemoryBase& rhs) const { 381 [[nodiscard]] bool operator<(const GlobalMemoryBase& rhs) const {
381 return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset); 382 return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset);
382 } 383 }
383}; 384};
@@ -389,7 +390,7 @@ struct MetaArithmetic {
389 390
390/// Parameters describing a texture sampler 391/// Parameters describing a texture sampler
391struct MetaTexture { 392struct MetaTexture {
392 Sampler sampler; 393 SamplerEntry sampler;
393 Node array; 394 Node array;
394 Node depth_compare; 395 Node depth_compare;
395 std::vector<Node> aoffi; 396 std::vector<Node> aoffi;
@@ -403,7 +404,7 @@ struct MetaTexture {
403}; 404};
404 405
405struct MetaImage { 406struct MetaImage {
406 const Image& image; 407 const ImageEntry& image;
407 std::vector<Node> values; 408 std::vector<Node> values;
408 u32 element{}; 409 u32 element{};
409}; 410};
@@ -414,7 +415,7 @@ using Meta =
414 415
415class AmendNode { 416class AmendNode {
416public: 417public:
417 std::optional<std::size_t> GetAmendIndex() const { 418 [[nodiscard]] std::optional<std::size_t> GetAmendIndex() const {
418 if (amend_index == amend_null_index) { 419 if (amend_index == amend_null_index) {
419 return std::nullopt; 420 return std::nullopt;
420 } 421 }
@@ -437,30 +438,30 @@ private:
437/// Holds any kind of operation that can be done in the IR 438/// Holds any kind of operation that can be done in the IR
438class OperationNode final : public AmendNode { 439class OperationNode final : public AmendNode {
439public: 440public:
440 explicit OperationNode(OperationCode code) : OperationNode(code, Meta{}) {} 441 explicit OperationNode(OperationCode code_) : OperationNode(code_, Meta{}) {}
441 442
442 explicit OperationNode(OperationCode code, Meta meta) 443 explicit OperationNode(OperationCode code_, Meta meta_)
443 : OperationNode(code, std::move(meta), std::vector<Node>{}) {} 444 : OperationNode(code_, std::move(meta_), std::vector<Node>{}) {}
444 445
445 explicit OperationNode(OperationCode code, std::vector<Node> operands) 446 explicit OperationNode(OperationCode code_, std::vector<Node> operands_)
446 : OperationNode(code, Meta{}, std::move(operands)) {} 447 : OperationNode(code_, Meta{}, std::move(operands_)) {}
447 448
448 explicit OperationNode(OperationCode code, Meta meta, std::vector<Node> operands) 449 explicit OperationNode(OperationCode code_, Meta meta_, std::vector<Node> operands_)
449 : code{code}, meta{std::move(meta)}, operands{std::move(operands)} {} 450 : code{code_}, meta{std::move(meta_)}, operands{std::move(operands_)} {}
450 451
451 template <typename... Args> 452 template <typename... Args>
452 explicit OperationNode(OperationCode code, Meta meta, Args&&... operands) 453 explicit OperationNode(OperationCode code_, Meta meta_, Args&&... operands_)
453 : code{code}, meta{std::move(meta)}, operands{operands...} {} 454 : code{code_}, meta{std::move(meta_)}, operands{operands_...} {}
454 455
455 OperationCode GetCode() const { 456 [[nodiscard]] OperationCode GetCode() const {
456 return code; 457 return code;
457 } 458 }
458 459
459 const Meta& GetMeta() const { 460 [[nodiscard]] const Meta& GetMeta() const {
460 return meta; 461 return meta;
461 } 462 }
462 463
463 std::size_t GetOperandsCount() const { 464 [[nodiscard]] std::size_t GetOperandsCount() const {
464 return operands.size(); 465 return operands.size();
465 } 466 }
466 467
@@ -472,7 +473,7 @@ public:
472 return operands; 473 return operands;
473 } 474 }
474 475
475 const Node& operator[](std::size_t operand_index) const { 476 [[nodiscard]] const Node& operator[](std::size_t operand_index) const {
476 return operands.at(operand_index); 477 return operands.at(operand_index);
477 } 478 }
478 479
@@ -485,14 +486,14 @@ private:
485/// Encloses inside any kind of node that returns a boolean conditionally-executed code 486/// Encloses inside any kind of node that returns a boolean conditionally-executed code
486class ConditionalNode final : public AmendNode { 487class ConditionalNode final : public AmendNode {
487public: 488public:
488 explicit ConditionalNode(Node condition, std::vector<Node>&& code) 489 explicit ConditionalNode(Node condition_, std::vector<Node>&& code_)
489 : condition{std::move(condition)}, code{std::move(code)} {} 490 : condition{std::move(condition_)}, code{std::move(code_)} {}
490 491
491 const Node& GetCondition() const { 492 [[nodiscard]] const Node& GetCondition() const {
492 return condition; 493 return condition;
493 } 494 }
494 495
495 const std::vector<Node>& GetCode() const { 496 [[nodiscard]] const std::vector<Node>& GetCode() const {
496 return code; 497 return code;
497 } 498 }
498 499
@@ -504,9 +505,9 @@ private:
504/// A general purpose register 505/// A general purpose register
505class GprNode final { 506class GprNode final {
506public: 507public:
507 explicit constexpr GprNode(Tegra::Shader::Register index) : index{index} {} 508 explicit constexpr GprNode(Tegra::Shader::Register index_) : index{index_} {}
508 509
509 u32 GetIndex() const { 510 [[nodiscard]] constexpr u32 GetIndex() const {
510 return static_cast<u32>(index); 511 return static_cast<u32>(index);
511 } 512 }
512 513
@@ -517,9 +518,9 @@ private:
517/// A custom variable 518/// A custom variable
518class CustomVarNode final { 519class CustomVarNode final {
519public: 520public:
520 explicit constexpr CustomVarNode(u32 index) : index{index} {} 521 explicit constexpr CustomVarNode(u32 index_) : index{index_} {}
521 522
522 constexpr u32 GetIndex() const { 523 [[nodiscard]] constexpr u32 GetIndex() const {
523 return index; 524 return index;
524 } 525 }
525 526
@@ -530,9 +531,9 @@ private:
530/// A 32-bits value that represents an immediate value 531/// A 32-bits value that represents an immediate value
531class ImmediateNode final { 532class ImmediateNode final {
532public: 533public:
533 explicit constexpr ImmediateNode(u32 value) : value{value} {} 534 explicit constexpr ImmediateNode(u32 value_) : value{value_} {}
534 535
535 u32 GetValue() const { 536 [[nodiscard]] constexpr u32 GetValue() const {
536 return value; 537 return value;
537 } 538 }
538 539
@@ -543,9 +544,9 @@ private:
543/// One of Maxwell's internal flags 544/// One of Maxwell's internal flags
544class InternalFlagNode final { 545class InternalFlagNode final {
545public: 546public:
546 explicit constexpr InternalFlagNode(InternalFlag flag) : flag{flag} {} 547 explicit constexpr InternalFlagNode(InternalFlag flag_) : flag{flag_} {}
547 548
548 InternalFlag GetFlag() const { 549 [[nodiscard]] constexpr InternalFlag GetFlag() const {
549 return flag; 550 return flag;
550 } 551 }
551 552
@@ -556,14 +557,14 @@ private:
556/// A predicate register, it can be negated without additional nodes 557/// A predicate register, it can be negated without additional nodes
557class PredicateNode final { 558class PredicateNode final {
558public: 559public:
559 explicit constexpr PredicateNode(Tegra::Shader::Pred index, bool negated) 560 explicit constexpr PredicateNode(Tegra::Shader::Pred index_, bool negated_)
560 : index{index}, negated{negated} {} 561 : index{index_}, negated{negated_} {}
561 562
562 Tegra::Shader::Pred GetIndex() const { 563 [[nodiscard]] constexpr Tegra::Shader::Pred GetIndex() const {
563 return index; 564 return index;
564 } 565 }
565 566
566 bool IsNegated() const { 567 [[nodiscard]] constexpr bool IsNegated() const {
567 return negated; 568 return negated;
568 } 569 }
569 570
@@ -576,30 +577,30 @@ private:
576class AbufNode final { 577class AbufNode final {
577public: 578public:
578 // Initialize for standard attributes (index is explicit). 579 // Initialize for standard attributes (index is explicit).
579 explicit AbufNode(Tegra::Shader::Attribute::Index index, u32 element, Node buffer = {}) 580 explicit AbufNode(Tegra::Shader::Attribute::Index index_, u32 element_, Node buffer_ = {})
580 : buffer{std::move(buffer)}, index{index}, element{element} {} 581 : buffer{std::move(buffer_)}, index{index_}, element{element_} {}
581 582
582 // Initialize for physical attributes (index is a variable value). 583 // Initialize for physical attributes (index is a variable value).
583 explicit AbufNode(Node physical_address, Node buffer = {}) 584 explicit AbufNode(Node physical_address_, Node buffer_ = {})
584 : physical_address{std::move(physical_address)}, buffer{std::move(buffer)} {} 585 : physical_address{std::move(physical_address_)}, buffer{std::move(buffer_)} {}
585 586
586 Tegra::Shader::Attribute::Index GetIndex() const { 587 [[nodiscard]] Tegra::Shader::Attribute::Index GetIndex() const {
587 return index; 588 return index;
588 } 589 }
589 590
590 u32 GetElement() const { 591 [[nodiscard]] u32 GetElement() const {
591 return element; 592 return element;
592 } 593 }
593 594
594 const Node& GetBuffer() const { 595 [[nodiscard]] const Node& GetBuffer() const {
595 return buffer; 596 return buffer;
596 } 597 }
597 598
598 bool IsPhysicalBuffer() const { 599 [[nodiscard]] bool IsPhysicalBuffer() const {
599 return static_cast<bool>(physical_address); 600 return static_cast<bool>(physical_address);
600 } 601 }
601 602
602 const Node& GetPhysicalAddress() const { 603 [[nodiscard]] const Node& GetPhysicalAddress() const {
603 return physical_address; 604 return physical_address;
604 } 605 }
605 606
@@ -613,9 +614,9 @@ private:
613/// Patch memory (used to communicate tessellation stages). 614/// Patch memory (used to communicate tessellation stages).
614class PatchNode final { 615class PatchNode final {
615public: 616public:
616 explicit PatchNode(u32 offset) : offset{offset} {} 617 explicit constexpr PatchNode(u32 offset_) : offset{offset_} {}
617 618
618 u32 GetOffset() const { 619 [[nodiscard]] constexpr u32 GetOffset() const {
619 return offset; 620 return offset;
620 } 621 }
621 622
@@ -626,13 +627,13 @@ private:
626/// Constant buffer node, usually mapped to uniform buffers in GLSL 627/// Constant buffer node, usually mapped to uniform buffers in GLSL
627class CbufNode final { 628class CbufNode final {
628public: 629public:
629 explicit CbufNode(u32 index, Node offset) : index{index}, offset{std::move(offset)} {} 630 explicit CbufNode(u32 index_, Node offset_) : index{index_}, offset{std::move(offset_)} {}
630 631
631 u32 GetIndex() const { 632 [[nodiscard]] u32 GetIndex() const {
632 return index; 633 return index;
633 } 634 }
634 635
635 const Node& GetOffset() const { 636 [[nodiscard]] const Node& GetOffset() const {
636 return offset; 637 return offset;
637 } 638 }
638 639
@@ -644,9 +645,9 @@ private:
644/// Local memory node 645/// Local memory node
645class LmemNode final { 646class LmemNode final {
646public: 647public:
647 explicit LmemNode(Node address) : address{std::move(address)} {} 648 explicit LmemNode(Node address_) : address{std::move(address_)} {}
648 649
649 const Node& GetAddress() const { 650 [[nodiscard]] const Node& GetAddress() const {
650 return address; 651 return address;
651 } 652 }
652 653
@@ -657,9 +658,9 @@ private:
657/// Shared memory node 658/// Shared memory node
658class SmemNode final { 659class SmemNode final {
659public: 660public:
660 explicit SmemNode(Node address) : address{std::move(address)} {} 661 explicit SmemNode(Node address_) : address{std::move(address_)} {}
661 662
662 const Node& GetAddress() const { 663 [[nodiscard]] const Node& GetAddress() const {
663 return address; 664 return address;
664 } 665 }
665 666
@@ -670,19 +671,19 @@ private:
670/// Global memory node 671/// Global memory node
671class GmemNode final { 672class GmemNode final {
672public: 673public:
673 explicit GmemNode(Node real_address, Node base_address, const GlobalMemoryBase& descriptor) 674 explicit GmemNode(Node real_address_, Node base_address_, const GlobalMemoryBase& descriptor_)
674 : real_address{std::move(real_address)}, base_address{std::move(base_address)}, 675 : real_address{std::move(real_address_)}, base_address{std::move(base_address_)},
675 descriptor{descriptor} {} 676 descriptor{descriptor_} {}
676 677
677 const Node& GetRealAddress() const { 678 [[nodiscard]] const Node& GetRealAddress() const {
678 return real_address; 679 return real_address;
679 } 680 }
680 681
681 const Node& GetBaseAddress() const { 682 [[nodiscard]] const Node& GetBaseAddress() const {
682 return base_address; 683 return base_address;
683 } 684 }
684 685
685 const GlobalMemoryBase& GetDescriptor() const { 686 [[nodiscard]] const GlobalMemoryBase& GetDescriptor() const {
686 return descriptor; 687 return descriptor;
687 } 688 }
688 689
@@ -695,9 +696,9 @@ private:
695/// Commentary, can be dropped 696/// Commentary, can be dropped
696class CommentNode final { 697class CommentNode final {
697public: 698public:
698 explicit CommentNode(std::string text) : text{std::move(text)} {} 699 explicit CommentNode(std::string text_) : text{std::move(text_)} {}
699 700
700 const std::string& GetText() const { 701 [[nodiscard]] const std::string& GetText() const {
701 return text; 702 return text;
702 } 703 }
703 704