Commit Graph

6733 Commits

Author SHA1 Message Date
rofl0r eb74d90c7a
CI: limit autoconf build to 8 processes
hopefully will prevent the OOM killer from kicking in.
2023-02-28 02:59:52 +00:00
rogerman 1daebcd670 Silence some compiler warnings. 2023-02-27 16:36:08 -08:00
rogerman cda8cb5686 Core: Move low-level vector, vertex coordinate, and color data type declarations into types.h so that they can be used universally. Also update the data type names to be more descriptive and have better consistency.
- Add SIMD-float32 data types, and also add macros to track SIMD data-type availability.
- Also fix some bugs where 3D would fail to render on big-endian systems. (Regression from commit a67e040.)
2023-02-27 15:39:17 -08:00
rogerman d9be9c6bf6 Cocoa Port: Silence some compiler warnings. 2023-02-25 12:11:22 -08:00
rogerman a7bdd1e3a9 GFX3D: Remove the mistaken addition of color clamping when converting fixed-point vertex colors into floating-point. Fixes the proper coloring of Princess Peach in the opening sequence of Super Mario 64 DS. (Regression from commit 7751b59.) 2023-02-24 16:01:14 -08:00
rogerman fac70ce98b OpenGL Renderer: Use the fixed-point vertex list data instead of the floating-point based one, alongside other tune-ups.
- To determine polygon facing, use GFX3D's CPoly.isPolyBackFacing instead of using GLSL's gl_FrontFacing. This eases OpenGL version requirements and improves older GPU compatibility a little.
- Also fix a bug where GPUs that support FBOs, but not shaders, were unable to read out their framebuffers properly.
2023-02-24 13:49:07 -08:00
rogerman 37683a708e GFX3D: Y-sorting and writing out vertices to a save state are now handled using fixed-point instead of floating-point, where appropriate. 2023-02-23 13:12:13 -08:00
rogerman 7751b59882 GFX3D: Polygon clipping, viewport transformation, perspective correction, and face calculations are now done in fixed-point instead of floating point. 2023-02-22 22:07:37 -08:00
rogerman e1969c470b GFX3D: Vertex post-processing has been moved from the 3D renderers to GFX3D.
- Specifically, viewport transformation, face calculation, and face culling are now handled in GFX3D, and are now standard behaviors for all 3D renderers. This reorganization makes more sense since the 3D renderers are primarily responsible for rasterization and framebuffer post-processing, rather than for processing geometry.
- As a positive side-effect, the OpenGL renderer gains a small performance improvement as well as better accuracy in face culling.
2023-02-19 20:23:44 -08:00
rogerman 5457932d75 OpenGL Renderer: Fix bug where the Depth L-Equal Polygon Facing option would fail to become enabled when running OpenGL 3.2 or later. (Regression from commit ab38d17. Note that this bug does affect the 0.9.13 release build.) 2023-02-18 16:31:38 -08:00
rogerman cf75e26353 OpenGL Renderer: Silence compiler warnings. 2023-02-18 16:21:44 -08:00
rogerman 97848fce8c GFX3D: Move some last bits of static data floating around in gfx3d.cpp into the GFX3D struct, and then make the instantiation of the struct itself static. 2023-02-18 13:37:17 -08:00
rogerman 92d662cb71 GFX3D: Fix longstanding potential overflows related to polygon lists by reducing POLYLIST_SIZE from 20000 to 16383.
- Historically (ever since commit b1e4934 and commit d5bb6fd), VERTLIST_SIZE (based on POLYLIST_SIZE) could reference an index over 66535, but POLY.vertIndexes has always been an unsigned 16-bit value with a max value of 66535, making for a potential overflow. In practice, an overflow has never happened in the past 15 years because a hardware NDS has a limit of 6144 polygons (or 24576 vertices), and that even a VERTLIST_SIZE of 80000 is way more than plenty to accommodate that. Rather than increasing POLY.vertIndexes to 32-bit, it makes more sense to reduce POLYLIST_SIZE to 16383 to keep VERTLIST_SIZE below 66536. Even with this change, POLYLIST_SIZE and VERTLIST_SIZE should be more than plenty in practice.
- Also, now that we're performing polygon clipping for all client 3D renderers (ever since commit e06d11f), we're finally accounting for the fact that the clipped polygon list size is larger than POLYLIST_SIZE. Client 3D renderers have been updated to now reflect this change and avoid theoretical overflow issues that have never actually happened in practice.
2023-02-18 10:54:02 -08:00
rogerman 86b990f68a GFX3D: The shininess table is no longer a part of SWAP_BUFFERS.
- Since the shininess table is only ever used for vertex generation, it makes no sense for the table to included for the rasterization step. The shininess table has been moved to the NDSGeometryEngine class, which is a class dedicated to just vertex and polygon generation. This reorganization seems more sensible.
2023-02-17 18:32:42 -08:00
rogerman 4a95e9b8d1 GFX3D: Reorder members of the GeometryEngineLegacySave struct to better reflect the actual order of data in the existing save state format.
- Also rename some matrix-related members for better clarity.
2023-02-17 14:01:24 -08:00
rogerman d0d23cce7e GFX3D: Attempt to fix an MSVC compiling issue. (Related to commit 5d6e866.) 2023-02-17 12:00:27 -08:00
rogerman 5d6e8663c4 GFX3D: Finish refactoring geometry engine related stuff into the new NDSGeometryEngine class.
- Also, the vector test has been changed so that the result vector accounts for the 4 sign bits and proper sign expansion on overflow.
2023-02-16 21:58:28 -08:00
rogerman db365e849f GFX3D: Clean up some lighting-related code. 2023-02-16 02:59:05 -08:00
rogerman 79aa5b558e GFX3D: Continue encapsulating stuff into the new NDSGeometryEngine class, mostly focusing on matrix-related things.
- There are two significant behavior changes in this commit that will require further testing.
- Behavior change: Before, MTX_LOAD_4x4 and MTX_LOAD_4x3 commands would update the individual values in the current matrix for each command. Now, these commands will batch the values into a temporary matrix until the temp matrix is complete, and then copy the temp matrix into the current matrix. This now matches the batching behavior that the other matrix commands already do.
- Behavior change: Before, there was a single shared temporary multiplication matrix used to batch the values of incoming MTX_MULT_4x4, MTX_MULT_4x3, and MTX_MULT_3x3 commands, theoretically allowing these commands to be used interchangeably and overwrite values from previous commands until the last command made a completed multiplier matrix. Now, there are 3 separate temporary multiplier matrices, one for each of the MTX_MULT_* commands, which means that each command type must now complete its own multiplier matrix before it can perform a matrix multiply.
2023-02-15 19:59:59 -08:00
rogerman 669f1b05f5 GFX3D: Begin encapsulating stuff into the new NDSGeometryEngine() class.
- Also do some minor misc. code cleanup.
2023-02-15 00:52:23 -08:00
rogerman d03e4a6886 Cocoa Port: In the OpenGL blitter, prevent FBO-related GL calls if FBOs are not available.
- Also silence some compiler warnings.
2023-02-14 23:30:22 -08:00
zeromus d0ed57d1b3 fixed: EMUFILE_FILE eof() on textmode failed on windows (caused .dct files from mac systems freeze process while loading) 2023-02-11 15:59:40 -05:00
rogerman 5831099ebc GFX3D: The Box Test is now performed with integer operations instead of with floating point.
- The integer-based Box Test should be just as good as the old float-based one, as tested by "American Girl: Julie Finds a Way". Of course, there are still bugs compared to a hardware NDS, but we haven't transitioned to rendering with integer-based vertices yet to make a meaningful test possible.
2023-02-10 19:01:16 -08:00
rogerman 624f649acb Oops! Forgot a file. (Related to commit a67e040.) 2023-02-10 18:38:21 -08:00
rogerman a67e040a57 GFX3D: Do some major code cleanup.
- Rename a bunch of variables to better reflect their intended usage.
- Add new data types for organizing 3D vectors and coordinates.
- C functions that are called in response to 3D commands now follow the exact same pattern: “static void gfx3d_glFuncName(const u32 param)”
- Be super explicit about the usage of numeric data types and their typecasts to improve their code visibility.
- Remove implementation-specific ambiguity of right bit-shifting signed numerics (Logical-Shift-Right vs Arithmetic-Shift-Right) in the following functions: gfx3d_glLightDirection_cache(), gfx3d_glNormal(), gfx3d_glTexCoord(), gfx3d_glVertex16b(), gfx3d_glVertex10b(), gfx3d_glVertex3_cord(), gfx3d_glVertex_rel(), gfx3d_glVecTest().
2023-02-10 18:25:21 -08:00
rogerman 242cb63327 GFX3D: Remove POLY struct members that don't need to be swapped. This results in less buffer copying for all POLY lists.
- Also remove Viewer3D_State.indexList. This member is obsolete since Viewer3D_State.gList.clippedPolyList is generated in the same order described by indexList.
- Encapsulate and rename some more lists to make their intended purpose more descriptive.
2023-02-09 00:27:45 -08:00
zeromus 23400431a1
Merge pull request #632 from hjung4/fix/strchr-oob-check
Fix out-of-bounds index access
2023-02-08 12:25:41 -06:00
Henry Jung 0e538b0931 fix: strchr check 2023-02-08 07:54:08 -05:00
rogerman d8ee3480df GFX3D: Clipping functions now take VERT parameters as non-nullable references instead of as nullable pointers where appropriate.
- GFX3D_ClipPoint() (formerly named clipPoint()) now writes directly to the target VERT rather than copying a return value back to the target.
2023-02-06 23:20:46 -08:00
rogerman 9554595948 GFX3D: Various minor tweaks and optimizations, plus code cleanup.
- Most importantly, refactor the GFX3D_Clipper::ClipPoly() method into the standalone GFX3D_GenerateClippedPoly() function, which drops all class member dependencies and is much more straightforward to use.
- Remove the GFX3D_Clipper class. It has been slowly gutted over the years, but the loss of the ClipPoly() method makes the class obsolete, putting the final nail in its coffin.
- Using the new GFX3D_GenerateClippedPoly() function, gfx3d_PerformClipping() operates on the unsorted clipped polygon list directly. This means that the polygon clipping step requires one less buffer copy.
- Clipped polygons no longer retain direct pointers to POLY structs, instead using their index member to reference a POLY struct at a POLY array location. All 3D renderers have been updated to reflect this change.
- Rename a bunch of variables that reference POLY, CPoly, and VERT structs to clearly differentiate them between raw NDS data and our own internally processed data.
- Fix a potential bug in GFX3D_GenerateRenderLists() where sorting clipped polygons would reorder their polygon indices without reordering their other data members along with the indices, causing the data members to desync. OpenGL rendering was immune to this bug, but SoftRasterizer might have possibly seen it. In any case, this fix is the correct behavior.
2023-02-06 17:50:42 -08:00
rogerman 628eb6596a Cocoa Port: Fix some random compiling issues. 2023-02-04 19:33:35 -08:00
rogerman cbbacdbf59 GFX3D: The POLY and VERT structs have been converted to POD-style structs for better data consistency. 2023-02-02 02:19:49 -08:00
rogerman 9273c9ab13 GFX3D: Encapsulate some data into the GFX3D struct, and also do some minor code cleanup. 2023-02-01 16:54:04 -08:00
rogerman a3e84e28c2 Save States: Oops! Fix a bug where 3D vertices were getting double-loaded, causing save state file reads to desync. Fixes #629. (Regression from commit 5426509e.)
- Problems only occurred when LOADING a save state. However, SAVING a save state on commit 5426509e should be okay, so such save states should not be broken.
2023-02-01 15:17:20 -08:00
zeromus 5bcfd2f022
Merge pull request #628 from radioactiveman/master
Fix a few compiler warnings
2023-01-30 16:53:26 -06:00
Thomas Lange ef3f285f95
Fix a few compiler warnings
warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]

