summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/OpcodeDecoding.cpp
AgeCommit message (Collapse)Author
2020-11-17VideoCommon: Migrate over to fmtLioncash
Migrates off the printf-based formatting where applicable.
2019-12-05VideoCommon/OpcodeDecoding: Make use of if constexprLioncash
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-05VideoCommon/OpcodeDecoding: Remove unused headersLioncash
Nothing provided by these headers are used, so we can remove them.
2019-12-05VideoCommon/OpcodeDecoding: Resolve implicit signedness conversionLioncash
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-05VideoCommon/OpcodeDecoding: Remove use of goto in Run()Lioncash
With the use of a lambda and a change in switch fallthrough, we can completely eliminate the use of goto within Run().
2019-12-05VideoCommon/OpcodeDecoding: Make use of anonymous namespaceLioncash
Provides a region for all internal utilities.
2019-12-05VideoCommon/OpcodeDecoding: Amend comment formattingLioncash
Amends a documentation comment that acquired some wonky formatting during the introduction of clang-format a few years ago.
2019-12-05VideoCommon/OpcodeDecoding: Move g_bRecordFifoData into namespaceLioncash
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-05VideoCommon/OpcodeDecoding: Normalize variable namingLioncash
Provides consistent naming of variables within the translation unit. While we're at it, we can mark them const where applicable.
2019-07-10VideoCommon/Statistics: Rename stats global to g_statsLioncash
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-10VideoCommon/Statistics: Make all member functions non-staticLioncash
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-10VideoCommon/Statistics: Normalize statistic variable namesLioncash
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.
2017-01-27CommandProcessor: Limit scope of ugly SCPFifoStruct.degasus
It's only used as an interface between two classes. So no need to declare it in the backend export header.
2016-10-08Remove Frameskipanthony
2016-10-01Reorganise a ton of logs levelaldelaro5
Most of this commits changes performance decreasing logs from info to debug and also cleans up innacurate levels.
2016-06-26VideoBackends: Merge Initialize and Shutdown functions.degasus
2016-06-24Reformat all the things. Have fun with merge conflicts.Pierre Bourdon
2016-01-25Fifo: Make g_use_deterministic_gpu_thread a TU-local variableLioncash
2016-01-25Fifo: Make g_bSkipCurrentFrame a TU-local variableLioncash
This is only ever queried, making it a global isn't necessary.
2016-01-24OpcodeDecoder: Add namespaceLioncash
2016-01-17VideoCommon: Header cleanupLioncash
Also remedies places where the video backends and core rely on things being indirectly included.
2016-01-12Fifo: Create a "Fifo" namespace.degasus
2015-11-20Mark more strings for translationJosJuice
2015-05-25Set copyright year to when a file was createdTillmann Karras
2015-05-25Update license headers to GPLv2+Tillmann Karras
2015-03-16Fix warningsTillmann Karras
2015-03-13Show no more than one FIFO error per session.skidau
2015-02-25Formatting/Whitespace CleanupStevoisiak
Various fixes to formatting and whitespace
2015-01-31VertexLoaderManager: assimilate GetVertexSize()Tillmann Karras
2015-01-29OpcodeDecoder: Calculate decoding time for verticesdegasus
2015-01-18DataReader: turn WritePointer into GetPointerTillmann Karras
2014-12-09VideoCommon: clean up VertexLoaderdegasus
2014-12-09VideoCommon: cleanup OpcodeDecoderdegasus
2014-12-09VideoCommon: fifo cleanupsdegasus
2014-11-19Update CPStatus before processing the FIFO events and force an exception ↵skidau
check on interrupts. Added more information into the FIFO unknown opcode error message.
2014-11-15OpcodeDecoder: Skip recursiv display listsdegasus
2014-11-05Host: Kill off Host_SysMessageLioncash
Equivalent facilities already exist.
2014-09-28Add the 'desynced GPU thread' mode.comex
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-28Rejigger some FIFO buffer variables to be more rational.comex
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-08Include CommonTypes.h instead of Common.h.Rohit Nirmal
2014-09-04Merge pull request #957 from degasus/frame_skippingDolphin Bot
VideoCommon: rewrite frame skipping code
2014-09-04VideoCommon: rewrite frame skipping codedegasus
2014-09-04VideoCommon: remove XFReg copy optimizationdegasus
This code is just ugly and I doubt there is a way that copying twice is faster.
2014-09-01Refactor opcode decoding a bit to kill FifoCommandRunnable.comex
Separated out from my gpu-determinism branch by request. It's not a big commit; I just like to write long commit messages. The main reason to kill it is hopefully a slight performance improvement from avoiding the double switch (especially in single core mode); however, this also improves cycle calculation, as described below. - FifoCommandRunnable is removed; in its stead, Decode returns the number of cycles (which only matters for "sync" GPU mode), or 0 if there was not enough data, and is also responsible for unknown opcode alerts. Decode and DecodeSemiNop are almost identical, so the latter is replaced with a skipped_frame parameter to Decode. Doesn't mean we can't improve skipped_frame mode to do less work; if, at such a point, branching on it has too much overhead (it certainly won't now), it can always be changed to a template parameter. - FifoCommandRunnable used a fixed, large cycle count for display lists, regardless of the contents. Presumably the actual hardware's processing time is mostly the processing time of whatever commands are in the list, and with this change InterpretDisplayList can just return the list's cycle count to be added to the total. (Since the calculation for this is part of Decode, it didn't seem easy to split this change up.) To facilitate this, Decode also gains an explicit 'end' parameter in lieu of FifoCommandRunnable's call to GetVideoBufferEndPtr, which can point to there or to the end of a display list (or elsewhere in gpu-determinism, but that's another story). Also, as a small optimization, InterpretDisplayList now calls OpcodeDecoder_Run rather than having its own Decode loop, to allow Decode to be inlined (haven't checked whether this actually happens though). skipped_frame mode still does not traverse display lists and uses the old fake value of 45 cycles. degasus has suggested that this hack is not essential for performance and can be removed, but I want to separate any potential performance impact of that from this commit.
2014-08-26A tiny restructuring to allow inlining of FifoCommandRunnable. Probably ↵comex
useless.
2014-07-11remove unused globalsdegasus
Also change globals into statics which are only used in one file
2014-07-11mark all local functions as staticdegasus
2014-06-27VideoCommon: remove unused statsdegasus
2014-06-18Kill off replaceable usages of s[n]printf.Lioncash
2014-05-08Opcode decoding: 0xC0 isn't a valid command.magumagu
Fix our opcode decoders to handle this appropriately.