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
5799025a
There was an error fetching the commit references. Please try again later.
Commit
5799025a
authored
10 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
GPU: Further improve synchronization.
parent
4783133b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/hw/gpu.cpp
+20
-22
20 additions, 22 deletions
src/core/hw/gpu.cpp
with
20 additions
and
22 deletions
src/core/hw/gpu.cpp
+
20
−
22
View file @
5799025a
...
...
@@ -21,12 +21,10 @@ namespace GPU {
Regs
g_regs
;
u32
g_cur_line
=
0
;
///< Current vertical screen line
u64
g_last_line_ticks
=
0
;
///< CPU tick count from last vertical screen line
u64
g_last_frame_ticks
=
0
;
///< CPU tick count from last frame
static
u32
kFrameCycles
=
0
;
///< 268MHz / 60 frames per second
static
u32
kFrameTicks
=
0
;
///< Approximate number of instructions/frame
static
u64
frame_ticks
=
0
;
///< 268MHz / 60 frames per second
static
u32
cur_line
=
0
;
///< Current vertical screen line
static
u64
last_frame_ticks
=
0
;
///< CPU tick count from last frame
static
u64
last_update_tick
=
0
;
///< CPU ticl count from last GPU update
template
<
typename
T
>
inline
void
Read
(
T
&
var
,
const
u32
raw_addr
)
{
...
...
@@ -34,7 +32,7 @@ inline void Read(T &var, const u32 raw_addr) {
u32
index
=
addr
/
4
;
// Reads other than u32 are untested, so I'd rather have them abort than silently fail
if
(
index
>=
Regs
::
NumIds
()
||
!
std
::
is_same
<
T
,
u32
>::
value
)
{
if
(
index
>=
Regs
::
NumIds
()
||
!
std
::
is_same
<
T
,
u32
>::
value
)
{
LOG_ERROR
(
HW_GPU
,
"unknown Read%lu @ 0x%08X"
,
sizeof
(
var
)
*
8
,
addr
);
return
;
}
...
...
@@ -48,7 +46,7 @@ inline void Write(u32 addr, const T data) {
u32
index
=
addr
/
4
;
// Writes other than u32 are untested, so I'd rather have them abort than silently fail
if
(
index
>=
Regs
::
NumIds
()
||
!
std
::
is_same
<
T
,
u32
>::
value
)
{
if
(
index
>=
Regs
::
NumIds
()
||
!
std
::
is_same
<
T
,
u32
>::
value
)
{
LOG_ERROR
(
HW_GPU
,
"unknown Write%lu 0x%08X @ 0x%08X"
,
sizeof
(
data
)
*
8
,
(
u32
)
data
,
addr
);
return
;
}
...
...
@@ -179,7 +177,6 @@ template void Write<u8>(u32 addr, const u8 data);
/// Update hardware
void
Update
()
{
auto
&
framebuffer_top
=
g_regs
.
framebuffer_config
[
0
];
u64
current_ticks
=
Core
::
g_app_core
->
GetTicks
();
// Update the frame after a certain number of CPU ticks have elapsed. This assumes that the
// active frame in memory is always complete to render. There also may be issues with this
...
...
@@ -189,9 +186,9 @@ void Update() {
// primitive homebrew relies on a vertical blank interrupt to happen inevitably (regardless of a
// threading reschedule).
if
((
current_t
icks
-
g_
last_frame_ticks
)
>
GPU
::
kF
rame
T
icks
)
{
if
((
Core
::
g_app_core
->
GetT
icks
()
-
last_frame_ticks
)
>
(
GPU
::
f
rame
_t
icks
)
)
{
VideoCore
::
g_renderer
->
SwapBuffers
();
g_
last_frame_ticks
=
current_t
icks
;
last_frame_ticks
=
Core
::
g_app_core
->
GetT
icks
()
;
}
// Synchronize GPU on a thread reschedule: Because we cannot accurately predict a vertical
...
...
@@ -199,17 +196,20 @@ void Update() {
// accurately when this is signalled between thread switches.
if
(
HLE
::
g_reschedule
)
{
u64
current_ticks
=
Core
::
g_app_core
->
GetTicks
();
u64
line_ticks
=
(
GPU
::
frame_ticks
/
framebuffer_top
.
height
)
*
16
;
// Synchronize line...
if
((
current_ticks
-
g_
last_
lin
e_tick
s
)
>=
GPU
::
kFrameTicks
/
framebuffer_top
.
height
)
{
//
//
Synchronize line...
if
((
current_ticks
-
last_
updat
e_tick
)
>=
line_ticks
)
{
GSP_GPU
::
SignalInterrupt
(
GSP_GPU
::
InterruptId
::
PDC0
);
g_
cur_line
++
;
g_
last_
lin
e_tick
s
=
current
_ticks
;
cur_line
++
;
last_
updat
e_tick
+=
line
_ticks
;
}
// Synchronize frame...
if
(
g_cur_line
>=
framebuffer_top
.
height
)
{
g_cur_line
=
0
;
if
(
cur_line
>=
framebuffer_top
.
height
)
{
cur_line
=
0
;
VideoCore
::
g_renderer
->
SwapBuffers
();
GSP_GPU
::
SignalInterrupt
(
GSP_GPU
::
InterruptId
::
PDC1
);
}
}
...
...
@@ -217,11 +217,9 @@ void Update() {
/// Initialize hardware
void
Init
()
{
kFrameCycles
=
268123480
/
Settings
::
values
.
gpu_refresh_rate
;
kFrameTicks
=
kFrameCycles
/
3
;
g_cur_line
=
0
;
g_last_frame_ticks
=
g_last_line_ticks
=
Core
::
g_app_core
->
GetTicks
();
frame_ticks
=
268123480
/
Settings
::
values
.
gpu_refresh_rate
;
cur_line
=
0
;
last_update_tick
=
last_frame_ticks
=
Core
::
g_app_core
->
GetTicks
();
auto
&
framebuffer_top
=
g_regs
.
framebuffer_config
[
0
];
auto
&
framebuffer_sub
=
g_regs
.
framebuffer_config
[
1
];
...
...
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