Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
10c6d891
There was an error fetching the commit references. Please try again later.
Commit
10c6d891
authored
6 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
memory_manager: Add implement CpuToGpuAddress.
parent
239ac8ab
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/video_core/memory_manager.cpp
+17
-0
17 additions, 0 deletions
src/video_core/memory_manager.cpp
src/video_core/memory_manager.h
+10
-0
10 additions, 0 deletions
src/video_core/memory_manager.h
with
27 additions
and
0 deletions
src/video_core/memory_manager.cpp
+
17
−
0
View file @
10c6d891
...
@@ -38,6 +38,9 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
...
@@ -38,6 +38,9 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
PageSlot
(
*
gpu_addr
+
offset
)
=
cpu_addr
+
offset
;
PageSlot
(
*
gpu_addr
+
offset
)
=
cpu_addr
+
offset
;
}
}
MappedRegion
region
{
cpu_addr
,
*
gpu_addr
,
size
};
mapped_regions
.
push_back
(
region
);
return
*
gpu_addr
;
return
*
gpu_addr
;
}
}
...
@@ -49,6 +52,9 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size)
...
@@ -49,6 +52,9 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size)
PageSlot
(
gpu_addr
+
offset
)
=
cpu_addr
+
offset
;
PageSlot
(
gpu_addr
+
offset
)
=
cpu_addr
+
offset
;
}
}
MappedRegion
region
{
cpu_addr
,
gpu_addr
,
size
};
mapped_regions
.
push_back
(
region
);
return
gpu_addr
;
return
gpu_addr
;
}
}
...
@@ -84,6 +90,17 @@ boost::optional<VAddr> MemoryManager::GpuToCpuAddress(GPUVAddr gpu_addr) {
...
@@ -84,6 +90,17 @@ boost::optional<VAddr> MemoryManager::GpuToCpuAddress(GPUVAddr gpu_addr) {
return
base_addr
+
(
gpu_addr
&
PAGE_MASK
);
return
base_addr
+
(
gpu_addr
&
PAGE_MASK
);
}
}
std
::
vector
<
GPUVAddr
>
MemoryManager
::
CpuToGpuAddress
(
VAddr
cpu_addr
)
const
{
std
::
vector
<
GPUVAddr
>
results
;
for
(
const
auto
&
region
:
mapped_regions
)
{
if
(
cpu_addr
>=
region
.
cpu_addr
&&
cpu_addr
<
(
region
.
cpu_addr
+
region
.
size
))
{
u64
offset
=
cpu_addr
-
region
.
cpu_addr
;
results
.
push_back
(
region
.
gpu_addr
+
offset
);
}
}
return
results
;
}
bool
MemoryManager
::
IsPageMapped
(
GPUVAddr
gpu_addr
)
{
bool
MemoryManager
::
IsPageMapped
(
GPUVAddr
gpu_addr
)
{
return
PageSlot
(
gpu_addr
)
!=
static_cast
<
u64
>
(
PageStatus
::
Unmapped
);
return
PageSlot
(
gpu_addr
)
!=
static_cast
<
u64
>
(
PageStatus
::
Unmapped
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/video_core/memory_manager.h
+
10
−
0
View file @
10c6d891
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include
<array>
#include
<array>
#include
<memory>
#include
<memory>
#include
<vector>
#include
<boost/optional.hpp>
#include
<boost/optional.hpp>
...
@@ -26,6 +27,7 @@ public:
...
@@ -26,6 +27,7 @@ public:
GPUVAddr
MapBufferEx
(
VAddr
cpu_addr
,
u64
size
);
GPUVAddr
MapBufferEx
(
VAddr
cpu_addr
,
u64
size
);
GPUVAddr
MapBufferEx
(
VAddr
cpu_addr
,
GPUVAddr
gpu_addr
,
u64
size
);
GPUVAddr
MapBufferEx
(
VAddr
cpu_addr
,
GPUVAddr
gpu_addr
,
u64
size
);
boost
::
optional
<
VAddr
>
GpuToCpuAddress
(
GPUVAddr
gpu_addr
);
boost
::
optional
<
VAddr
>
GpuToCpuAddress
(
GPUVAddr
gpu_addr
);
std
::
vector
<
GPUVAddr
>
CpuToGpuAddress
(
VAddr
cpu_addr
)
const
;
static
constexpr
u64
PAGE_BITS
=
16
;
static
constexpr
u64
PAGE_BITS
=
16
;
static
constexpr
u64
PAGE_SIZE
=
1
<<
PAGE_BITS
;
static
constexpr
u64
PAGE_SIZE
=
1
<<
PAGE_BITS
;
...
@@ -51,6 +53,14 @@ private:
...
@@ -51,6 +53,14 @@ private:
using
PageBlock
=
std
::
array
<
VAddr
,
PAGE_BLOCK_SIZE
>
;
using
PageBlock
=
std
::
array
<
VAddr
,
PAGE_BLOCK_SIZE
>
;
std
::
array
<
std
::
unique_ptr
<
PageBlock
>
,
PAGE_TABLE_SIZE
>
page_table
{};
std
::
array
<
std
::
unique_ptr
<
PageBlock
>
,
PAGE_TABLE_SIZE
>
page_table
{};
struct
MappedRegion
{
VAddr
cpu_addr
;
GPUVAddr
gpu_addr
;
u64
size
;
};
std
::
vector
<
MappedRegion
>
mapped_regions
;
};
};
}
// namespace Tegra
}
// namespace Tegra
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment