diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 40 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 56 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 2 |
3 files changed, 95 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index ccdb310f0..9f699399f 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -2,12 +2,50 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/assert.h" | ||
| 5 | #include "video_core/engines/maxwell_3d.h" | 6 | #include "video_core/engines/maxwell_3d.h" |
| 6 | 7 | ||
| 7 | namespace Tegra { | 8 | namespace Tegra { |
| 8 | namespace Engines { | 9 | namespace Engines { |
| 9 | 10 | ||
| 10 | void Maxwell3D::WriteReg(u32 method, u32 value) {} | 11 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} |
| 11 | 12 | ||
| 13 | void Maxwell3D::WriteReg(u32 method, u32 value) { | ||
| 14 | ASSERT_MSG(method < Regs::NUM_REGS, | ||
| 15 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | ||
| 16 | |||
| 17 | regs.reg_array[method] = value; | ||
| 18 | |||
| 19 | #define MAXWELL3D_REG_INDEX(field_name) (offsetof(Regs, field_name) / sizeof(u32)) | ||
| 20 | |||
| 21 | switch (method) { | ||
| 22 | case MAXWELL3D_REG_INDEX(query.query_get): { | ||
| 23 | ProcessQueryGet(); | ||
| 24 | break; | ||
| 25 | } | ||
| 26 | default: | ||
| 27 | break; | ||
| 28 | } | ||
| 29 | |||
| 30 | #undef MAXWELL3D_REG_INDEX | ||
| 31 | } | ||
| 32 | |||
| 33 | void Maxwell3D::ProcessQueryGet() { | ||
| 34 | GPUVAddr sequence_address = regs.query.QueryAddress(); | ||
| 35 | // Since the sequence address is given as a GPU VAddr, we have to convert it to an application | ||
| 36 | // VAddr before writing. | ||
| 37 | VAddr address = memory_manager.PhysicalToVirtualAddress(sequence_address); | ||
| 38 | |||
| 39 | switch (regs.query.query_get.mode) { | ||
| 40 | case Regs::QueryMode::Write: { | ||
| 41 | // Write the current query sequence to the sequence address. | ||
| 42 | u32 sequence = regs.query.query_sequence; | ||
| 43 | Memory::Write32(address, sequence); | ||
| 44 | break; | ||
| 45 | } | ||
| 46 | default: | ||
| 47 | UNIMPLEMENTED_MSG("Query mode %u not implemented", regs.query.query_get.mode.Value()); | ||
| 48 | } | ||
| 49 | } | ||
| 12 | } // namespace Engines | 50 | } // namespace Engines |
| 13 | } // namespace Tegra | 51 | } // namespace Tegra |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 0f4ae1328..5cd2ecd20 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -4,19 +4,73 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/memory_manager.h" | ||
| 8 | 11 | ||
| 9 | namespace Tegra { | 12 | namespace Tegra { |
| 10 | namespace Engines { | 13 | namespace Engines { |
| 11 | 14 | ||
| 12 | class Maxwell3D final { | 15 | class Maxwell3D final { |
| 13 | public: | 16 | public: |
| 14 | Maxwell3D() = default; | 17 | Maxwell3D(MemoryManager& memory_manager); |
| 15 | ~Maxwell3D() = default; | 18 | ~Maxwell3D() = default; |
| 16 | 19 | ||
| 17 | /// Write the value to the register identified by method. | 20 | /// Write the value to the register identified by method. |
| 18 | void WriteReg(u32 method, u32 value); | 21 | void WriteReg(u32 method, u32 value); |
| 22 | |||
| 23 | /// Register structure of the Maxwell3D engine. | ||
| 24 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. | ||
| 25 | struct Regs { | ||
| 26 | static constexpr size_t NUM_REGS = 0xE36; | ||
| 27 | |||
| 28 | enum class QueryMode : u32 { | ||
| 29 | Write = 0, | ||
| 30 | Sync = 1, | ||
| 31 | }; | ||
| 32 | |||
| 33 | union { | ||
| 34 | struct { | ||
| 35 | INSERT_PADDING_WORDS(0x6C0); | ||
| 36 | struct { | ||
| 37 | u32 query_address_high; | ||
| 38 | u32 query_address_low; | ||
| 39 | u32 query_sequence; | ||
| 40 | union { | ||
| 41 | u32 raw; | ||
| 42 | BitField<0, 2, QueryMode> mode; | ||
| 43 | BitField<4, 1, u32> fence; | ||
| 44 | BitField<12, 4, u32> unit; | ||
| 45 | } query_get; | ||
| 46 | |||
| 47 | GPUVAddr QueryAddress() const { | ||
| 48 | return static_cast<GPUVAddr>( | ||
| 49 | (static_cast<GPUVAddr>(query_address_high) << 32) | query_address_low); | ||
| 50 | } | ||
| 51 | } query; | ||
| 52 | INSERT_PADDING_WORDS(0x772); | ||
| 53 | }; | ||
| 54 | std::array<u32, NUM_REGS> reg_array; | ||
| 55 | }; | ||
| 56 | } regs{}; | ||
| 57 | |||
| 58 | static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); | ||
| 59 | |||
| 60 | private: | ||
| 61 | /// Handles a write to the QUERY_GET register. | ||
| 62 | void ProcessQueryGet(); | ||
| 63 | |||
| 64 | MemoryManager& memory_manager; | ||
| 19 | }; | 65 | }; |
| 20 | 66 | ||
| 67 | #define ASSERT_REG_POSITION(field_name, position) \ | ||
| 68 | static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \ | ||
| 69 | "Field " #field_name " has invalid position") | ||
| 70 | |||
| 71 | ASSERT_REG_POSITION(query, 0x6C0); | ||
| 72 | |||
| 73 | #undef ASSERT_REG_POSITION | ||
| 74 | |||
| 21 | } // namespace Engines | 75 | } // namespace Engines |
| 22 | } // namespace Tegra | 76 | } // namespace Tegra |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index a961f3fd4..ba7781756 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -26,7 +26,7 @@ class GPU final { | |||
| 26 | public: | 26 | public: |
| 27 | GPU() { | 27 | GPU() { |
| 28 | memory_manager = std::make_unique<MemoryManager>(); | 28 | memory_manager = std::make_unique<MemoryManager>(); |
| 29 | maxwell_3d = std::make_unique<Engines::Maxwell3D>(); | 29 | maxwell_3d = std::make_unique<Engines::Maxwell3D>(*memory_manager); |
| 30 | fermi_2d = std::make_unique<Engines::Fermi2D>(); | 30 | fermi_2d = std::make_unique<Engines::Fermi2D>(); |
| 31 | maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); | 31 | maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); |
| 32 | } | 32 | } |