WIP V2: Experimental: Metal backend #441

Merged
GreemDev merged 369 commits from new-metal into master 2024-12-24 06:55:16 +00:00

369 Commits

Author SHA1 Message Date
Evan Husted
61303032f1 Silence compile warnings 2024-12-24 00:31:49 -06:00
Evan Husted
bff884a89c UI: Change backend text based on used Window type rather than configured value 2024-12-24 00:18:47 -06:00
Evan Husted
89f3c8235c misc: More places need to factor in Auto, oops 2024-12-23 23:53:58 -06:00
Evan Husted
f3545f5eae UI: Auto graphics backend 2024-12-23 23:26:47 -06:00
Evan Husted
a335c8ff2b UI: Collapse IsHypervisorAvailable and IsMetalAvailable into IsAppleSiliconMac 2024-12-23 22:37:15 -06:00
Evan Husted
3aaeaf3540 UI: Only allow ARM macs to select Metal backend 2024-12-23 22:35:28 -06:00
Evan Husted
e82a90993c UI: Properly disable selecting Metal on non-Mac platforms 2024-12-23 22:32:37 -06:00
Evan Husted
f3dcb80a60 GAL changes 2024-12-23 21:52:39 -06:00
Evan Husted
d4b9e06522 .NET 9 2024-12-23 21:44:45 -06:00
Isaac Marovitz
0945ea68fe Make resource encoding less stupid 2024-12-23 21:44:34 -06:00
Isaac Marovitz
d3c0971acf Set correct maximum supported anisotropy 2024-12-23 21:44:31 -06:00
Isaac Marovitz
7bdae9e552 GAL Changes 2024-12-23 21:44:29 -06:00
Isaac Marovitz
567b0a5027 Updates 2024-12-23 21:44:26 -06:00
Isaac Marovitz
a5f82a99a3 GAL Changes 2024-12-23 21:44:23 -06:00
Isaac Marovitz
89c05ac239 Check for null resources before declaring them resident 2024-12-23 21:44:17 -06:00
Isaac Marovitz
fe4c77788f Fix null sampler crash 2024-12-23 21:44:11 -06:00
Isaac Marovitz
d23de14812 Fix counted indirect draws
Fixes Monster Hunter Rise and Apollo Justice
2024-12-23 21:44:07 -06:00
Isaac Marovitz
216261931e Program hash set 2024-12-23 21:44:04 -06:00
Isaac Marovitz
8c2f3ae8d2 Auto-backed samplers 2024-12-23 21:44:02 -06:00
Isaac Marovitz
a710bcd874 Refactor binding logic + Bind image arrays 2024-12-23 21:43:49 -06:00
Isaac Marovitz
b941ef6bde Fix primitive id in shader gen
Fixes Dark Souls
2024-12-23 21:43:47 -06:00
Isaac Marovitz
b5e6f26296 Fix cubemap array length
Fixes crash in Sonic Frontiers
2024-12-23 21:43:45 -06:00
Isaac Marovitz
c0d20f8689 Properly create stencil views of combined formats
Fixes Link’s Awakening
2024-12-23 21:43:42 -06:00
Isaac Marovitz
4a81d9edc4 Add missing set texture for depth stencil blit
Mostly fixes Sonic Frontiers & Link’s Awakening
2024-12-23 21:43:38 -06:00
Isaac Marovitz
a05a9a33f1 Fix typo in stride change shader
Fixes Castlevania Dominus Collection
2024-12-23 21:43:35 -06:00
Isaac Marovitz
b1e5262893 Fix invalid depth stencil state when no depth stencil is present
Partially fixes Sonic Frontiers and Castlevania Dominus Collection
2024-12-23 21:43:32 -06:00
Isaac Marovitz
dce6b94841 Style 2024-12-23 21:43:30 -06:00
Isaac Marovitz
51e85ed38b Metal: Unsupported topology indexed draw conversion (#40)
* Convert unsupported indexed buffer topologies

* Fix index count and dispatch size

* Cleanup

* Fix typos
2024-12-23 21:43:23 -06:00
Isaac Marovitz
38b2cf9b83 Fix null resources breaking arg buffer alignment 2024-12-23 21:43:16 -06:00
Isaac Marovitz
e406b67690 Remove RenderPipelineDescriptorResult 2024-12-23 21:43:13 -06:00
Isaac Marovitz
2d522b1675 D32FS8 to D24S8 Conversion 2024-12-23 21:43:10 -06:00
Isaac Marovitz
967887d050 Upstream changes 2024-12-23 21:43:04 -06:00
Isaac Marovitz
3258a4bad1 Logic Operations 2024-12-23 21:43:00 -06:00
Isaac Marovitz
058ce78d31 Fix array size query 2024-12-23 21:42:56 -06:00
Isaac Marovitz
b988c0bc3d Debug Groups 2024-12-23 21:42:51 -06:00
Isaac Marovitz
1fc96128fa IaIndexing
Fixes shader problems in Donkey Kong Country Tropical Freeze, and Fire Emblem: Three Houses
2024-12-23 21:42:49 -06:00
Isaac Marovitz
4a11cc9c7a Rasterizer Discard + Multisample State 2024-12-23 21:42:47 -06:00
Isaac Marovitz
782299c123 Metal: Argument Buffer Pre-Pass (#38)
* Init

* Fix missing flags

* Cleanup
2024-12-23 21:42:44 -06:00
riperiperi
e8de1156eb Patch some leaks and only perform copies on valid textures (#37) 2024-12-23 21:42:42 -06:00
Isaac Marovitz
ceaa174859 Get render command encoder after finalising buffers
Fixes crash in Fire Emblem: Houses
2024-12-23 21:42:40 -06:00
Isaac Marovitz
7eaaeea999 Format 2024-12-23 21:42:38 -06:00
Isaac Marovitz
d707273671 Fix non atomic image loads again 2024-12-23 21:42:23 -06:00
Isaac Marovitz
2a7375209e Finally fix (most) image atomics 2024-12-23 21:42:22 -06:00
Isaac Marovitz
2e5ae70b91 Precise Float Fixes
Fixes artifacts in TOTK
2024-12-23 21:42:19 -06:00
Isaac Marovitz
6f24b88e88 Fix image atomics 2024-12-23 21:42:17 -06:00
Isaac Marovitz
5d59c552e7 Fix Non-Float Textures + Image Read + FSI Buffers
Fixes Mario Party Superstars
2024-12-23 21:42:15 -06:00
Isaac Marovitz
341e4e5fb1 Image Constant Fixes
Allows Mario Party Superstars to boot
2024-12-23 21:42:10 -06:00
Isaac Marovitz
68146fa285 Helper Shader fixes for non float formats 2024-12-23 21:41:44 -06:00
Isaac Marovitz
80bb95dfb9 Shader Extra Set Support + Cleanup (#36)
Separate samplers are now supported and arrays in constant sets are bound
2024-12-23 21:41:39 -06:00
Isaac Marovitz
5b88ea66ba InstGenMemory Refactor + Bindless Support 2024-12-23 21:41:35 -06:00
Isaac Marovitz
9d3fc82484 TextureArray & ImageArray Creation + State 2024-12-23 21:41:33 -06:00
Isaac Marovitz
8f6eceaa1f Fix hex number type ambiguity
Fixes cutscenes in Super Mario Sunshine
2024-12-23 21:41:30 -06:00
Isaac Marovitz
04bd1fa1ca Use RGBA8Unorm for R4G4B4A4Unorm
Gets SM64 to boot
2024-12-23 21:41:28 -06:00
Isaac Marovitz
c0dcb6c4f2 Dual Source Blend Support in Shader
Fixes Super Mario Galaxy and The Legend of Zelda: Skyward Sword HD
2024-12-23 21:41:26 -06:00
Isaac Marovitz
8bbfa86538 Get Tomb Raider working 2024-12-23 21:41:23 -06:00
Isaac Marovitz
a0c67cab44 Remove DummyBufferTextures
Mostly gets VTG on Compute working again
2024-12-23 21:41:19 -06:00
Isaac Marovitz
421ba5448a Properly register TextureBuffer usage + Store Auto ref 2024-12-23 21:41:12 -06:00
Isaac Marovitz
45c99dbfa8 Partial indirect draw support 2024-12-23 21:41:05 -06:00
Gabriel A
a84ed6af0d Fixes 2024-12-23 21:40:57 -06:00
Gabriel A
0642df4909 Start building more accurate vertex as compute usage info 2024-12-23 21:40:55 -06:00
Isaac Marovitz
d650538138 Bind TextureBuffers 2024-12-23 21:40:53 -06:00
Isaac Marovitz
eeadf17f5c Remove ClearSegments for now
Currently unimplemented and issues are arising with building BindingSegments in general.
2024-12-23 21:40:51 -06:00
Isaac Marovitz
7bf0625075 Fix compute generation failure in NieR 2024-12-23 21:40:49 -06:00
Isaac Marovitz
5220ee1dc8 Some debug improvements 2024-12-23 21:40:46 -06:00
Isaac Marovitz
cb0a1ce48a Stop complaining about clip distance 2024-12-23 21:40:44 -06:00
Isaac Marovitz
ffb9040b3b Shader Gen Fixes
Fixes Luigi’s Mansion 2 HD
2024-12-23 21:40:42 -06:00
Isaac Marovitz
40ea153616 DepthStencil Blits 2024-12-23 21:40:40 -06:00
Isaac Marovitz
4373610790 Multisample Blits
Partially fixes Sonic Colors Ultimate
2024-12-23 21:40:38 -06:00
Isaac Marovitz
f5b82cd6dc Fix image bindings 2024-12-23 21:40:36 -06:00
Isaac Marovitz
0064afeb6a FSI (with raster order groups) 2024-12-23 21:40:34 -06:00
Isaac Marovitz
69bee52a89 SwizzleAdd (NOT TESTED) 2024-12-23 21:40:32 -06:00
Isaac Marovitz
159afd5d03 Consolodate barriers 2024-12-23 21:40:30 -06:00
Isaac Marovitz
6229f3bb4c Shader Memory Barriers
Fixes some of the shader generation failures in Sonic Frontiers
2024-12-23 21:40:26 -06:00
Isaac Marovitz
d42f0e5945 Image binding support
Kirby still has a problem with NaN 3D Texture
2024-12-23 21:40:22 -06:00
Isaac Marovitz
015f5d00b4 Image shader gen support 2024-12-23 21:39:56 -06:00
Isaac Marovitz
d9b322688c Shader cache support 2024-12-23 21:39:54 -06:00
Isaac Marovitz
5e72eb8362 Make dotnet format happy 2024-12-23 21:39:51 -06:00
Isaac Marovitz
e0cd935c28 GAL ResourceUsage Changes
TODO: Guest Barrier Defer
2024-12-23 21:39:49 -06:00
Isaac Marovitz
1f133040bd Better vertex buffer management 2024-12-23 21:39:47 -06:00
Isaac Marovitz
c399868ddf Fix LOD 2024-12-23 21:39:45 -06:00
Isaac Marovitz
fcd2adecc5 Better index buffer management 2024-12-23 21:39:43 -06:00
Isaac Marovitz
b468569665 Formatting cleanup 2024-12-23 21:39:36 -06:00
Isaac Marovitz
353a6ca4bb Formatting 2024-12-23 21:39:31 -06:00
Isaac Marovitz
6188872a7c Update binding model description comment 2024-12-23 21:39:16 -06:00
riperiperi
8411f69899 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-12-23 21:39:13 -06:00
Isaac Marovitz
0bb0ecb599 Fix invariant position not doing its job 2024-12-23 21:39:11 -06:00
riperiperi
8cbd44aecb implement compressed/uncompressed copy, fix other copies, fix int/uint output shaders (#33) 2024-12-23 21:39:09 -06:00
Isaac Marovitz
d2f965885a Fix blend state optimisation breaking attachments
Fixes SM3DW
2024-12-23 21:39:07 -06:00
riperiperi
29b6e8ac53 Fix warnings 2024-12-23 21:39:05 -06:00
riperiperi
26da57cccd Maintain identity swizzle view of textures for rendering 2024-12-23 21:39:03 -06:00
riperiperi
82b5f8e681 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-12-23 21:38:59 -06:00
Isaac Marovitz
58527e02ee Cleanup + Format 2024-12-23 21:38:54 -06:00
Isaac Marovitz
4d5b128a81 Fix trying to reserve size 0 in staging buffer 2024-12-23 21:38:46 -06:00
Isaac Marovitz
49a814a400 Fix zero buff not being reset 2024-12-23 21:38:42 -06:00
Isaac Marovitz
09546205b5 Dirty Arg Buffers on Program Change 2024-12-23 21:38:39 -06:00
Isaac Marovitz
d2a4a9e9a7 Least allocations in the west 2024-12-23 21:38:37 -06:00
Isaac Marovitz
d3f273cad1 Don’t use Enum.HasFlag 2024-12-23 21:38:35 -06:00
Isaac Marovitz
60722a1837 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-12-23 21:38:32 -06:00
Isaac Marovitz
549938e2b1 Update comment for Metal 2024-12-23 21:38:20 -06:00
Isaac Marovitz
144397c3da Don’t do inline vertex buffer updates
Somehow broke zero buff MTLVertexDescriptor, but fixes broken geoemtry so I’m pushing anyway
2024-12-23 21:38:17 -06:00
riperiperi
2fb3c6975e 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-12-23 21:38:15 -06:00
riperiperi
879c93cf73 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-12-23 21:38:13 -06:00
Isaac Marovitz
7d5b4c5d1d Dont bind images in texture slots 2024-12-23 21:38:11 -06:00
Isaac Marovitz
2860db198c Stop depth/stencil blits from crashing everything 2024-12-23 21:38:04 -06:00
riperiperi
4b53d18bef Fix Geometry/TFB on compute, Buffer Textures, add Window Resizing (#28) 2024-12-23 21:38:00 -06:00
riperiperi
bbbc9e529d 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-12-23 21:37:58 -06:00
Isaac Marovitz
c160810bfc Fragment input interpolation qualifiers
Fixes Mario’s shadow in SMO
2024-12-23 21:37:55 -06:00
Isaac Marovitz
4f7b3fa058 CommandBufferBarrier 2024-12-23 21:37:52 -06:00
riperiperi
36de337ac2 Add constrained border colours to samplers (#26) 2024-12-23 21:37:50 -06:00
Isaac Marovitz
3b2beda27f Don’t bind byte format converted index buffers at requested index 2024-12-23 21:37:48 -06:00
Isaac Marovitz
de8e03c350 Render target deduplication
not sure if this is working
2024-12-23 21:37:45 -06:00
Isaac Marovitz
0b6bc12a65 Fix CBP not doing its job
Thanks peri (again)
2024-12-23 21:37:43 -06:00
Isaac Marovitz
16bc02ea2a Fix blend descriptors not dirting render pipeline
Thanks peri
2024-12-23 21:37:41 -06:00
Isaac Marovitz
97814b2852 Support non-index quad draws
Fixes Deltarune
2024-12-23 21:37:38 -06:00
Isaac Marovitz
a9633981a8 Be better about memory 2024-12-23 21:37:36 -06:00
Isaac Marovitz
1af7dc4b68 Fix stencil clears 2024-12-23 21:37:14 -06:00
Isaac Marovitz
d6dcc39131 Enable Alpha Test workaround on Metal 2024-12-23 21:37:10 -06:00
Isaac Marovitz
4f699ef96a Fix Cull FrontAndBack 2024-12-23 21:37:07 -06:00
Isaac Marovitz
30f194e5c0 Warning about host map buffer creation 2024-12-23 21:37:05 -06:00
Isaac Marovitz
f1086afcdf Fix fragment point_coord in 2024-12-23 21:37:03 -06:00
Isaac Marovitz
dae0f3cded 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-12-23 21:37:01 -06:00
Isaac Marovitz
a1ab7fe6a2 VoteAllEqual, FindLSB/MSB 2024-12-23 21:36:58 -06:00
Isaac Marovitz
fac2cbbbbf 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-12-23 21:36:56 -06:00
Isaac Marovitz
9b138a413c Actually clear the right render target 2024-12-23 21:36:54 -06:00
Isaac Marovitz
58eefa8bdf Big GetData()
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2024-12-23 21:36:52 -06:00
Isaac Marovitz
0ebc8bd1b8 Fix Animal Crossing Crash 2024-12-23 21:36:50 -06:00
Isaac Marovitz
becf828d0a 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-12-23 21:36:48 -06:00
Isaac Marovitz
d0e4adac36 PreloadCbs + FlushCommandsIfWeightExceeding 2024-12-23 21:36:46 -06:00
Isaac Marovitz
197184657f Cleanup Pipeline
Housekeeping

More housekeeping
2024-12-23 21:36:44 -06:00
Isaac Marovitz
74083083cd PersistentFlushBuffer + BackgroundResources 2024-12-23 21:36:42 -06:00
Isaac Marovitz
175cded85d Match S8UintD24Unorm to Depth24UnormStencil8
Kind of works for es2gears
2024-12-23 21:36:40 -06:00
Isaac Marovitz
c911db8309 Fix FEZ not showing anything
Does not fix the underlying shortcomings of the cache system
2024-12-23 21:35:50 -06:00
Isaac Marovitz
3451fbbbad Clear cached converted buffers on signaled write 2024-12-23 21:35:47 -06:00
Isaac Marovitz
98ae46ba70 FIx regression 2024-12-23 21:35:45 -06:00
Isaac Marovitz
bf4232a35b Helper shader cleanup 2024-12-23 21:35:43 -06:00
Isaac Marovitz
c3e39a9c91 Use buffer manager for color blit 2024-12-23 21:35:41 -06:00
Isaac Marovitz
b8779c6e09 Buffer Conversions (#23)
* Why is this not working

* Revert helper shader changes for now

* Byte Index Buffer Restride
2024-12-23 21:35:38 -06:00
riperiperi
20cf1a08c1 don't recreate render pipeline unless we're about to draw, pass view depth properly (#22) 2024-12-23 21:35:36 -06:00
Isaac Marovitz
dda746c0fb 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-12-23 21:35:33 -06:00
Isaac Marovitz
585bdc2b54 Log failed format conversions 2024-12-23 21:35:31 -06:00
Isaac Marovitz
e49702965f Print shader code involved in failed linking 2024-12-23 21:35:21 -06:00
Isaac Marovitz
8b5392ce9b Don’t use DidModifyRange 2024-12-23 21:35:17 -06:00
Isaac Marovitz
9e61294671 Fix sample compare 2024-12-23 21:35:15 -06:00
Isaac Marovitz
5423ad9ae1 Depth Bias 2024-12-23 21:35:13 -06:00
Isaac Marovitz
65bddcd475 Map R5G5B5A1Unorm 2024-12-23 21:35:11 -06:00
Samuliak
36ac0414e2 override Equals for render pipeline hash 2024-12-23 21:35:09 -06:00
Isaac Marovitz
51b4ffeb6c Disable scaled vertex formats 2024-12-23 21:35:07 -06:00
Isaac Marovitz
39bfd55958 Disable Vector Indexing Bug Workaround 2024-12-23 21:35:04 -06:00
Isaac Marovitz
e615d7d849 Fix modulo operator
Support sample offsets

Include FragmentIn as additional arg

Always declare frag output struct

SubgroupLaneId
2024-12-23 21:35:02 -06:00
Isaac Marovitz
c883ebb645 Workaround for Wonder 2024-12-23 21:35:00 -06:00
Isaac Marovitz
24ab7788d8 Fix 3D -> 3D Texture Copies 2024-12-23 21:34:57 -06:00
Isaac Marovitz
9ab2cd94c1 Fix Clear Viewport 2024-12-23 21:34:55 -06:00
Isaac Marovitz
4ee4e09358 Fix sample-less reads with lod 2024-12-23 21:34:52 -06:00
Isaac Marovitz
a07975afec Fix Pack and UnpackHalf2x16 2024-12-23 21:34:50 -06:00
Isaac Marovitz
746c897206 Handle Array Format SetData 2024-12-23 21:34:48 -06:00
Isaac Marovitz
fe4fa6f4db Cleanup 2024-12-23 21:33:31 -06:00
Isaac Marovitz
db24e0f6fe Implement IoVariable.FrontFacing 2024-12-23 21:33:24 -06:00
Isaac Marovitz
e9aee16a27 Fix LOD sample typo 2024-12-23 21:33:21 -06:00
Isaac Marovitz
02f1e289e2 Rebase Changes 2024-12-23 21:33:19 -06:00
Isaac Marovitz
9ebf82f184 More cleanup 2024-12-23 21:33:17 -06:00
Isaac Marovitz
49e83335d1 Cleanup + Format 2024-12-23 21:33:14 -06:00
Isaac Marovitz
f00cf8704f 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-12-23 21:33:12 -06:00
Isaac Marovitz
65da0569a3 Handle stride 0 on regular buffers 2024-12-23 21:33:09 -06:00
Isaac Marovitz
d811532a9f Buffer Descriptor Step Functions 2024-12-23 21:33:07 -06:00
Isaac Marovitz
a42c66e6d5 Sample LOD Level 2024-12-23 21:33:01 -06:00
Isaac Marovitz
8be6b671b8 Fix FragmentOutputColor Type 2024-12-23 21:32:59 -06:00
Isaac Marovitz
2e99df371f Stencil Ref Value 2024-12-23 21:32:56 -06:00
Isaac Marovitz
ac8af32744 Stencil Fixes 2024-12-23 21:32:54 -06:00
Isaac Marovitz
a58568d036 RenderTargetColorMasks 2024-12-23 21:32:52 -06:00
Isaac Marovitz
7ed45d12db Make dotnet format happy 2024-12-23 21:32:50 -06:00
SamoZ256
505f830556 Zero vertex buffer (#17)
* cast src size to float

* implement zero buffers
2024-12-23 21:32:47 -06:00
Isaac Marovitz
43ad627d4f Implement Texture CopyTo 2024-12-23 21:32:45 -06:00
Isaac Marovitz
c5cca8a1a3 Cleanup present 2024-12-23 21:32:43 -06:00
Isaac Marovitz
f7941a0a8b 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-12-23 21:32:40 -06:00
SamoZ256
6cc4d46e8c 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-12-23 21:32:34 -06:00
SamoZ256
18b852e05d Fix Scott Pilgrim (#15)
* check for null vertex functions

* format

* Format

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-12-23 21:32:02 -06:00
Isaac Marovitz
41e6a04a23 Suppress GC Finalize on StateCache 2024-12-23 21:31:59 -06:00
Isaac Marovitz
881ab59177 Use Stack instead of List 2024-12-23 21:31:57 -06:00
Isaac Marovitz
327c1576f7 Whitespace formatting 2024-12-23 21:31:54 -06:00
Samuliak
60ece6d9a1 dispose all temporary buffers 2024-12-23 21:31:52 -06:00
Samuliak
58b42a1143 dispose temporary metal buffer 2024-12-23 21:31:47 -06:00
Samuliak
3be47ae4a9 dispose drawable texture view 2024-12-23 21:31:41 -06:00
Samuliak
6ab989ac54 implement texture get data 2024-12-23 21:31:36 -06:00
Samuliak
9f01cce95f fix: don't dispose stencil state before using 2024-12-23 21:31:30 -06:00
Samuliak
0abbbdc277 allow null depth stencil render targets 2024-12-23 21:31:28 -06:00
Samuliak
eb7ec713ec reset certain state before doing blit or clear 2024-12-23 21:31:26 -06:00
Samuliak
d5437f3dbf reset viewport before blit 2024-12-23 21:31:24 -06:00
Samuliak
1c4e527ac2 dispose encoder state manager 2024-12-23 21:31:01 -06:00
Samuliak
af341f88df dispose all objects in encoder state manager 2024-12-23 21:30:58 -06:00
Samuliak
1ff81393be dispose caches 2024-12-23 21:30:55 -06:00
Samuliak
2cb5265c8e warn about barriers 2024-12-23 21:30:53 -06:00
Samuliak
78553f31d9 do memory barriers 2024-12-23 21:30:50 -06:00
Samuliak
60084f826e remove useless parameters 2024-12-23 21:30:48 -06:00
Samuliak
280efb2ed6 set the inline state after restoring state 2024-12-23 21:30:46 -06:00
Samuliak
14607f4471 make states private 2024-12-23 21:30:41 -06:00
Samuliak
fd4fe01348 fix: incorrect merge stuff 2024-12-23 21:30:39 -06:00
Samuliak
8f91b556af don't interrupt render pass before color clear 2024-12-23 21:30:29 -06:00
Samuliak
305a703d4a implement save and restore state system 2024-12-23 21:30:22 -06:00
Samuliak
a2c0c11380 revert deferred clears 2024-12-23 21:30:02 -06:00
Samuliak
016df3b050 prepare for deferred clears 2024-12-23 21:29:58 -06:00
Samuliak
084b75a398 resolve merge conflicts 2024-12-23 21:29:56 -06:00
Isaac Marovitz
91aed4d0dd Rebase 2024-12-23 21:29:54 -06:00
Isaac Marovitz
bea46ff9ce Cleanup + Format 2024-12-23 21:29:50 -06:00
Isaac Marovitz
58fb8564a8 Start Proper Dispose 2024-12-23 21:29:47 -06:00
Samuliak
94e077ca27 do texture barrier tiled 2024-12-23 21:29:44 -06:00
Samuliak
a10b0230c3 do texture barrier 2024-12-23 21:29:42 -06:00
Samuliak
c7dc9ba34e implement depth stencil cache 2024-12-23 21:29:40 -06:00
Isaac Marovitz
ad4db6b242 Fix typo in SamplerType.TextureBuffer 2024-12-23 21:29:37 -06:00
Isaac Marovitz
11c596a18a Fix StoreActions & Don’t Clamp Scissor for Now 2024-12-23 21:29:35 -06:00
Isaac Marovitz
7f8d54d6dc Depth Clear 2024-12-23 21:29:33 -06:00
Isaac Marovitz
90e3899c23 Shitty Clears + Inline Buffer Improvements? 2024-12-23 21:29:24 -06:00
Isaac Marovitz
381f4ec091 FragmentOutputDepth Fixes 2024-12-23 21:29:20 -06:00
Isaac Marovitz
b76f9105c8 Depth Sampler Fixes 2024-12-23 21:29:09 -06:00
Isaac Marovitz
486fd78eba Revert position changes 2024-12-23 21:29:06 -06:00
Isaac Marovitz
38385bad30 Nvm it should be in.position 2024-12-23 21:29:04 -06:00
Isaac Marovitz
27ece39dbe More shader fixes 2024-12-23 21:29:02 -06:00
Samuliak
7a6c7196c8 fix: incorrect layer count of texture view 2024-12-23 21:28:59 -06:00
Samuliak
765ca8e6c0 don't use mask on size query 2024-12-23 21:28:57 -06:00
Samuliak
d5b98d6187 declare local memory 2024-12-23 21:28:51 -06:00
Samuliak
913f25b2a0 support multiple render targets & fix: incorrect texture name 2024-12-23 21:28:41 -06:00
Samuliak
5d0ae23a0b put render pipeline cache into a separate file 2024-12-23 21:28:38 -06:00
Samuliak
dd5fb8bed9 implement pipeline cache 2024-12-23 21:28:36 -06:00
Isaac Marovitz
2316f30de1 Use return value of BeginRenderPass 2024-12-23 21:28:33 -06:00
Isaac Marovitz
96eea9de23 Cleanup 2024-12-23 21:28:31 -06:00
Samuliak
9c5917912b remove outdated comment 2024-12-23 21:28:29 -06:00
Isaac Marovitz
efe575c9b2 Fix table 2024-12-23 21:28:27 -06:00
Isaac Marovitz
ba4d6815ea Dont hardcode Vertex Format 2024-12-23 21:28:20 -06:00
Samuliak
9b99f55c4f style 2024-12-23 21:28:17 -06:00
Samuliak
5a6169b19d bring back inline updates for some state 2024-12-23 21:28:15 -06:00
Samuliak
f30aa98ce5 fix: don't rebind pipeline unless dirty 2024-12-23 21:28:12 -06:00
Samuliak
149141594f don't bind null vertex buffers 2024-12-23 21:28:09 -06:00
Samuliak
b5f15de64f mark state as dirty 2024-12-23 21:28:07 -06:00
Samuliak
bc9a26bbf2 add todo notice 2024-12-23 21:28:04 -06:00
Samuliak
f3d314104f don't end render pass when not neccessary 2024-12-23 21:28:01 -06:00
Isaac Marovitz
6324569dd2 Remove rebase garbage 2024-12-23 21:27:30 -06:00
Isaac Marovitz
2c474050f8 Be smart and use a bitmask not a list 2024-12-23 21:27:18 -06:00
Isaac Marovitz
46cc993f9a Cleanup 2024-12-23 21:27:15 -06:00
Isaac Marovitz
c51c8bdae6 Fix Vertex Attributes in Wonder & Kirby 2024-12-23 21:27:13 -06:00
Isaac Marovitz
4f356b4117 Implement SetDepthClamp 2024-12-23 21:27:10 -06:00
Isaac Marovitz
15051d6e56 Implement SetBlendState 2024-12-23 21:27:08 -06:00
Isaac Marovitz
2587e1ff22 Be consistent with things that lack support 2024-12-23 21:27:06 -06:00
Isaac Marovitz
0d5292ff8c Ignore SetDepthMode 2024-12-23 21:27:04 -06:00
Isaac Marovitz
401ad1f983 Make Texture Volatile on dispose 2024-12-23 21:26:57 -06:00
Isaac Marovitz
3c1ef06151 Format 2024-12-23 21:26:49 -06:00
Isaac Marovitz
95af212cfc Fix present 2024-12-23 21:26:46 -06:00
Isaac Marovitz
4190abbbf5 Fix Depth/Stencil attachments 2024-12-23 21:25:27 -06:00
Isaac Marovitz
c7b6e4cf80 Break everything :D 2024-12-23 21:25:24 -06:00
Isaac Marovitz
96d884a15b Clamp ScissorRect 2024-12-23 21:25:21 -06:00
Isaac Marovitz
f79ebd1141 Set DepthAttachmentPixelFormat 2024-12-23 21:25:19 -06:00
Isaac Marovitz
7f65ec0b8c Set Depth Attachment Texture 2024-12-23 21:25:17 -06:00
Isaac Marovitz
824321c88a Clamp Viewport ZNear & ZFar 2024-12-23 21:25:08 -06:00
Samuliak
91d1bb6c08 format 2024-12-23 21:24:50 -06:00
Samuliak
22d3fa068d use 0 instead of undef 2024-12-23 21:24:45 -06:00
Samuliak
d08218a809 fix: pass array index as an additional argument to sample 2024-12-23 21:24:42 -06:00
Samuliak
b7414c1e4d don't declare samplers for separate textures 2024-12-23 21:24:40 -06:00
Samuliak
a66ab905a9 don't hardcode texture type 2024-12-23 21:24:37 -06:00
Samuliak
2bef29b200 offset storage buffer bindings by 15 2024-12-23 21:24:35 -06:00
Samuliak
72eb47513c fix: incorrect abs instruction 2024-12-23 21:24:32 -06:00
Samuliak
6095f14646 add: vertex and instance id arguments 2024-12-23 21:24:29 -06:00
Samuliak
c3a9a0d625 determine type of buffer by its field types 2024-12-23 21:24:03 -06:00
Isaac Marovitz
18e1569941 Rebase + Format 2024-12-23 21:23:59 -06:00
Samuliak
362dc6eaea use unknown texture usage 2024-12-23 21:23:47 -06:00
Samuliak
d66c39b64b don't hardcode render pipeline attachments 2024-12-23 21:23:42 -06:00
Samuliak
de23abcf90 create GetSwizzle helper function 2024-12-23 21:23:32 -06:00
Samuliak
b2a0ca0e2b add: textures and samplers as shader arguments & fix: issue with casting 2024-12-23 21:23:28 -06:00
Samuliak
e3364b0fcc support fragment coord as an input to a shader 2024-12-23 21:23:24 -06:00
Samuliak
8a0dd491b9 support texture views 2024-12-23 21:23:20 -06:00
Isaac Marovitz
ba05ed9552 Format 2024-12-23 21:23:14 -06:00
Isaac Marovitz
b85721b738 Rebase + GAL Changes 2024-12-23 21:23:06 -06:00
Isaac Marovitz
9d7164a329 Remove TODOs 2024-12-23 21:21:51 -06:00
Isaac Marovitz
2f70337dca Fix Scissor/Viewport state & Validation Error 2024-12-23 21:21:47 -06:00
Isaac Marovitz
60c99e32b0 Require Argument Buffers Tier 2 2024-12-23 21:21:42 -06:00
Isaac Marovitz
ebd2d82ff3 Buffer bindings in shader…
Will need to be reworked
2024-12-23 21:21:36 -06:00
Isaac Marovitz
44bd12104b Bind Uniform & Storage Buffers 2024-12-23 21:21:31 -06:00
Evan Husted
0df70db73c remnant 2024-12-23 21:21:14 -06:00
Isaac Marovitz
64e9dcee3d Fix buffer access syntax 2024-12-23 21:19:39 -06:00
Isaac Marovitz
e353e3d3fc Dispose pipeline before window 2024-12-23 21:19:33 -06:00
Isaac Marovitz
6a67822b3b Set scissors & viewports 2024-12-23 21:19:26 -06:00
Isaac Marovitz
65b7af6308 Format 2024-12-23 21:19:22 -06:00
Isaac Marovitz
36fe41bffd Format 2024-12-23 21:19:19 -06:00
Isaac Marovitz
e758e531c5 Fix some crashes 2024-12-23 21:19:16 -06:00
Isaac Marovitz
efa9d56a56 Fix Cubemap & Array Texture Creation 2024-12-23 21:19:08 -06:00
Isaac Marovitz
b95e1d288b Properly check for 3D 2024-12-23 21:17:32 -06:00
Isaac Marovitz
48aba086e1 Fix swizzle for certain formats 2024-12-23 21:17:28 -06:00
Isaac Marovitz
44f4d41cf8 Blit at the end of the render 2024-12-23 21:17:25 -06:00
Isaac Marovitz
b4f468c653 Load attachments 2024-12-23 21:17:21 -06:00
Isaac Marovitz
3117aeca7f Cleanup Shader I/O 2024-12-23 21:17:17 -06:00
Isaac Marovitz
987a42ce30 Fix fragment shader bindings 2024-12-23 21:17:09 -06:00
Isaac Marovitz
fc7f09624c Fix VertexBuffers
Naive non-managed approach
2024-12-23 21:16:57 -06:00
Isaac Marovitz
e2445990a5 Fix some shader gen problems… 2024-12-23 21:16:52 -06:00
Isaac Marovitz
dc4305f1cf Formatting 2024-12-23 21:16:48 -06:00
Isaac Marovitz
b7a0aefa80 Make TypeConversion failure an error 2024-12-23 21:16:42 -06:00
Isaac Marovitz
7a99143a8a Fix MSL Reinterpret Casts 2024-12-23 21:16:39 -06:00
Isaac Marovitz
89d1caf30f Dont set Vertex Attributes for now 2024-12-23 21:16:35 -06:00
Isaac Marovitz
de7b3e7dac Remove capture code 2024-12-23 21:16:31 -06:00
Isaac Marovitz
94e15aa662 Bind Textures & Samplers 2024-12-23 21:16:27 -06:00
Isaac Marovitz
b157a8e549 Revise ISampler 2024-12-23 21:16:20 -06:00
Isaac Marovitz
6685041545 Try again 2024-12-23 21:16:15 -06:00
Isaac Marovitz
b8630b5c45 Resolve warning 2024-12-23 21:16:12 -06:00
Isaac Marovitz
c0da3d68ca Formatting 2024-12-23 21:16:07 -06:00
Isaac Marovitz
76bafe75f4 FIx build 2024-12-23 21:15:56 -06:00
Isaac Marovitz
3c562d8906 Fix some rebase errors 2024-12-23 21:15:36 -06:00
Isaac Marovitz
df0dc4454b End Pass on Dispose 2024-12-23 21:15:33 -06:00
Isaac Marovitz
26ea1e6d37 Don’t change Render State if Vertex Function is Invalid 2024-12-23 21:15:26 -06:00
Isaac Marovitz
e8d0212ec6 “Report” Driver 2024-12-23 21:15:18 -06:00
Isaac Marovitz
e7197877a2 Adjust function signature 2024-12-23 21:15:14 -06:00
Isaac Marovitz
dff9046f55 Get it building again 2024-12-23 21:15:07 -06:00
Isaac Marovitz
cb36036faa Render Targets 2024-12-23 21:15:01 -06:00
Isaac Marovitz
c4cf4895d8 format 2024-12-23 21:14:55 -06:00
Isaac Marovitz
b6116da940 Formatting 2024-12-23 21:14:50 -06:00
Isaac Marovitz
fbcd9994c8 smh 2024-12-23 21:14:18 -06:00
Isaac Marovitz
5d90932277 Dont specify [[stage_in]] on fragment 2024-12-23 21:14:06 -06:00
Isaac Marovitz
037157135e If one shader fails, whole program fails 2024-12-23 21:12:41 -06:00
Isaac Marovitz
d45c7711ba Fix fragment shaders (and fuck everything up) 2024-12-23 21:09:35 -06:00
Isaac Marovitz
b3629e3a8b Vertex buffer data 2024-12-23 21:09:25 -06:00
Isaac Marovitz
c216028d00 Dont be stupid 2024-12-23 21:09:18 -06:00
Isaac Marovitz
02fbcfbadb Dont set 0 attributes 2024-12-23 21:09:07 -06:00
Isaac Marovitz
a5c1b6a255 Reset Descriptor instead of making a new object 2024-12-23 21:09:00 -06:00
Isaac Marovitz
be1d099879 Set Vertex Descriptor properly 2024-12-23 21:08:54 -06:00
Isaac Marovitz
3529fcd592 Start vertex descriptor work 2024-12-23 21:08:44 -06:00
Isaac Marovitz
3398977c97 Implement CreateProgram 2024-12-23 21:08:35 -06:00
Isaac Marovitz
fe62c794b9 Fix fragment output color 2024-12-23 21:08:21 -06:00
Isaac Marovitz
2e3509f8e8 Set TargetLanguage for Metal to MSL 2024-12-23 21:08:06 -06:00
Isaac Marovitz
d65858be25 Fix IoMap variable names
Output struct

Lazy Vertex IO

Output fixes

Fix output struct definition

MSL Binding Model description

Might need tweaks/adjustments

Cleanup

Typo + Format
2024-12-23 21:07:58 -06:00
Isaac Marovitz
2a28950739 Fix ETC2 PTA formats
Format
2024-12-23 21:07:52 -06:00
Isaac Marovitz
4587905cd8 Partial TextureQuerySamples 2024-12-23 21:07:07 -06:00
Isaac Marovitz
9cc56a3bca Fix instructions 2024-12-23 21:06:58 -06:00
Isaac Marovitz
b06afd1a1f LDR ASTC 2024-12-23 21:06:52 -06:00
Isaac Marovitz
7182ac7233 Get build working again (values likely wrong) 2024-12-23 21:06:45 -06:00
Isaac Marovitz
398b6cb60e dotnet format 2024-12-23 21:06:31 -06:00
Isaac Marovitz
c5522e3694 Back to where we were
First special instruction

Start Load/Store implementation

Start TextureSample

Sample progress

I/O Load/Store Progress

Rest of load/store

TODO: Currently, the generator still assumes the GLSL style of I/O attributres. On MSL, the vertex function should output a struct which contains a float4 with the required position attribute.

TextureSize and VectorExtract

Fix UserDefined IO Vars

Fix stage input struct names
2024-12-23 21:05:34 -06:00
Isaac Marovitz
a3da70edc2 Boot TOTK 2024-12-23 21:05:28 -06:00
Evan Husted
14999a1d51
Merge branch 'master' into new-metal 2024-12-23 21:04:54 -06:00
Isaac Marovitz
94e699eeba Boot Sonic Mania 2024-12-23 21:01:19 -06:00
Isaac Marovitz
b1785c0b14 Update for new Shader IR format 2024-12-23 21:01:10 -06:00
Isaac Marovitz
84c90f8895 Update src/Ryujinx.Graphics.Metal/Pipeline.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2024-12-23 21:00:54 -06:00
Isaac Marovitz
dc4d3078ef Vertex Input Attributes 2024-12-23 21:00:45 -06:00
Isaac Marovitz
4b5c3d7fc6 More Shader Gen Stuff
Mostly copied from GLSL since in terms of syntax within blocks they’re pretty similar. Likely the result will need tweaking…

Isn’t that conveniant?

“Do the simd_shuffle”

atomics

Remaining instructions

Remove removed special instructions

Getting somewhere…
2024-12-23 21:00:23 -06:00
Isaac Marovitz
5a802a550b Fix Metal Validation Error 2024-12-23 21:00:16 -06:00
Isaac Marovitz
7c31a411df SDL2 Headless Metal Backend support 2024-12-23 20:59:56 -06:00
Isaac Marovitz
8b9d6ffc94 Easier capture stuff 2024-12-23 20:58:47 -06:00
Isaac Marovitz
4cde7a4125 Define MaxFramesPerCapture 2024-12-23 20:58:39 -06:00
Isaac Marovitz
c1ef270b9d Cleanup encoder getting + Fix capture overflow 2024-12-23 20:58:32 -06:00
Evan Husted
2812f01643 merge leftovers 2024-12-23 20:58:17 -06:00
Isaac Marovitz
7441d94f10 Formatting 2024-12-23 20:57:31 -06:00
Isaac Marovitz
a8b4e643d0 Start of MSL instructions
Remaining functions
2024-12-23 20:55:40 -06:00
Isaac Marovitz
a7908c187d Warn when generating unsupported shader 2024-12-23 20:55:27 -06:00
Isaac Marovitz
25dba8da7c Pass sampler to Blit shader 2024-12-23 20:55:21 -06:00
Isaac Marovitz
0edec0d3ff Shader comments 2024-12-23 20:55:12 -06:00
Isaac Marovitz
fb8749ce4e HelperShaders class 2024-12-23 20:53:42 -06:00
Isaac Marovitz
d36c285b79 Undertale boots 2024-12-23 20:53:33 -06:00
Isaac Marovitz
179482e9cb Check if packed depth is supported 2024-12-23 20:53:19 -06:00
Isaac Marovitz
671aff68a6 Fix RGB Seizure 2024-12-23 20:53:06 -06:00
Isaac Marovitz
8bf33b3098 Barry is here mashallah 2024-12-23 20:52:40 -06:00
Isaac Marovitz
6a115becef Seizure my beloved is working 2024-12-23 20:52:32 -06:00
Isaac Marovitz
ed445e001a SetData 2024-12-23 20:52:22 -06:00
Isaac Marovitz
93f31bd08a Look ma no crash 2024-12-23 20:44:22 -06:00
Isaac Marovitz
a60ecea4c3 Whitespace 2024-12-23 20:44:19 -06:00
Isaac Marovitz
ff0362063a TODO 2024-12-23 20:44:13 -06:00
Isaac Marovitz
e0ea464c40 BeginComputePass 2024-12-23 20:44:01 -06:00
Isaac Marovitz
05002ae234 SetDepthTest 2024-12-23 20:43:52 -06:00
Isaac Marovitz
dc60b76748 SetStencilTest 2024-12-23 20:43:43 -06:00
Isaac Marovitz
cc3c7901b6 Forgot depth 2024-12-23 20:43:37 -06:00
Isaac Marovitz
15ad03bc04 Texture usage 2024-12-23 20:43:32 -06:00
Isaac Marovitz
1d01fbf6b1 CopyBuffer to Buffer 2024-12-23 20:43:10 -06:00
Isaac Marovitz
1e835aa56f CopyTo Buffer 2024-12-23 20:42:50 -06:00
Evan Husted
93e5ff0137 up to date with 08126b26b1db39b2eb11be81b4e2ffd613b0bdbf 2024-12-23 20:41:07 -06:00
Evan Husted
6d513cad1e merging leftovers 2024-12-23 20:36:29 -06:00
Evan Husted
cbad43b003 some initial metal commits cherry-picked 2024-12-23 20:35:49 -06:00