Reported by clang 15.
2023-01-30 23:40:50 +01:00
rogerman c9a4d9c4b8 SoftRasterizer: Fix compiling issue for non-SSE2 systems. (Regression from commit 5426509e.) 2023-01-25 19:09:21 -08:00
rogerman 5426509ede GFX3D: Render states and geometry lists are now copied/swapped more consistently on flush. (Related to commit 8438a5a6.)
- Viewports are now processed on VIEWPORT register write instead of being processed at render time.
- CLEAR_DEPTH, CLRIMAGE_OFFSET, EDGE_COLOR, FOG_TABLE, and TOON_TABLE register writes are now handled more consistently.
- The fogDensityTable check for force-drawing clear images in gfx3d_VBlankEndSignal() has been removed. Changes done in commit 8438a5a6 will always causes this check to fail, and this commit will always cause this check to fail. Therefore, this check is now obsolete.
- Change a bunch of GFX3D-related structs from C++ style constructed structs into C-style POD structs.
2023-01-25 18:52:45 -08:00
zeromus be287de623
Merge pull request #627 from RainingChain/fwSettingsMacAddress
Add mac address setting
2023-01-21 16:59:18 -06:00
Raining Chain 9d2ddfa648 Add mac address setting 2023-01-21 17:32:05 -05:00
rogerman f0b0afe18b Colorspace Handler: FragmentColor may now be accessed through a 4-element array, in which elements 0-1-2-3 represent color components R-G-B-A, respectively. 2023-01-19 14:24:35 -08:00
rogerman 2b66e756da Add support for page-aligned variables/arrays.
- Better account for UltraSPARC's unique memory page size.
- malloc_alignedCacheLine() no longer returns 16-byte aligned memory if the architecture is neither 32-bit or 64-bit. Now, the function only returns 64-byte alignment for 64-bit architectures OR 32-byte alignment for 32-bit architectures.
2023-01-19 14:18:58 -08:00
zeromus 8438a5a647 crude hack to fix problem where loadstate could crash if the GPU hasn't ever booted up. see TODO TODO TODO TODO in gfx3d.cpp -- somebody needs to revise the tables so they arent memory mapped but so that they work rather like shininess tables. if they aren't truly latched when the gpu is flushed, then put them in a table anyway and simply reference the live values instead of the latched ones. How to keep from accidentally referencing the latched ones? perhaps the 3d state could be divided into a latched part and an unlatched part via base classes. Could also be done by embedding a "latched" and "unlatched" struct in the gpu but that would involve touching every line of code that used something from it. 2023-01-17 23:32:47 -06:00
zeromus 29c077c165 winport - fix issues with save/load state to japanese filename (fixes #615) 2022-12-05 15:54:38 -05:00
zeromus 91efef9346
Merge pull request #602 from KellanClark/master
Fix division edge cases and prevent crash
2022-10-23 21:07:41 -04:00
Kellan Clark b5b7f29255 Fix division edge cases and prevent crash 2022-10-23 20:22:21 -04:00
rogerman 739f3162d5 Cocoa Port: Fix HUD rendering on the OpenGL blitter for GPUs that don't support shaders. 2022-09-15 15:42:12 -07:00
rogerman 698139ed8e saves.cpp: Fix compiling issue for all non-Windows platforms. (Regression from commit 3a6c8cf9.) 2022-08-04 21:26:55 -07:00
zeromus 3a6c8cf9f8
Merge pull request #523 from Keppl/backup_saves_max_patch
Limit maximum number of backups files for load state backup
2022-08-04 17:33:43 -04:00
zeromus 3614b45a6c
Merge pull request #575 from janisozaur/update-default-joystick-size
Update default joystick cofiguration size in line with #567
2022-08-04 17:32:25 -04:00