summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
AgeCommit message (Collapse)Author
2024-10-29VideoCommon: Implement primitive breaking for primitive listsTellowKrinkle
2024-10-12Cache normals in addition to binormals and tangentsPokechu22
Fixes LIT (https://bugs.dolphin-emu.org/issues/13635). The text does not include normals, but has lighting enabled. With the previous default of (0, 0, 0), lighting was always black (as dot(X, (0, 0, 0)) is always 0). It seems like the normal from the map in the background (0, 0, 1) is re-used. LIT also has the vertex color enabled while vertex color is not specified, the same as SMS's debug cubes; the default MissingColorValue GameINI value of solid white seems to work correctly in this case.
2024-04-20Memmap: Replace GetPointer with GetSpanForAddressJosJuice
To ensure memory safety, callers of GetPointer have to perform a bounds check. But how is this bounds check supposed to be performed? GetPointerForRange contained one implementation of a bounds check, but it was cumbersome, and it also isn't obvious why it's correct. To make doing the right thing easier, this commit changes GetPointer to return a span that tells the caller how many bytes it's allowed to access.
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.
2024-02-01VertexLoaderManager: Use fill() in Init()Lioncash
Same behavior, less code.
2024-02-01VertexLoaderManager: Remove unused entry structLioncash
This isn't used anywhere, so it can be removed.
2023-04-12Resolve [-Wclass-memaccess]Minty-Meeo
2023-03-20VideoCommon:VertexLoaderManager: Only update vertex format in shader manager ↵Robin Kertels
if necessary.
2023-02-09Suppress memcpy writing to an object with no trivial copy-assignment warningsPokechu22
We need to copy padding in most of these cases, and the objects are trivially copyable; however, BitField prevents trivial copy-assignment.
2023-01-31Split AbstractGfx out of RendererScott Mansell
Almost all the virtual functions in Renderer are part of dolphin's "graphics api abstraction layer", which has slowly formed over the last decade or two. Most of the work was done previously with the introduction of the various "AbstractX" classes, associated with texture cache cleanups and implementation of newer graphics APIs (Direct3D 12, Vulkan, Metal). We are simply taking the last step and yeeting these functions out of Renderer. This "AbstractGfx" class is now completely agnostic of any details from the flipper/hollywood GPU we are emulating, though somewhat specialized. (Will not build, this commit only contains changes outside VideoBackends)
2023-01-25VideoCommon: Cull vertices on the CPUTellowKrinkle
2022-12-28VideoCommon: De-globalize VertexShaderManager class.Admiral H. Curtiss
2022-12-03HW/Memmap: Refactor Memory to class, move to Core::System.Admiral H. Curtiss
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-11-18VideoCommon:VertexLoaderManager: Reduce CPConfig checksRobin Kertels
A bit of a micro optimization: CheckCPConfiguration is called 350 times instead of 35k times.
2022-10-24VideoCommon: Treat invalid normal count as NormalTangentBinormalPokechu22
See https://bugs.dolphin-emu.org/issues/13070.
2022-10-09Simplify saving CP statePokechu22
Rather than makring some parts of VertexLoaderManager dirty in some places and some in others, do it all in VideoState. Also, since CPState no longer contains pointers/non-CP data after d039b1bc0dfaba2a88036468b6d971bb1d7e463d, we can just use p.Do on it instead of manually saving each field.
2022-09-19VideoCommon: Add dynamic vertex loader to ubershadersTellowKrinkle
2022-09-19VertexLoaderManager: Clean up and slightly speed up with templatesRobin Kertels
2022-09-15VertexLoaderManager: Fix backwards preprocess checkRobin Kertels
Spotted by Pokechu22.
2022-07-23Convert CP/XF matrix indices mismatch panic alert to a warningPokechu22
https://bugs.dolphin-emu.org/issues/12977 indicates that this happens on startup of Spider-Man 2, even in single-core. I don't have the game, so I can't directly determine why this is happening, but presumably real hardware does not hang in this case, so we can make it less obtrusive.
2022-05-18Show a panic alert if the CP matrix indices don't match the XF matrix indicesPokechu22
This almost certainly never happens, but if it does we want to know.
2022-05-18Show a panic alert if the CP vertex config doesn't match the XF vertex configPokechu22
This probably isn't triggered by real games, but it's possible to accidentally do it with libogc (which results in freezes on real hardware).
2022-04-22VideoCommon: Handle emboss texgen with only a single normalPokechu22
Fixes a large number of effects in Rogue Squadron 2 and 3.
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.
2022-04-22Convert vertex loader position cache to std::arrayPokechu22
2021-12-18Eliminate VarType for ComponentFormatPokechu22
2021-12-18VideoCommon: Move VertexLoaderManager logic out of CPStatePokechu22
2021-12-18Refactor OpcodeDecoding and FIFO analyzer to use callbacksPokechu22
2021-12-18Create and use CPArray enum classPokechu22
2021-12-18Convert OpcodeDecoder::Opcode and OpcodeDecoder::Primitive to enum classPokechu22
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-05-07Move vertex size and component calculation to VertexLoaderBasePokechu22
2021-05-07Remove VertexLoader::ToStringPokechu22
2021-04-06Track and log CP commands 0x00/0x10/0x20 differently from other unknown commandsPokechu22
They appear to relate to perf queries, and combining them with truely unknown commands would probably hide useful information. Furthermore, 0x20 is issued by every title, so without this every title would be recorded as using an unknown command, which is very unhelpful.
2021-04-06Log a warning for inexact uses of MATINDEX or VCD commandsPokechu22
2021-04-06Add game quirks for unknown BP/CP/XF commandsPokechu22
2021-03-26Refactor CP array constants slightlyPokechu22
2021-03-06Convert BPMemory to BitField and enum classPokechu22
Additional changes: - For TevStageCombiner's ColorCombiner and AlphaCombiner, op/comparison and scale/compare_mode have been split as there are different meanings and enums if bias is set to compare. (Shift has also been renamed to scale) - In TexMode0, min_filter has been split into min_mip and min_filter. - In TexImage1, image_type is now cache_manually_managed. - The unused bit in GenMode is now exposed. - LPSize's lineaspect is now named adjust_for_aspect_ratio.
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.
2021-03-06Create constants for CP registers and masksPokechu22
2019-12-05VideoCommon/IndexGenerator: Eliminate static stateLioncash
Now that we've extracted all of the stateless functions that can be hidden, it's time to make the index generator a regular class with active data members. This can just be a member that sits within the vertex manager base class. By deglobalizing the state of the index generator we also get rid of the wonky dual-initializing that was going on within the OpenGL backend. Since the renderer is always initialized before the vertex manager, we now only call Init() once throughout the execution lifecycle.
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: 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.
2019-06-01Common/CommonFuncs: Remove now-unneccessary ArraySize functionLioncash
Since C++17, non-member std::size() is present in the standard library which also operates on regular C arrays. Given that, we can just replace usages of ArraySize with that where applicable. In many cases, we can just change the actual C array ArraySize() was called on into a std::array and just use its .size() member function instead. In some other cases, we can collapse the loops they were used in, into a ranged-for loop, eliminating the need for en explicit bounds query.
2019-05-31VideoCommon: Constrain the array_base registersbooto
The array_base registers as part of CP state do not seem to incorporate the upper bits in the physical address they try to access.
2019-05-06Reformat repo to clang-format 7.0 rulesTechjar
2019-02-19Move most backend functionality to VideoCommonStenzek
2018-03-14Assert: Uppercase assertion macrosLioncash
Macros should be all upper-cased. This is also kind of a wart that's been sticking out for quite a while now (we avoid prefixing underscores).
2017-07-30Vulkan: Uber shader supportStenzek