Commit graph

64 commits

Author SHA1 Message Date
Pokechu22
0afe318b55 OpcodeDecoding: Make s_is_fifo_error_seen static 2021-12-18 15:21:48 -08:00
Pokechu22
d039b1bc0d VideoCommon: Move VertexLoaderManager logic out of CPState 2021-12-18 15:21:48 -08:00
Pokechu22
d84d695fdf Remove DataReader from LoadXFReg 2021-12-18 15:21:48 -08:00
Pokechu22
b5fd35f951 Refactor OpcodeDecoding and FIFO analyzer to use callbacks 2021-12-18 15:21:36 -08:00
Pokechu22
1914087998 Create and use CPArray enum class 2021-12-18 12:51:56 -08:00
Pokechu22
3aaeb2b9ef Convert OpcodeDecoder::Opcode and OpcodeDecoder::Primitive to enum class 2021-12-18 12:51:56 -08:00
Scott Mansell
f5c550e9cb Delay singlecore gpu interrupts
Fixes Bomberman Jetters in single core mode.

When single core mode pauses the CPU to execute the GPU
FIFO it greedily executes the whole thing. Before this commit,
Finish and Token interrupts would happen instantly, not even
taking into account how long the current FIFO window has
taken to execute. The interrupts would be effectively backdated
to the start of this execution window.

This commit does two things: It pipes the current FIFO window
execution time though to the interrupt scheduling and it enforces
a minimum delay of 500 cycles before an interrupt will be fired.
2021-11-25 11:11:01 +13:00
Pierre Bourdon
e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Lioncash
3d9b2aa005 VideoCommon: Migrate over to fmt
Migrates off the printf-based formatting where applicable.
2020-11-17 21:23:58 -05:00
Lioncash
1f46a6a64b VideoCommon/OpcodeDecoding: Make use of if constexpr
We can make use of if constexpr in several scenarios here to allow
compilers to exise the relevant code paths out.

Technically a decent compiler would do this already, but now we can give
compilers a little more nudging here in the event that isn't the case.
2019-12-05 09:13:06 -05:00
Lioncash
99353c3baa VideoCommon/OpcodeDecoding: Remove unused headers
Nothing provided by these headers are used, so we can remove them.
2019-12-05 09:13:06 -05:00
Lioncash
6339a5ea8e VideoCommon/OpcodeDecoding: Resolve implicit signedness conversion
cmd2 is a u32, so any bitwise arithmetic on it with a type of the same
size or smaller will result in a u32 value. This is also implicitly
converted to an unsigned type in the if statement as well, given that
size_t * int -> size_t.

This is just more explicit about the operations occurring and also
likely silences a sign conversion warning.
2019-12-05 09:13:06 -05:00
Lioncash
4710b82f43 VideoCommon/OpcodeDecoding: Remove use of goto in Run()
With the use of a lambda and a change in switch fallthrough, we can
completely eliminate the use of goto within Run().
2019-12-05 09:13:06 -05:00
Lioncash
f74503cce0 VideoCommon/OpcodeDecoding: Make use of anonymous namespace
Provides a region for all internal utilities.
2019-12-05 09:13:06 -05:00
Lioncash
6b4e340995 VideoCommon/OpcodeDecoding: Amend comment formatting
Amends a documentation comment that acquired some wonky formatting
during the introduction of clang-format a few years ago.
2019-12-05 09:13:06 -05:00
Lioncash
b2a9c36501 VideoCommon/OpcodeDecoding: Move g_bRecordFifoData into namespace
Keeps the global localized with the code that it's primarily related to.

Now it's obvious from a glance what the global variable is affecting.
2019-12-05 09:13:03 -05:00
Lioncash
d8063e9c54 VideoCommon/OpcodeDecoding: Normalize variable naming
Provides consistent naming of variables within the translation unit.

While we're at it, we can mark them const where applicable.
2019-12-05 08:05:29 -05:00
Lioncash
d4337eebde VideoCommon/Statistics: Rename stats global to g_stats
Makes the global variable follow our convention of prefixing g_ on
global variables to make it obvious in surrounding code that it's not a
local variable.
2019-07-10 23:34:54 -04:00
Lioncash
9802a5e16b VideoCommon/Statistics: Make all member functions non-static
Rather than making Statistics' member functions operate on the global
variable instance of itself, we can make these functions member
functions and operate on a by-instance state, removing the direct
dependency on the global variable itself.

This also makes for less reading, as there's no need to repeat "stats."
for all variable accesses.
2019-07-10 23:24:37 -04:00
Lioncash
a99c7d01e1 VideoCommon/Statistics: Normalize statistic variable names
Normalizes all variables related to statistics so that they follow our
coding style.

