dolphin/Source/Core/VideoBackends/Metal
Pokechu22 a3951dc2d7 Fix out of bounds accesses for invalid vertex component formats
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-04-04 12:50:34 -07:00
..
CMakeLists.txt Implement AbstactGfx for Metal 2023-01-31 19:41:24 +13:00
MRCHelpers.h
MTLBoundingBox.h VideoCommon: Use std::span for BoundingBox::Write() 2023-12-09 16:33:21 -05:00
MTLBoundingBox.mm VideoCommon: Use std::span for BoundingBox::Write() 2023-12-09 16:33:21 -05:00
MTLGfx.h VideoBackends: support multiple compute images for some backends (D3D, OGL, Vulkan) 2023-06-28 17:15:31 -05:00
MTLGfx.mm VideoBackends / VideoCommon: add type enum to dictate whether a texture is a 2D texture, a texture array, or a cube map; support 2D texture type across backends 2023-12-15 11:06:02 -06:00
MTLMain.mm Add HDR to Metal 2024-03-10 03:25:33 -04:00
MTLObjectCache.h Lint fixes 2023-02-09 18:36:20 +13:00
MTLObjectCache.mm VideoBackends:Metal: Multi render target support 2023-06-28 00:11:37 -05:00
MTLPerfQuery.h VideoBackends:Metal: Implement PerfQuery 2022-07-21 20:44:19 -05:00
MTLPerfQuery.mm Return quarter value for PerfQuery in all backends. 2023-03-14 02:08:20 +01:00
MTLPipeline.h VideoBackends:Metal: Support multiple compute textures 2023-11-29 18:45:11 -06:00
MTLPipeline.mm VideoBackends:Metal: Support multiple compute textures 2023-11-29 18:45:11 -06:00
MTLShader.h VideoBackends:Metal: Cache pipelines 2022-07-21 20:44:19 -05:00
MTLShader.mm VideoBackends:Metal: Cache pipelines 2022-07-21 20:44:19 -05:00
MTLStateTracker.h Merge pull request #12370 from iwubcode/more_samplers 2023-12-17 14:50:23 -05:00
MTLStateTracker.mm VideoBackends:Metal: Support multiple compute textures 2023-11-29 18:45:11 -06:00
MTLTexture.h VideoBackends:Metal: Multi render target support 2023-06-28 00:11:37 -05:00
MTLTexture.mm VideoBackends:Metal: Multi render target support 2023-06-28 00:11:37 -05:00
MTLUtil.h Add HDR to Metal 2024-03-10 03:25:33 -04:00
MTLUtil.mm Add HDR to Metal 2024-03-10 03:25:33 -04:00
MTLVertexFormat.h VideoBackends:Metal: Cache pipelines 2022-07-21 20:44:19 -05:00
MTLVertexFormat.mm Fix out of bounds accesses for invalid vertex component formats 2024-04-04 12:50:34 -07:00
MTLVertexManager.h VideoBackends:Metal: Use base vertex 2022-07-21 20:44:19 -05:00
MTLVertexManager.mm VideoCommon: De-globalize GeometryShaderManager class. 2022-12-29 15:33:19 +01:00
VideoBackend.h VideoCommon: Pass WindowSystemInfo to InitBackendInfo 2023-06-08 22:07:39 -07:00