Commit Graph

35 Commits

Author SHA1 Message Date
Ahmad Abdallah 2c1e8ed840 Fix GX_NRM_NBT and GX_NRM_NBT3 vertex attribute handling (#181)
* Fix GX_NRM_NBT and GX_NRM_NBT3 vertex attribute handling

* Fix GX_NRM_NBT3 indexing, add GX_TG_BINRM/GX_TG_TANGENT support

* Add GX_TG_BUMP emboss bump mapping support
2026-06-03 20:52:26 -06:00
SuperDude88 7ba0d010cc Implement GX2SetPolygonOffset
Co-authored-by: Lurs <2795933+Lurs@users.noreply.github.com>

Co-authored-by: Luke Street <luke@street.dev>
2026-05-30 10:25:07 -06:00
Luke Street c214a67adf Runtime texture replacement API 2026-05-30 10:01:40 -06:00
Luke Street c50f5cda92 Fix draw call count & dirty on currentPnMtx change 2026-05-14 17:06:57 -06:00
Jasper St. Pierre 1bd972429e gx: Fix scissor width/height handling (#148)
* Not a big deal if we're using our own lib, but officially, the scissor offset is 342, not 340.
* aurora was subtracting the scissor offset for lt/tp, but not for rt/bm; fix that.
* Handle empty scissors
2026-04-30 10:40:43 -06:00
Luke Street a6a3d3a65a Add GXDestroyCopyTex function (#141) 2026-04-26 14:01:24 -06:00
Luke Street c4c5b3f4af Fix texture cache leak with immediate GXDestroyTexObj 2026-04-21 14:13:13 -06:00
Luke Street 5d420c9f73 Arbitrary mipmap detection & texture cleanup (#131) 2026-04-20 20:33:14 -06:00
Luke Street c05e7aace1 Viewport scaling rework & IR configuration (#127)
This is a breaking change: `GXSetViewport`, `GXSetScissor`, `GXSetTexCopySrc`, `GXSetTexCopyDst` now accept logical coords relative to the `VIConfigure` EFB size.

`GXSetViewportRender` and `GXSetScissorRender` are used to override the scaled viewport/scissor from the logical coords.
2026-04-18 14:10:32 -06:00
qwertyquerty 5fee2ac628 better bp caching, xf cache, optimize fifo with realloc and remove double lookups (#110)
* optimize fifo with realloc and remove double lookups

* bp cache, xf cache, and last pipeline ref cache

* remove double lookup from find/try_emplace

* change name

* Move xfRegCache

* Update gx_test_stubs.cpp

---------

Co-authored-by: Luke Street <luke@street.dev>
2026-04-12 19:40:21 -06:00
Luke Street bf46df6ba7 Simplify bind groups & improve caching 2026-04-12 18:55:35 -06:00
Luke Street ac3611e518 Improve resolve_sampled_textures performance considerably & add more traces 2026-04-12 15:35:28 -06:00
Luke Street 3a268fffa3 Fix _PC texture types 2026-04-11 13:37:32 -06:00
Luke Street b1bf531884 FIFOify texture binding (#109)
* FIFOify texture binding

* Use __cntlzw helper

* Some cleanup

* Fix texture eviction & cleanup
2026-04-09 00:14:00 -06:00
Pieter-Jan Briers 50fda393a1 GX optimizations (#107)
* handle_draw optimization

1. cache vtxSize
2. remove heap allocation from draw call merging index buffer
3. move things that aren't on the "draw call merging hot path" out to other functions, to reduce stack frame size of handle_draw (it was previously using __chkstk)

* Make ByteBuffer expand exponentially

Fix half a second of startup time being just that.

* Babysit the compiler's inlining decisions

* Merged draw call idxBuf now a global static

* GXFlush() doesn't write NOPs to FIFO

I'm sure this made sense on actual hardware

* Don't bind unused textures/samplers

* Remove C++ RAII types from build_bind_groups

Most of this function's code was fucking with WebGPU AddRef and ReleaseRef. Seriously.

* More refs in common.hpp

* Index buffer in handle_draw_unmerged now not dynamically allocated for small draws

* Fix gx_test_stubs.cpp

* Some cleanup & renaming

---------

Co-authored-by: Luke Street <luke@street.dev>
2026-04-08 19:51:06 -06:00
Pieter-Jan Briers 212d01769d Tracy integration (#106)
* Sprinkle Tracy all over the project

* Move Tracy FetchContent to extern file, disable Tracy by default

* Use older CMake syntax for setting cache variables

* Fix test compile

* Rename ALIGN macro to AURORA_ALIGN

Needed because it conflicts with a macro in Apple's SDK headers on my macbook, and Tracy is now pulling in that header.
2026-04-08 19:19:58 -06:00
Luke Street 833122b894 Fix indMtx scaleExp (5-bits instead of 6) 2026-04-07 18:08:33 -06:00
Luke Street 6b9f614d32 Texture refactor (#78)
- Removes special sampling logic from the GX shader in favor of performing conversions using separate draw calls and swizzling
- Simplifies texture bindings
- Much more accurate EFB copy handling (still incomplete but better)
  - Handle copy clears appropriately (color, alpha, depth) + GXSetDstAlpha copies
- Re-enables code for buffered texture uploads
- Adds `lastTextureUploadSize` to AuroraStats
- Use RG8 + swizzle for IA4/IA8
2026-04-01 00:49:28 -06:00
Luke Street 819c72914e Add le arg to GXSetArray 2026-03-31 01:04:04 -06:00
Luke Street 24a00238de Implement GX_POINTS 2026-03-31 00:43:08 -06:00
Luke Street 507fda8591 Implement GX_LINES and GX_LINESTRIP
Includes support for GXTexOffsets
2026-03-29 22:33:28 -06:00
Luke Street 587e2e3cb6 Full GPU vertex parsing 2026-03-29 12:58:35 -06:00
Jeffrey Crowell 818b750d71 avoid redundant storage uploads and extra alignment padding (#55)
was hitting this crash:

  (lldb) bt
  * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    * frame #0: 0x00000001927915b0 libsystem_kernel.dylib`__pthread_kill + 8
      frame #1: 0x00000001927cb888 libsystem_pthread.dylib`pthread_kill + 296
      frame #2: 0x00000001926d0850 libsystem_c.dylib`abort + 124
      frame #3: 0x00000001060400f8 libgame.dylib`aurora::ByteBuffer::resize(this=0x0000000106b97358, size=8488606, zeroed=false) at common.hpp:141:9
      frame #4: 0x0000000106047cb8 libgame.dylib`aurora::ByteBuffer::append(this=0x0000000106b97358, data=0x00000004323e0ae0, size=145566) at common.hpp:96:5
      frame #5: 0x0000000106038230 libgame.dylib`aurora::gfx::push(target=0x0000000106b97358, data="b0\xf2", length=145566, alignment=256) at common.cpp:725:12
      frame #6: 0x0000000106038340 libgame.dylib`aurora::gfx::push_storage(data="b0\xf2", length=145566) at common.cpp:750:10
      frame #7: 0x000000010606c144 libgame.dylib`aurora::gx::fifo::handle_draw(cmd=152 '\x98', data="\x98", pos=0x000000016d931eac, size=1184, bigEndian=true)
  at command_processor.cpp:1668:26
      frame #8: 0x0000000106066434 libgame.dylib`aurora::gx::fifo::process(data="\x98", size=1184, bigEndian=true) at command_processor.cpp:628:7
      frame #9: 0x00000001060a00dc libgame.dylib`GXCallDisplayList(data=0x000000043247f980, nbytes=1184) at GXDispList.cpp:67:3
      frame #10: 0x0000000105f7d440 libgame.dylib`J3DShapeDraw::draw(this=0x0000000432839a28) const at J3DShapeDraw.cpp:79:5
      frame #11: 0x0000000105f7e97c libgame.dylib`J3DShape::drawFast(this=0x0000000432839960) const at J3DShape.cpp:337:32
      frame #12: 0x0000000105f793a0 libgame.dylib`J3DShapePacket::drawFast(this=0x00000004329be9e8) at J3DPacket.cpp:401:18
      frame #13: 0x0000000105f79280 libgame.dylib`J3DMatPacket::draw(this=0x00000004329bf448) at J3DPacket.cpp:236:17
      frame #14: 0x0000000105f98b3c libgame.dylib`J3DDrawBuffer::drawHead(this=0x000000042f513808) const at J3DDrawBuffer.cpp:232:21
      frame #15: 0x0000000105f98ce8 libgame.dylib`J3DDrawBuffer::draw(this=0x000000042f513808) const at J3DDrawBuffer.cpp:223:5
      frame #16: 0x000000010530cd50 libgame.dylib`dDlst_list_c::drawXluDrawList(this=0x0000000106bb99d0, pDrawBuf=0x000000042f513808) at d_drawlist.cpp:1835:15
      frame #17: 0x000000010528bc10 libgame.dylib`dDlst_list_c::drawXluListDarkBG(this=0x0000000106bb99d0) at d_drawlist.h:479:32
      frame #18: 0x0000000105289150 libgame.dylib`dComIfGd_drawXluListDarkBG() at d_com_inf_game.h:4729:33
      frame #19: 0x0000000105287dc0 libgame.dylib`mDoGph_Painter() at m_Do_graphic.cpp:1783:13
      frame #20: 0x00000001056325f0 libgame.dylib`cAPIGph_Painter() at c_API_graphic.cpp:10:5
      frame #21: 0x00000001052b6560 libgame.dylib`fpcM_Management(i_preExecuteFn=0x0000000000000000, i_postExecuteFn=(libgame.dylib`fapGm_After() at
  f_ap_game.cpp:718)) at f_pc_manager.cpp:64:13
      frame #22: 0x00000001052a5fa8 libgame.dylib`fapGm_Execute() at f_ap_game.cpp:735:5
      frame #23: 0x0000000105236db0 libgame.dylib`main01() at m_Do_main.cpp:177:9
      frame #24: 0x0000000105237e2c libgame.dylib`game_main(argc=1, argv=0x000000016d9335a0) at m_Do_main.cpp:298:5
      frame #25: 0x00000001024cd518 dusk`main(argc=1, argv=0x000000016d9335a0) at main.cpp:12:12
      frame #26: 0x0000000192401d54 dyld`start + 7184

  (lldb) f 4
  frame #4: 0x0000000106047cb8 libgame.dylib`aurora::ByteBuffer::append(this=0x0000000106b97358, data=0x00000004323e0ae0, size=145566) at common.hpp:96:5
     93  	  [[nodiscard]] bool empty() const noexcept { return m_length == 0; }
     94
     95  	  void append(const void* data, size_t size) {
  -> 96  	    resize(m_length + size, false);
      	    ^
     97  	    memcpy(m_data + m_length, data, size);
     98  	    m_length += size;
     99  	  }

› (lldb) p/x m_capacity
  (size_t) 0x0000000000800000
  (lldb) p m_capacity
  (size_t) 8388608
  (lldb) p/x size
  (size_t) 0x000000000081869e these were the size/capacity

essentially alignment padding was making the capacity overwhelmed.
2026-03-13 19:46:11 -07:00
Luke Street 42f46ae99f Implement indirect texturing (kinda works) 2026-03-12 00:05:19 -06:00
Pieter-Jan Briers eb960f8148 Add debug group/marker GX/GD API (#48)
* Add debug group/marker GX/GD API

* This keeps happening

* Don't crash if debug group stack underflows

* Missed a debug check

* Stubs

* Last stub?

* We hate C++

* Oh right release exists
2026-03-10 18:38:35 -06:00