summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/maxwell_3d.h121
1 files changed, 61 insertions, 60 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 753aff57f..1af948d24 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -480,6 +480,67 @@ public:
480 }; 480 };
481 }; 481 };
482 482
483 struct ViewportTransform {
484 f32 scale_x;
485 f32 scale_y;
486 f32 scale_z;
487 f32 translate_x;
488 f32 translate_y;
489 f32 translate_z;
490 INSERT_PADDING_WORDS(2);
491
492 MathUtil::Rectangle<s32> GetRect() const {
493 return {
494 GetX(), // left
495 GetY() + GetHeight(), // top
496 GetX() + GetWidth(), // right
497 GetY() // bottom
498 };
499 };
500
501 s32 GetX() const {
502 return static_cast<s32>(std::max(0.0f, translate_x - std::fabs(scale_x)));
503 }
504
505 s32 GetY() const {
506 return static_cast<s32>(std::max(0.0f, translate_y - std::fabs(scale_y)));
507 }
508
509 s32 GetWidth() const {
510 return static_cast<s32>(translate_x + std::fabs(scale_x)) - GetX();
511 }
512
513 s32 GetHeight() const {
514 return static_cast<s32>(translate_y + std::fabs(scale_y)) - GetY();
515 }
516 };
517
518 struct ScissorTest {
519 u32 enable;
520 union {
521 BitField<0, 16, u32> min_x;
522 BitField<16, 16, u32> max_x;
523 };
524 union {
525 BitField<0, 16, u32> min_y;
526 BitField<16, 16, u32> max_y;
527 };
528 u32 fill;
529 };
530
531 struct ViewPort {
532 union {
533 BitField<0, 16, u32> x;
534 BitField<16, 16, u32> width;
535 };
536 union {
537 BitField<0, 16, u32> y;
538 BitField<16, 16, u32> height;
539 };
540 float depth_range_near;
541 float depth_range_far;
542 };
543
483 bool IsShaderConfigEnabled(std::size_t index) const { 544 bool IsShaderConfigEnabled(std::size_t index) const {
484 // The VertexB is always enabled. 545 // The VertexB is always enabled.
485 if (index == static_cast<std::size_t>(Regs::ShaderProgram::VertexB)) { 546 if (index == static_cast<std::size_t>(Regs::ShaderProgram::VertexB)) {
@@ -507,56 +568,8 @@ public:
507 568
508 std::array<RenderTargetConfig, NumRenderTargets> rt; 569 std::array<RenderTargetConfig, NumRenderTargets> rt;
509 570
510 struct ViewportTransform {
511 f32 scale_x;
512 f32 scale_y;
513 f32 scale_z;
514 f32 translate_x;
515 f32 translate_y;
516 f32 translate_z;
517 INSERT_PADDING_WORDS(2);
518
519 MathUtil::Rectangle<s32> GetRect() const {
520 return {
521 GetX(), // left
522 GetY() + GetHeight(), // top
523 GetX() + GetWidth(), // right
524 GetY() // bottom
525 };
526 };
527
528 s32 GetX() const {
529 return static_cast<s32>(std::max(0.0f, translate_x - std::fabs(scale_x)));
530 }
531
532 s32 GetY() const {
533 return static_cast<s32>(std::max(0.0f, translate_y - std::fabs(scale_y)));
534 }
535
536 s32 GetWidth() const {
537 return static_cast<s32>(translate_x + std::fabs(scale_x)) - GetX();
538 }
539
540 s32 GetHeight() const {
541 return static_cast<s32>(translate_y + std::fabs(scale_y)) - GetY();
542 }
543 };
544
545 std::array<ViewportTransform, NumViewports> viewport_transform; 571 std::array<ViewportTransform, NumViewports> viewport_transform;
546 572
547 struct ViewPort {
548 union {
549 BitField<0, 16, u32> x;
550 BitField<16, 16, u32> width;
551 };
552 union {
553 BitField<0, 16, u32> y;
554 BitField<16, 16, u32> height;
555 };
556 float depth_range_near;
557 float depth_range_far;
558 };
559
560 std::array<ViewPort, NumViewports> viewports; 573 std::array<ViewPort, NumViewports> viewports;
561 574
562 INSERT_PADDING_WORDS(0x1D); 575 INSERT_PADDING_WORDS(0x1D);
@@ -575,18 +588,6 @@ public:
575 588
576 INSERT_PADDING_WORDS(0x17); 589 INSERT_PADDING_WORDS(0x17);
577 590
578 struct ScissorTest {
579 u32 enable;
580 union {
581 BitField<0, 16, u32> min_x;
582 BitField<16, 16, u32> max_x;
583 };
584 union {
585 BitField<0, 16, u32> min_y;
586 BitField<16, 16, u32> max_y;
587 };
588 u32 fill;
589 };
590 std::array<ScissorTest, NumViewports> scissor_test; 591 std::array<ScissorTest, NumViewports> scissor_test;
591 592
592 INSERT_PADDING_WORDS(0x15); 593 INSERT_PADDING_WORDS(0x15);