Commit graph

945 commits

Author SHA1 Message Date
Isaac Marovitz
b44167d12a Shader cache support 2024-09-28 19:03:01 -04:00
Isaac Marovitz
eb2dae561f Make dotnet format happy 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1287098b8b GAL ResourceUsage Changes
TODO: Guest Barrier Defer
2024-09-28 19:03:01 -04:00
Isaac Marovitz
9f2c99fcfa Better vertex buffer management 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a6f5f2f82b Fix LOD 2024-09-28 19:03:01 -04:00
Isaac Marovitz
655823ecc7 Better index buffer management 2024-09-28 19:03:01 -04:00
Isaac Marovitz
18a1741348 Formatting cleanup 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b734c81683 Formatting 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6e80cc6caa Update binding model description comment 2024-09-28 19:03:01 -04:00
riperiperi
ea30e543e6 Fix preload cbs optimization (for real) (#34)
* Mostly fix preload cbs. There seems to be some random flickering...

* fix index buffer usage range

* fix missing preflush submit before present
2024-09-28 19:03:01 -04:00
Isaac Marovitz
e3468d35b6 Fix invariant position not doing its job 2024-09-28 19:03:01 -04:00
riperiperi
d22feff1d2 implement compressed/uncompressed copy, fix other copies, fix int/uint output shaders (#33) 2024-09-28 19:03:01 -04:00
Isaac Marovitz
9d866ff282 Fix blend state optimisation breaking attachments
Fixes SM3DW
2024-09-28 19:03:01 -04:00
riperiperi
fd0329f2eb Fix warnings 2024-09-28 19:03:01 -04:00
riperiperi
468ab8242f Maintain identity swizzle view of textures for rendering 2024-09-28 19:03:01 -04:00
riperiperi
7b9b23e500 Fix a bunch of issues with texture copy and flush (#32)
* Fix a bunch of issues with texture copy and flush

* TextureCopy helper class, fix clear bug
2024-09-28 19:03:01 -04:00
Isaac Marovitz
0c1acb5107 Cleanup + Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8e8dcf0d7f Fix trying to reserve size 0 in staging buffer 2024-09-28 19:03:01 -04:00
Isaac Marovitz
9f0a468f55 Fix zero buff not being reset 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ab79959975 Dirty Arg Buffers on Program Change 2024-09-28 19:03:01 -04:00
Isaac Marovitz
de5bf3a141 Least allocations in the west 2024-09-28 19:03:01 -04:00
Isaac Marovitz
5e8606c89a Don’t use Enum.HasFlag 2024-09-28 19:03:01 -04:00
Isaac Marovitz
daee63c451 Metal: Better Bindings (#29)
* Tell GAL to use Vk model (and break everything)

* ResourceBindingSegments

* Set information on backend caps

* Get ready to break everything

* Refactor EncoderStateManager

* Remove padding from helper shaders

* Fix ref array sizes

* Seperate vert & frag buffers

* Shader-side changes

* Fixes

* Fix some helper shader resource layouts

* Sort by binding id

* Fix helper shader layouts

* Don’t do inline vertex buffer updates

* Check for null storage
2024-09-28 19:03:01 -04:00
Isaac Marovitz
971c270bcf Update comment for Metal 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6aff6401fb Don’t do inline vertex buffer updates
Somehow broke zero buff MTLVertexDescriptor, but fixes broken geoemtry so I’m pushing anyway
2024-09-28 19:03:01 -04:00
riperiperi
6f6ccb7898 Create command buffers when rented rather than in advance (#31)
* Make it less likely to freeze, but the creation of the command buffer should probably be moved

* Create command buffers as they're rented rather than in advance
2024-09-28 19:03:01 -04:00
riperiperi
2511bf1e4c Preload command speedup, Texture/buffer data flush, blit shader fix (#30)
* Move encoder state to be tied to command buffer, so preload and background cbs have their own encoder state

* Texture buffer/data flush, blit shader fix
2024-09-28 19:03:01 -04:00
Isaac Marovitz
80f9a5d0da Dont bind images in texture slots 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ed4f7a5602 Stop depth/stencil blits from crashing everything 2024-09-28 19:03:01 -04:00
riperiperi
edceb1607f Fix Geometry/TFB on compute, Buffer Textures, add Window Resizing (#28) 2024-09-28 19:03:01 -04:00
riperiperi
e02df72323 State and cache optimization (#27)
* WIP pipeline/depth state cache rework

* Fix some issues

* Fix some more default values

* Reduce allocations for state changes

* fix helpershader stuff

* explanation comment

* fix depth bias
2024-09-28 19:03:01 -04:00
Isaac Marovitz
9d26aa8d06 Fragment input interpolation qualifiers
Fixes Mario’s shadow in SMO
2024-09-28 19:03:01 -04:00
Isaac Marovitz
c8c4fd730d CommandBufferBarrier 2024-09-28 19:03:01 -04:00
riperiperi
e27ade5aee Add constrained border colours to samplers (#26) 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b33c1ae22f Don’t bind byte format converted index buffers at requested index 2024-09-28 19:03:01 -04:00
Isaac Marovitz
242fcc2481 Render target deduplication
not sure if this is working
2024-09-28 19:03:01 -04:00
Isaac Marovitz
ef4a2fb3b5 Fix CBP not doing its job
Thanks peri (again)
2024-09-28 19:03:01 -04:00
Isaac Marovitz
c4731c0555 Fix blend descriptors not dirting render pipeline
Thanks peri
2024-09-28 19:03:01 -04:00
Isaac Marovitz
0c562a2c50 Support non-index quad draws
Fixes Deltarune
2024-09-28 19:03:01 -04:00
Isaac Marovitz
ab1e02c56a Be better about memory 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a264d9273d Fix stencil clears 2024-09-28 19:03:01 -04:00
Isaac Marovitz
05189c7749 Enable Alpha Test workaround on Metal 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b7ddb693bc Fix Cull FrontAndBack 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a60643620d Warning about host map buffer creation 2024-09-28 19:03:01 -04:00
Isaac Marovitz
113e721cce Fix fragment point_coord in 2024-09-28 19:03:01 -04:00
Isaac Marovitz
c8308d27f1 Argument Buffers (#24)
* Stuff

* More arg buffer stuff

* Fixes

* Rebase

* Pass storage buffers to inline functions

* Fix binding

* Fix typo + Fix a couple shaders

* Enforce ids

* Dispose

* Mark used buffers as resident

* Update depth clear shader

* Fix non-contiguous struct defs

* Update ChangeBufferStride

* Fix StorageBuffer assignments

* Fix odyssey crash

* Retain buffer bindings

* Pad Std140

* Set texture data with safe buffers

* Clone buffers

* Always declare vert in

* Stop clears from breaking OpenGL games

* Fix depth clear

* Use invariant position

* Horribly inefficient texture & sampler arg buffers

* Fix missing struct access

* Minimise rebinds as much as possible

* Build arg buffers on staging buffer
2024-09-28 19:03:01 -04:00
Isaac Marovitz
a71b5f1a3a VoteAllEqual, FindLSB/MSB 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b094d34575 Fix vertex “built-ins”
Only declare main func out in main

Fix simd_ballot

Fix thread_index_in_simdgroup outside of compute

Fix atomic operations

instance_index
2024-09-28 19:03:01 -04:00
Isaac Marovitz
4578ee53d3 Actually clear the right render target 2024-09-28 19:03:01 -04:00
Isaac Marovitz
72cbb41609 Big GetData()
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2024-09-28 19:03:01 -04:00
Isaac Marovitz
e7fab91c69 Fix Animal Crossing Crash 2024-09-28 19:03:01 -04:00
Isaac Marovitz
97a36298fa Instruction.Barrier
Whoops

Fix inline functions in compute stage

Fix regression

Declare SharedMemories + Only Declare Memories on Main Func

Lowecase struct

Avoid magic strings

Make function signatures readable

Change how unsized arrays are indexed

Use string builder

Fix shuffle instructions

Cleanup NumberFormater

Bunch of Subgroup I/O Vars

Will probably need further refinement

Fix point_coord type

Fix support buffer declaration

Fix point_coord
2024-09-28 19:03:01 -04:00
Isaac Marovitz
03161d8048 PreloadCbs + FlushCommandsIfWeightExceeding 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b1928461bb Cleanup Pipeline
Housekeeping

More housekeeping
2024-09-28 19:03:01 -04:00
Isaac Marovitz
30b50a99e4 PersistentFlushBuffer + BackgroundResources 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a638060dee Match S8UintD24Unorm to Depth24UnormStencil8
Kind of works for es2gears
2024-09-28 19:03:01 -04:00
Isaac Marovitz
49781fde65 Fix FEZ not showing anything
Does not fix the underlying shortcomings of the cache system
2024-09-28 19:03:01 -04:00
Isaac Marovitz
84f3b4a3e1 Clear cached converted buffers on signaled write 2024-09-28 19:03:01 -04:00
Isaac Marovitz
2c511cdf4f FIx regression 2024-09-28 19:03:01 -04:00
Isaac Marovitz
17cfcf07d2 Helper shader cleanup 2024-09-28 19:03:01 -04:00
Isaac Marovitz
410287aba2 Use buffer manager for color blit 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6ebe5bb406 Buffer Conversions (#23)
* Why is this not working

* Revert helper shader changes for now

* Byte Index Buffer Restride
2024-09-28 19:03:01 -04:00
riperiperi
02de48a6f2 don't recreate render pipeline unless we're about to draw, pass view depth properly (#22) 2024-09-28 19:03:01 -04:00
Isaac Marovitz
58b3e2e82b Metal: Buffers Take 2 (#21)
* Basic BufferManager

* Start Scoped Command Buffers

* Fences stuff

* Remember to cleanup sync manager

* Auto, Command Buffer Dependants

* Cleanup

* Cleanup + Fix Texture->Buffer Copies

* Slow buffer upload

* Cleanup + Rework TextureBuffer

* Don’t get unsafe

* Cleanup

* Goddamn it

* Staging Buffer + Interrupt Action + Flush
2024-09-28 19:03:01 -04:00
Isaac Marovitz
d0946213fa Log failed format conversions 2024-09-28 19:03:01 -04:00
Isaac Marovitz
66e2533c90 Print shader code involved in failed linking 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b821cb1739 Don’t use DidModifyRange 2024-09-28 19:03:01 -04:00
Isaac Marovitz
122f0f45c8 Fix sample compare 2024-09-28 19:03:01 -04:00
Isaac Marovitz
9a6759d1e5 Depth Bias 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e97c9bc959 Map R5G5B5A1Unorm 2024-09-28 19:03:01 -04:00
Samuliak
bc5df02d7d override Equals for render pipeline hash 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1c5937c40b Disable scaled vertex formats 2024-09-28 19:03:01 -04:00
Isaac Marovitz
4bb736d70a Disable Vector Indexing Bug Workaround 2024-09-28 19:03:01 -04:00
Isaac Marovitz
efb7baf15c Fix modulo operator
Support sample offsets

Include FragmentIn as additional arg

Always declare frag output struct

SubgroupLaneId
2024-09-28 19:03:01 -04:00
Isaac Marovitz
fad653c12e Workaround for Wonder 2024-09-28 19:03:01 -04:00
Isaac Marovitz
bb4cb531f2 Fix 3D -> 3D Texture Copies 2024-09-28 19:03:01 -04:00
Isaac Marovitz
3c188718c4 Fix Clear Viewport 2024-09-28 19:03:01 -04:00
Isaac Marovitz
362672ae12 Fix sample-less reads with lod 2024-09-28 19:03:01 -04:00
Isaac Marovitz
970914e2b4 Fix Pack and UnpackHalf2x16 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f7e97a30af Handle Array Format SetData 2024-09-28 19:03:01 -04:00
Isaac Marovitz
aae9dc0c2e Cleanup 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b0ba5d5da1 Implement IoVariable.FrontFacing 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a6de2c9274 Fix LOD sample typo 2024-09-28 19:03:01 -04:00
Isaac Marovitz
d323a8d44a Rebase Changes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ba07a8c603 More cleanup 2024-09-28 19:03:01 -04:00
Isaac Marovitz
362746887e Cleanup + Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b064d76a4f Metal: Compute Shaders (#19)
* check for too bix texture bindings

* implement lod query

* print shader stage name

* always have fragment input

* resolve merge conflicts

* fix: lod query

* fix: casting texture coords

* support non-array memories

* use structure types for buffers

* implement compute pipeline cache

* compute dispatch

* improve error message

* rebind compute state

* bind compute textures

* pass local size as an argument to dispatch

* implement texture buffers

* hack: change vertex index to vertex id

* pass support buffer as an argument to every function

* return at the end of function

* fix: certain missing compute bindings

* implement texture base

* improve texture binding system

* remove useless exception

* move texture handle to texture base

* fix: segfault when using disposed textures

---------

Co-authored-by: Samuliak <samuliak77@gmail.com>
Co-authored-by: SamoZ256 <96914946+SamoZ256@users.noreply.github.com>
2024-09-28 19:03:01 -04:00
Isaac Marovitz
131ab75d55 Handle stride 0 on regular buffers 2024-09-28 19:03:01 -04:00
Isaac Marovitz
65149cfe9f Buffer Descriptor Step Functions 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a435d94fae Sample LOD Level 2024-09-28 19:03:01 -04:00
Isaac Marovitz
88dd2984be Fix FragmentOutputColor Type 2024-09-28 19:03:01 -04:00
Isaac Marovitz
43460186a8 Stencil Ref Value 2024-09-28 19:03:01 -04:00
Isaac Marovitz
0a6f11d247 Stencil Fixes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1b86360a61 RenderTargetColorMasks 2024-09-28 19:03:01 -04:00
Isaac Marovitz
dc01de61cd Make dotnet format happy 2024-09-28 19:03:01 -04:00
SamoZ256
e423f81155 Zero vertex buffer (#17)
* cast src size to float

* implement zero buffers
2024-09-28 19:03:01 -04:00
Isaac Marovitz
35f68c1b31 Implement Texture CopyTo 2024-09-28 19:03:01 -04:00
Isaac Marovitz
cb8fdeafbc Cleanup present 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1f29a76ea3 Metal: Advanced Present (#6)
* Initial DrawTexture support & Advanced Present

* TODO: Get Scissors Working

* Chnage scissor state management

* Rebase problems…

* Rebase fixes again

* Update DrawTexture + Fix Topology

* Fix flipping

* Add clear action support

* Cleanup
2024-09-28 19:03:01 -04:00
SamoZ256
1f91c74a95 Clone the state & flip viewport vertically (#16)
* implement texture get data

* reset all state before blit & clone state

* format

* support blit regions

* implement source region for blit

* replace bottom with top

* account for 0 size

* support image flipping

* revert presentation fixes & y flip

* revert

* flip viewport vertically

* switch face winding

* comment

* use SetBytes for texture clear

* implement missing compute builtins

* change storage and texture buffer alignment

* correct compute builtins

* don't use nullable for textures and samplers

* remove incorrect texture get data implementation

* Cleanup IntPtrs

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-09-28 19:03:01 -04:00