These are relatively low traffic areas, so this modification isn't too
noisy.
2019-07-10 23:19:10 -04:00
degasus
3787af9ee9 CommandProcessor: Limit scope of ugly SCPFifoStruct.
It's only used as an interface between two classes. So no need to declare
it in the backend export header.
2017-01-27 19:04:56 +01:00
anthony
b427ead0cc Remove Frameskip 2016-10-08 11:49:51 -05:00
aldelaro5
f0aa9b3751 Reorganise a ton of logs level
Most of this commits changes performance decreasing logs from info to debug and also cleans up innacurate levels.
2016-10-01 15:50:28 -04:00
degasus
7833ff25df VideoBackends: Merge Initialize and Shutdown functions. 2016-06-26 12:34:59 +02:00
Pierre Bourdon
3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Lioncash
32ce2be2bf Fifo: Make g_use_deterministic_gpu_thread a TU-local variable 2016-01-25 05:24:03 -05:00
Lioncash
5ebd1e215b Fifo: Make g_bSkipCurrentFrame a TU-local variable
This is only ever queried, making it a global isn't necessary.
2016-01-25 05:23:14 -05:00
Lioncash
e187c55bdd OpcodeDecoder: Add namespace 2016-01-24 01:31:36 -05:00
Lioncash
d9fec92628 VideoCommon: Header cleanup
Also remedies places where the video backends and core rely on things
being indirectly included.
2016-01-17 20:11:45 -05:00
degasus
5f244abf28 Fifo: Create a "Fifo" namespace. 2016-01-12 23:28:26 +01:00
JosJuice
74ea765427 Mark more strings for translation 2015-11-20 11:33:47 +01:00
Tillmann Karras
30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras
cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
Tillmann Karras
f82afd1b2f Fix warnings 2015-03-16 19:02:30 +01:00
skidau
cdff138c67 Show no more than one FIFO error per session. 2015-03-13 23:25:15 +11:00
Stevoisiak
93b16a4a2d Formatting/Whitespace Cleanup
Various fixes to formatting and whitespace
2015-02-25 10:48:21 -05:00
Tillmann Karras
1aac65f988 VertexLoaderManager: assimilate GetVertexSize() 2015-01-31 09:23:50 +01:00
degasus
20628b6e5d OpcodeDecoder: Calculate decoding time for vertices 2015-01-29 19:55:28 +01:00
Tillmann Karras
2cedc0034d DataReader: turn WritePointer into GetPointer 2015-01-18 12:59:33 +01:00
degasus
3fc7e55cc4 VideoCommon: clean up VertexLoader 2014-12-09 18:56:27 +01:00
degasus
21970c4a2a VideoCommon: cleanup OpcodeDecoder 2014-12-09 18:56:27 +01:00
degasus
4b22885ed8 VideoCommon: fifo cleanups 2014-12-09 18:56:27 +01:00
skidau
3d448e49c6 Update CPStatus before processing the FIFO events and force an exception check on interrupts.
Added more information into the FIFO unknown opcode error message.
2014-11-19 12:48:08 +11:00
degasus
90613a1bda OpcodeDecoder: Skip recursiv display lists 2014-11-15 16:24:06 +01:00
Lioncash
884ec2ed13 Host: Kill off Host_SysMessage
Equivalent facilities already exist.
2014-11-05 02:30:48 -05:00
comex
65af90669b Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...

The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data.  Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic.  Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.

My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point).  Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much.  However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all.  (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)

With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done).  Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.

Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render.  That makes up the bulk of this commit.

In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.

The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.

Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches.  When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.

* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame.  For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-09-28 21:34:29 -04:00
comex
0ae9e398c8 Rejigger some FIFO buffer variables to be more rational.
videoBuffer -> s_video_buffer
size -> s_video_buffer_write_ptr
g_pVideoData -> g_video_buffer_read_ptr (impl moved to Fifo.cpp)

This eradicates the wonderful use of 'size' as a global name, and makes
it clear that s_video_buffer_write_ptr and g_video_buffer_read_ptr are
the two ends of the FIFO buffer s_video_buffer.

Oh, and remove a useless namespace {}.
2014-09-28 21:25:12 -04:00
Rohit Nirmal
fbc64984ca Include CommonTypes.h instead of Common.h. 2014-09-08 15:39:58 -04:00
Dolphin Bot
830a03c540 Merge pull request #957 from degasus/frame_skipping
VideoCommon: rewrite frame skipping code
2014-09-04 18:27:19 +02:00
degasus
8b84ddce9a VideoCommon: rewrite frame skipping code 2014-09-04 18:07:39 +02:00