diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 93 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 16 |
2 files changed, 58 insertions, 51 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 7cea146f0..2a5855795 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -519,61 +519,66 @@ void Maxwell3D::ProcessFirmwareCall4() { | |||
| 519 | regs.reg_array[0xd00] = 1; | 519 | regs.reg_array[0xd00] = 1; |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | void Maxwell3D::ProcessQueryGet() { | 522 | void Maxwell3D::StampQueryResult(u64 payload, bool long_query) { |
| 523 | struct LongQueryResult { | ||
| 524 | u64_le value; | ||
| 525 | u64_le timestamp; | ||
| 526 | }; | ||
| 527 | static_assert(sizeof(LongQueryResult) == 16, "LongQueryResult has wrong size"); | ||
| 523 | const GPUVAddr sequence_address{regs.query.QueryAddress()}; | 528 | const GPUVAddr sequence_address{regs.query.QueryAddress()}; |
| 524 | // Since the sequence address is given as a GPU VAddr, we have to convert it to an application | 529 | if (long_query) { |
| 525 | // VAddr before writing. | 530 | // Write the 128-bit result structure in long mode. Note: We emulate an infinitely fast |
| 531 | // GPU, this command may actually take a while to complete in real hardware due to GPU | ||
| 532 | // wait queues. | ||
| 533 | LongQueryResult query_result{}; | ||
| 534 | query_result.value = payload; | ||
| 535 | // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming | ||
| 536 | query_result.timestamp = system.CoreTiming().GetTicks(); | ||
| 537 | memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result)); | ||
| 538 | } else { | ||
| 539 | memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload)); | ||
| 540 | } | ||
| 541 | } | ||
| 526 | 542 | ||
| 543 | void Maxwell3D::ProcessQueryGet() { | ||
| 527 | // TODO(Subv): Support the other query units. | 544 | // TODO(Subv): Support the other query units. |
| 528 | ASSERT_MSG(regs.query.query_get.unit == Regs::QueryUnit::Crop, | 545 | ASSERT_MSG(regs.query.query_get.unit == Regs::QueryUnit::Crop, |
| 529 | "Units other than CROP are unimplemented"); | 546 | "Units other than CROP are unimplemented"); |
| 530 | 547 | ||
| 531 | u64 result = 0; | 548 | switch (regs.query.query_get.operation) { |
| 532 | 549 | case Regs::QueryOperation::Release: { | |
| 533 | // TODO(Subv): Support the other query variables | 550 | u64 result = regs.query.query_sequence; |
| 534 | switch (regs.query.query_get.select) { | 551 | StampQueryResult(result, regs.query.query_get.short_query == 0); |
| 535 | case Regs::QuerySelect::Zero: | ||
| 536 | // This seems to actually write the query sequence to the query address. | ||
| 537 | result = regs.query.query_sequence; | ||
| 538 | break; | 552 | break; |
| 539 | default: | ||
| 540 | result = 1; | ||
| 541 | UNIMPLEMENTED_MSG("Unimplemented query select type {}", | ||
| 542 | static_cast<u32>(regs.query.query_get.select.Value())); | ||
| 543 | } | 553 | } |
| 544 | 554 | case Regs::QueryOperation::Acquire: { | |
| 545 | // TODO(Subv): Research and implement how query sync conditions work. | 555 | // Todo(Blinkhawk): Under this operation, the GPU waits for the CPU |
| 546 | 556 | // to write a value that matches the current payload. | |
| 547 | struct LongQueryResult { | 557 | UNIMPLEMENTED_MSG("Unimplemented query operation ACQUIRE"); |
| 548 | u64_le value; | 558 | break; |
| 549 | u64_le timestamp; | 559 | } |
| 550 | }; | 560 | case Regs::QueryOperation::Counter: { |
| 551 | static_assert(sizeof(LongQueryResult) == 16, "LongQueryResult has wrong size"); | 561 | u64 result{}; |
| 552 | 562 | switch (regs.query.query_get.select) { | |
| 553 | switch (regs.query.query_get.mode) { | 563 | case Regs::QuerySelect::Zero: |
| 554 | case Regs::QueryMode::Write: | 564 | result = 0; |
| 555 | case Regs::QueryMode::Write2: { | 565 | break; |
| 556 | u32 sequence = regs.query.query_sequence; | 566 | default: |
| 557 | if (regs.query.query_get.short_query) { | 567 | result = 1; |
| 558 | // Write the current query sequence to the sequence address. | 568 | UNIMPLEMENTED_MSG("Unimplemented query select type {}", |
| 559 | // TODO(Subv): Find out what happens if you use a long query type but mark it as a short | 569 | static_cast<u32>(regs.query.query_get.select.Value())); |
| 560 | // query. | ||
| 561 | memory_manager.Write<u32>(sequence_address, sequence); | ||
| 562 | } else { | ||
| 563 | // Write the 128-bit result structure in long mode. Note: We emulate an infinitely fast | ||
| 564 | // GPU, this command may actually take a while to complete in real hardware due to GPU | ||
| 565 | // wait queues. | ||
| 566 | LongQueryResult query_result{}; | ||
| 567 | query_result.value = result; | ||
| 568 | // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming | ||
| 569 | query_result.timestamp = system.CoreTiming().GetTicks(); | ||
| 570 | memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result)); | ||
| 571 | } | 570 | } |
| 571 | StampQueryResult(result, regs.query.query_get.short_query == 0); | ||
| 572 | break; | ||
| 573 | } | ||
| 574 | case Regs::QueryOperation::Trap: { | ||
| 575 | UNIMPLEMENTED_MSG("Unimplemented query operation TRAP"); | ||
| 576 | break; | ||
| 577 | } | ||
| 578 | default: { | ||
| 579 | UNIMPLEMENTED_MSG("Unknown query operation"); | ||
| 572 | break; | 580 | break; |
| 573 | } | 581 | } |
| 574 | default: | ||
| 575 | UNIMPLEMENTED_MSG("Query mode {} not implemented", | ||
| 576 | static_cast<u32>(regs.query.query_get.mode.Value())); | ||
| 577 | } | 582 | } |
| 578 | } | 583 | } |
| 579 | 584 | ||
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index e437bacb7..78e055765 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -71,12 +71,11 @@ public: | |||
| 71 | static constexpr std::size_t MaxConstBuffers = 18; | 71 | static constexpr std::size_t MaxConstBuffers = 18; |
| 72 | static constexpr std::size_t MaxConstBufferSize = 0x10000; | 72 | static constexpr std::size_t MaxConstBufferSize = 0x10000; |
| 73 | 73 | ||
| 74 | enum class QueryMode : u32 { | 74 | enum class QueryOperation : u32 { |
| 75 | Write = 0, | 75 | Release = 0, |
| 76 | Sync = 1, | 76 | Acquire = 1, |
| 77 | // TODO(Subv): It is currently unknown what the difference between method 2 and method 0 | 77 | Counter = 2, |
| 78 | // is. | 78 | Trap = 3, |
| 79 | Write2 = 2, | ||
| 80 | }; | 79 | }; |
| 81 | 80 | ||
| 82 | enum class QueryUnit : u32 { | 81 | enum class QueryUnit : u32 { |
| @@ -1077,7 +1076,7 @@ public: | |||
| 1077 | u32 query_sequence; | 1076 | u32 query_sequence; |
| 1078 | union { | 1077 | union { |
| 1079 | u32 raw; | 1078 | u32 raw; |
| 1080 | BitField<0, 2, QueryMode> mode; | 1079 | BitField<0, 2, QueryOperation> operation; |
| 1081 | BitField<4, 1, u32> fence; | 1080 | BitField<4, 1, u32> fence; |
| 1082 | BitField<12, 4, QueryUnit> unit; | 1081 | BitField<12, 4, QueryUnit> unit; |
| 1083 | BitField<16, 1, QuerySyncCondition> sync_cond; | 1082 | BitField<16, 1, QuerySyncCondition> sync_cond; |
| @@ -1409,6 +1408,9 @@ private: | |||
| 1409 | /// Handles a write to the QUERY_GET register. | 1408 | /// Handles a write to the QUERY_GET register. |
| 1410 | void ProcessQueryGet(); | 1409 | void ProcessQueryGet(); |
| 1411 | 1410 | ||
| 1411 | // Writes the query result accordingly | ||
| 1412 | void StampQueryResult(u64 payload, bool long_query); | ||
| 1413 | |||
| 1412 | // Handles Conditional Rendering | 1414 | // Handles Conditional Rendering |
| 1413 | void ProcessQueryCondition(); | 1415 | void ProcessQueryCondition(); |
| 1414 | 1416 | ||