summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader_Position.cpp
AgeCommit message (Collapse)Author
2024-04-04Fix out of bounds accesses for invalid vertex component formatsPokechu22
On all platforms, this would result in out of bounds accesses when getting the component sizes (which uses stuff from VertexLoader_Position.h/VertexLoader_TextCoord.h/VertexLoader_Normal.h). On platforms other than x64 and ARM64, this would also be out of bounds accesses when getting function pointers for the non-JIT vertex loader (in VertexLoader_Position.cpp etc.). Usually both of these would get data from other entries in the same multi-dimensional array, but the last few entries would be truly out of bounds. This does mean that an out of bounds function pointer can be called on platforms that don't have a JIT vertex loader, but it is limited to invalid component formats with values 5/6/7 due to the size of the bitfield the formats come from, so it seems unlikely that this could be exploited in practice. This issue affects a few games; Def Jam: Fight for New York (https://bugs.dolphin-emu.org/issues/12719) and Fifa Street are known to be affected. I have not done any hardware testing for this PR specifically, though I *think* I previously determined that at least a value of 5 behaves the same as float (4). That's what I implemented in any case. I did previously determine that both Def Jam: Fight for New York and Fifa Street use an invalid normal format, but don't actually have lighting enabled when that normal vector is used, so it doesn't change rendering in practice. The color component format also has two invalid values, but VertexLoader_Color.h/.cpp do check for those invalid ones and return a default value instead of doing an out of bounds access.
2023-01-13VertexLoader: Don't write position_cache if vertex is skippedPokechu22
This is the behavior in the x64 and ARM64 vertex loaders. I don't know if it makes sense (the whole skipped vertex system seems jank, but several games behave incorrectly without it).
2022-11-22VertexLoader: Eliminate use of DataReaderPokechu22
DataReader is generally jank - it has a start and end pointer, but the end pointer is generally not used, and all of the vertex loaders mostly bypassed it anyways. Wrapper code (the vertex loaer test, as well as Fifo.cpp and OpcodeDecoding.cpp) still uses it, as does the software vertex loader (which is not a subclass of VertexLoader). These can probably be eliminated later.
2022-10-25VertexLoader: Remove "too many initializer values" workaround functionsPokechu22
I originally added these in 2b1d1038a6acf0acf75b03ca93c85de6fe6cdf18, for both the TPipelineFunction and the size. The size was moved into the header in fdcd2b7d009cece6ad090143ce954aed713bb11c (making the size functions obsolete), but it seems that the functions themselves are no longer needed now. I think I didn't use this approach before because it would have required ComponentFormatTable and ComponentCountRow to be templated, which would end up resulting in lines that were too long and thus wrapped in awkward places. (I *think* they didn't get inferred properly.) Now that we only need TPipelineFunction, the templating is not needed, and this ends up being a more readable version of the version with the wrapper functions.
2022-09-15VertexLoader: Inline GetSizeRobin Kertels
2022-04-22VertexLoader: Convert count register to remaining registerPokechu22
This more accurately represents what's going on, and also ends at 0 instead of 1, making some indexing operations easier. This also changes it so that position_matrix_index_cache actually starts from index 0 instead of index 1.
2021-12-18Create and use CPArray enum classPokechu22
2021-12-18VertexLoader: Convert to EnumMapPokechu22
2021-07-05treewide: convert GPLv2+ license info to SPDX tagsPierre Bourdon
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-03-06Convert CPMemory to BitField and enum classPokechu22
Additionally, VCacheEnhance has been added to UVAT_group1. According to YAGCD, this field is always 1. TVtxDesc also now has separate low and high fields whose hex values correspond with the proper registers, instead of having one 33-bit value. This change was made in a way that should be backwards-compatible.
2019-05-30VertexLoader_Position: Tidy up public function definitionsLioncash
We can use u32 instead of unsigned int to shorten up these definitions and make them much nicer to read. While we're at it, change the size array to house u32 elements to match the return value of the function.
2019-05-30VertexLoader_Position: Make lookup tables immutableLioncash
Allows the compiler to place these arrays within the read-only segment.
2019-05-30VertexLoader_Position: Place helper functions in anonymous namespaceLioncash
2018-04-12Reformat all the things!spycrab
2017-03-03Common: Move byte swapping utilities into their own headerLioncash
This moves all the byte swapping utilities into a header named Swap.h. A dedicated header is much more preferable here due to the size of the code itself. In general usage throughout the codebase, CommonFuncs.h was generally only included for these functions anyway. These being in their own header avoids dumping the lesser used utilities into scope. As well as providing a localized area for more utilities related to byte swapping in the future (should they be needed). This also makes it nicer to identify which files depend on the byte swapping utilities in particular. Since this is a completely new header, moving the code uncovered a few indirect includes, as well as making some other inclusions unnecessary.
2016-06-24Reformat all the things. Have fun with merge conflicts.Pierre Bourdon
2016-01-17VideoCommon: Header cleanupLioncash
Also remedies places where the video backends and core rely on things being indirectly included.
2015-08-28Fix building with PCH disabled.Rohit Nirmal
2015-06-20VertexLoader: Remove the LOADERDECL define.Lioncash
These functions aren't called from jitted code anymore so it isn't necessary.
2015-06-07zfreeze: cache vertex positionsTillmann Karras
Suggested by degasus.
2015-05-30Clean up cached_arraybases. Update VideoSW to new scheme.Scott Mansell
Move ownership of cached_arraybases from CPMemory to VertexLoaderManager to better match it usage.
2015-05-25Set copyright year to when a file was createdTillmann Karras
2015-05-25Update license headers to GPLv2+Tillmann Karras
2015-03-18VertexLoaders: make positions more compactTillmann Karras
2015-02-25Formatting/Whitespace CleanupStevoisiak
Various fixes to formatting and whitespace
2015-01-20VertexLoader: remove non-JIT SSE codeTillmann Karras
2015-01-19VertexLoader_Position: remove old JIT ideasTillmann Karras
2015-01-18DataReader: turn WritePointer into GetPointerTillmann Karras
2014-12-21VertexLoader: Skip vertices with position index = -1degasus
2014-12-21VertexLoader: Add a VertexLoader pointer to each function calldegasus
2014-12-09VideoCommon: Rename s_pCurBufferPointerdegasus
2014-12-09VideoCommon: rewrite DataReaderdegasus
2014-11-20Vertex Loader: SSE implementations of more position/texcoord/normal formatsFiora
~35-45% faster NFS:HP2, possibly other vertex-bound games.
2014-09-28Mechanical changes to move most CP state to a struct rather than separate ↵comex
globals. The next commit will add a separate copy of the struct and the ability for LoadCPReg to work on it.
2014-09-08Include CommonTypes.h instead of Common.h.Rohit Nirmal
2014-09-01VertexLoader: Change VtxDesc to use u64 instead of u32Pierre Bourdon
This is required to make packing consistent between compilers: with u32, MSVC would not allocate a bitfield that spans two u32s (it would leave a "hole").
2014-08-30Get rid of C-style empty function parameter indicatorsLioncash
2014-07-11avoid the extern keyword in .cpp filesdegasus
2014-03-09clang-modernize -use-nullptrTillmann Karras
and s/\bNULL\b/nullptr/g for *.cpp/h/mm files not compiled on my machine
2014-02-18Convert all includes to relative paths.Lioncash
2014-01-21VertexLoader: temp class for reader/writerdegasus
2014-01-21VertexLoader: inline destionation bufferdegasus
2014-01-21VertexLoader: load scale factor as const, this will save some assembler ↵degasus
instructions
2014-01-16VertexLoader: don't check for possible rangedegasus
I(index) < std::numeric_limits<I>::max() is always true, so we don't have to check it
2013-12-31Remove unnecessary Src/ foldersJasper St. Pierre