Commit graph

960 commits

Author SHA1 Message Date
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
SamoZ256
20b1f6a6ee Fix Scott Pilgrim (#15)
* check for null vertex functions

* format

* Format

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-09-28 19:03:01 -04:00
Isaac Marovitz
8b7ac4e87f Suppress GC Finalize on StateCache 2024-09-28 19:03:01 -04:00
Isaac Marovitz
bbcd05aacf Use Stack instead of List 2024-09-28 19:03:01 -04:00
Isaac Marovitz
0e095c778a Whitespace formatting 2024-09-28 19:03:01 -04:00
Samuliak
2833642858 dispose all temporary buffers 2024-09-28 19:03:01 -04:00
Samuliak
f470430c2f dispose temporary metal buffer 2024-09-28 19:03:01 -04:00
Samuliak
051bd144e1 dispose drawable texture view 2024-09-28 19:03:01 -04:00
Samuliak
68f6c08287 implement texture get data 2024-09-28 19:03:01 -04:00
Samuliak
704a78c11f fix: don't dispose stencil state before using 2024-09-28 19:03:01 -04:00
Samuliak
acce02bdf5 allow null depth stencil render targets 2024-09-28 19:03:01 -04:00
Samuliak
8d7be4fe25 reset certain state before doing blit or clear 2024-09-28 19:03:01 -04:00
Samuliak
57a173a671 reset viewport before blit 2024-09-28 19:03:01 -04:00
Samuliak
e6e898b297 dispose encoder state manager 2024-09-28 19:03:01 -04:00
Samuliak
7654f0b16c dispose all objects in encoder state manager 2024-09-28 19:03:01 -04:00
Samuliak
c26df1f7a3 dispose caches 2024-09-28 19:03:01 -04:00
Samuliak
41fb433495 warn about barriers 2024-09-28 19:03:01 -04:00
Samuliak
1a0b928c35 do memory barriers 2024-09-28 19:03:01 -04:00
Samuliak
17334b2131 remove useless parameters 2024-09-28 19:03:01 -04:00
Samuliak
be9f5dcf69 set the inline state after restoring state 2024-09-28 19:03:01 -04:00
Samuliak
f08d6c1cad make states private 2024-09-28 19:03:01 -04:00
Samuliak
8eba42447f fix: incorrect merge stuff 2024-09-28 19:03:01 -04:00
Samuliak
3ec45f73f4 don't interrupt render pass before color clear 2024-09-28 19:03:01 -04:00
Samuliak
b475a44941 implement save and restore state system 2024-09-28 19:03:01 -04:00
Samuliak
295845e6e3 revert deferred clears 2024-09-28 19:03:01 -04:00
Samuliak
79acae3709 prepare for deferred clears 2024-09-28 19:03:01 -04:00
Samuliak
d423a53595 resolve merge conflicts 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f4190bd95a Rebase 2024-09-28 19:03:01 -04:00
Isaac Marovitz
997393bc65 Cleanup + Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
937d84018e Start Proper Dispose 2024-09-28 19:03:01 -04:00
Samuliak
4bbf7b67d4 do texture barrier tiled 2024-09-28 19:03:01 -04:00
Samuliak
b1549be8c3 do texture barrier 2024-09-28 19:03:01 -04:00
Samuliak
0d15f0fc90 implement depth stencil cache 2024-09-28 19:03:01 -04:00
Isaac Marovitz
20beb2e250 Fix typo in SamplerType.TextureBuffer 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e1279f67fe Fix StoreActions & Don’t Clamp Scissor for Now 2024-09-28 19:03:01 -04:00
Isaac Marovitz
bd3df5f26a Depth Clear 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8feee9c005 Shitty Clears + Inline Buffer Improvements? 2024-09-28 19:03:01 -04:00
Isaac Marovitz
087bf71a13 FragmentOutputDepth Fixes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
3e1f624308 Depth Sampler Fixes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8b2cc4ccf1 Revert position changes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1aa2b793eb Nvm it should be in.position 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6f44dcc416 More shader fixes 2024-09-28 19:03:01 -04:00
Samuliak
bd14efb220 fix: incorrect layer count of texture view 2024-09-28 19:03:01 -04:00
Samuliak
f5cffa0b46 don't use mask on size query 2024-09-28 19:03:01 -04:00
Samuliak
979da4c1ab declare local memory 2024-09-28 19:03:01 -04:00
Samuliak
f08d3a7517 support multiple render targets & fix: incorrect texture name 2024-09-28 19:03:01 -04:00
Samuliak
21029e895a put render pipeline cache into a separate file 2024-09-28 19:03:01 -04:00
Samuliak
bab9542020 implement pipeline cache 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f2490347af Use return value of BeginRenderPass 2024-09-28 19:03:01 -04:00
Isaac Marovitz
684e025d61 Cleanup 2024-09-28 19:03:01 -04:00
Samuliak
7983bc062b remove outdated comment 2024-09-28 19:03:01 -04:00
Isaac Marovitz
fe2337d61a Fix table 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e72c69cf19 Dont hardcode Vertex Format 2024-09-28 19:03:01 -04:00
Samuliak
9ecaacc977 style 2024-09-28 19:03:01 -04:00
Samuliak
d04e24c382 bring back inline updates for some state 2024-09-28 19:03:01 -04:00
Samuliak
bb425bf640 fix: don't rebind pipeline unless dirty 2024-09-28 19:03:01 -04:00
Samuliak
0444e43654 don't bind null vertex buffers 2024-09-28 19:03:01 -04:00
Samuliak
ccce85e1bb mark state as dirty 2024-09-28 19:03:01 -04:00
Samuliak
348a37a355 add todo notice 2024-09-28 19:03:01 -04:00
Samuliak
918e1c16b7 don't end render pass when not neccessary 2024-09-28 19:03:01 -04:00
Isaac Marovitz
2abadbd649 Remove rebase garbage 2024-09-28 19:03:01 -04:00
Isaac Marovitz
14c58f62eb Be smart and use a bitmask not a list 2024-09-28 19:03:01 -04:00
Isaac Marovitz
102c87e623 Cleanup 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a7e5c26011 Fix Vertex Attributes in Wonder & Kirby 2024-09-28 19:03:01 -04:00
Isaac Marovitz
20e1d1cd33 Implement SetDepthClamp 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f98d9bae24 Implement SetBlendState 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1db8decd12 Be consistent with things that lack support 2024-09-28 19:03:01 -04:00
Isaac Marovitz
71ccb7eaef Ignore SetDepthMode 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e6c2e5873c Make Texture Volatile on dispose 2024-09-28 19:03:01 -04:00
Isaac Marovitz
c97e7d621b Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
45b533b23b Fix present 2024-09-28 19:03:01 -04:00
Isaac Marovitz
fbe275204b Fix Depth/Stencil attachments 2024-09-28 19:03:01 -04:00
Isaac Marovitz
738227519d Break everything :D 2024-09-28 19:03:01 -04:00
Isaac Marovitz
de86f20b94 Clamp ScissorRect 2024-09-28 19:03:01 -04:00
Isaac Marovitz
fcc7cb55df Set DepthAttachmentPixelFormat 2024-09-28 19:03:01 -04:00
Isaac Marovitz
4e6abb0191 Set Depth Attachment Texture 2024-09-28 19:03:01 -04:00
Isaac Marovitz
35b0436a2b Clamp Viewport ZNear & ZFar 2024-09-28 19:03:01 -04:00
Samuliak
e99f9e2af0 format 2024-09-28 19:03:01 -04:00
Samuliak
bc3fd22f05 use 0 instead of undef 2024-09-28 19:03:01 -04:00
Samuliak
fefdabf257 fix: pass array index as an additional argument to sample 2024-09-28 19:03:01 -04:00
Samuliak
73bb0712a8 don't declare samplers for separate textures 2024-09-28 19:03:01 -04:00
Samuliak
75781ba698 don't hardcode texture type 2024-09-28 19:03:01 -04:00
Samuliak
262452f586 offset storage buffer bindings by 15 2024-09-28 19:03:01 -04:00
Samuliak
f56117a5c7 fix: incorrect abs instruction 2024-09-28 19:03:01 -04:00
Samuliak
aff8fdb2f8 add: vertex and instance id arguments 2024-09-28 19:03:01 -04:00
Samuliak
3651e8ea32 determine type of buffer by its field types 2024-09-28 19:03:01 -04:00
Isaac Marovitz
2d609ad57b Rebase + Format 2024-09-28 19:03:01 -04:00
Samuliak
559122f591 use unknown texture usage 2024-09-28 19:03:01 -04:00
Samuliak
64005ba9ee don't hardcode render pipeline attachments 2024-09-28 19:03:01 -04:00
Samuliak
a11247b72d create GetSwizzle helper function 2024-09-28 19:03:01 -04:00
Samuliak
320c317113 add: textures and samplers as shader arguments & fix: issue with casting 2024-09-28 19:03:01 -04:00
Samuliak
6295153a28 support fragment coord as an input to a shader 2024-09-28 19:03:01 -04:00
Samuliak
e638172753 support texture views 2024-09-28 19:03:01 -04:00
Isaac Marovitz
32db6cc281 Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
722aa4e45d Rebase + GAL Changes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
00b99770a2 Remove TODOs 2024-09-28 19:03:01 -04:00
Isaac Marovitz
df6821d023 Fix Scissor/Viewport state & Validation Error 2024-09-28 19:03:01 -04:00
Isaac Marovitz
17aa3c6d0f Require Argument Buffers Tier 2 2024-09-28 19:03:01 -04:00
Isaac Marovitz
5a320cca19 Buffer bindings in shader…
Will need to be reworked
2024-09-28 19:03:01 -04:00
Isaac Marovitz
192a84aa2d Bind Uniform & Storage Buffers 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ebc53d7961 Fix buffer access syntax 2024-09-28 19:03:01 -04:00
Isaac Marovitz
4d063f80b8 Dispose pipeline before window 2024-09-28 19:03:01 -04:00
Isaac Marovitz
316fea1fa9 Set scissors & viewports 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a9db9f5b27 Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
009f791879 Format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
c0bb55cf5e Fix some crashes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
54c8dabadc Fix Cubemap & Array Texture Creation 2024-09-28 19:03:01 -04:00
Isaac Marovitz
04ca284e14 Properly check for 3D 2024-09-28 19:03:01 -04:00
Isaac Marovitz
d58f79ae0f Fix swizzle for certain formats 2024-09-28 19:03:01 -04:00
Isaac Marovitz
cd7d62542a Blit at the end of the render 2024-09-28 19:03:01 -04:00
Isaac Marovitz
72209ba2a6 Load attachments 2024-09-28 19:03:01 -04:00
Isaac Marovitz
70ba3506b0 Cleanup Shader I/O 2024-09-28 19:03:01 -04:00
Isaac Marovitz
35cc208435 Fix fragment shader bindings 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8dca53685a Fix VertexBuffers
Naive non-managed approach
2024-09-28 19:03:01 -04:00
Isaac Marovitz
e517cfeb8f Fix some shader gen problems… 2024-09-28 19:03:01 -04:00
Isaac Marovitz
4a30b58e0b Formatting 2024-09-28 19:03:01 -04:00
Isaac Marovitz
bdd9ede4fd Make TypeConversion failure an error 2024-09-28 19:03:01 -04:00
Isaac Marovitz
84a8edf675 Fix MSL Reinterpret Casts 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e8a2637d46 Dont set Vertex Attributes for now 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e4a14dd23a Remove capture code 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ffb7423260 Bind Textures & Samplers 2024-09-28 19:03:01 -04:00
Isaac Marovitz
80340c98d3 Revise ISampler 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b8c60e993a Try again 2024-09-28 19:03:01 -04:00
Isaac Marovitz
d88314424b Resolve warning 2024-09-28 19:03:01 -04:00
Isaac Marovitz
df8fca012f Formatting 2024-09-28 19:03:01 -04:00
Isaac Marovitz
3d897c4f9a FIx build 2024-09-28 19:03:01 -04:00
Isaac Marovitz
62bf395970 Fix some rebase errors 2024-09-28 19:03:01 -04:00
Isaac Marovitz
bb742f64c6 End Pass on Dispose 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a669592651 Don’t change Render State if Vertex Function is Invalid 2024-09-28 19:03:01 -04:00
Isaac Marovitz
eb5fa2b546 “Report” Driver 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8e99199e19 Adjust function signature 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b439a52ac7 Get it building again 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b9c4a23f22 Render Targets 2024-09-28 19:03:01 -04:00
Isaac Marovitz
64c95bd8d8 format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
264742f085 Formatting 2024-09-28 19:03:01 -04:00
Isaac Marovitz
64d12e8d23 smh 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a9e9819b33 Dont specify [[stage_in]] on fragment 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a58d1cffe4 If one shader fails, whole program fails 2024-09-28 19:03:01 -04:00
Isaac Marovitz
511db833db Fix fragment shaders (and fuck everything up) 2024-09-28 19:03:01 -04:00
Isaac Marovitz
2890fc1069 Vertex buffer data 2024-09-28 19:03:01 -04:00
Isaac Marovitz
7f41e7dbd4 Dont be stupid 2024-09-28 19:03:01 -04:00
Isaac Marovitz
c58cc76b39 Dont set 0 attributes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
8232ce7d72 Reset Descriptor instead of making a new object 2024-09-28 19:03:01 -04:00
Isaac Marovitz
db9de66437 Set Vertex Descriptor properly 2024-09-28 19:03:01 -04:00
Isaac Marovitz
5c9d1bd0da Start vertex descriptor work 2024-09-28 19:03:01 -04:00
Isaac Marovitz
fb5402ce81 Implement CreateProgram 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ed11cdda8d Fix fragment output color 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6017c225b2 Set TargetLanguage for Metal to MSL 2024-09-28 19:03:01 -04:00
Isaac Marovitz
98e2ab5a49 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-09-28 19:03:01 -04:00
Isaac Marovitz
d5758cb310 Fix ETC2 PTA formats
Format
2024-09-28 19:03:01 -04:00
Isaac Marovitz
81b1ae4bcf Partial TextureQuerySamples 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ce5f383f5d Fix instructions 2024-09-28 19:03:01 -04:00
Isaac Marovitz
d2ec22a01b LDR ASTC 2024-09-28 19:03:01 -04:00
Isaac Marovitz
53b886d893 Get build working again (values likely wrong) 2024-09-28 19:03:01 -04:00
Isaac Marovitz
29ef76f153 dotnet format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a1b314acd2 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-09-28 19:03:01 -04:00
Isaac Marovitz
5198fcb881 Boot TOTK 2024-09-28 19:03:01 -04:00
Isaac Marovitz
b37c109673 Boot Sonic Mania 2024-09-28 19:03:01 -04:00
Isaac Marovitz
163be0a159 Update for new Shader IR format 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1f8ae7e5b1 Update src/Ryujinx.Graphics.Metal/Pipeline.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2024-09-28 19:03:01 -04:00
Isaac Marovitz
bbc2ac2e9b Vertex Input Attributes 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f07327166c 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-09-28 19:03:01 -04:00
Isaac Marovitz
1790050a14 Fix Metal Validation Error 2024-09-28 19:03:01 -04:00
Isaac Marovitz
f2c090fe55 SDL2 Headless Metal Backend support 2024-09-28 19:03:01 -04:00
Isaac Marovitz
fd0eaaafc1 Easier capture stuff 2024-09-28 19:03:01 -04:00
Isaac Marovitz
0233a0d35a Define MaxFramesPerCapture 2024-09-28 19:03:01 -04:00
Isaac Marovitz
61910fe342 Cleanup encoder getting + Fix capture overflow 2024-09-28 19:03:01 -04:00
Isaac Marovitz
1cb2ec7ebc Formatting 2024-09-28 19:03:01 -04:00
Isaac Marovitz
4ec37d1798 Start of MSL instructions
Remaining functions
2024-09-28 19:03:01 -04:00
Isaac Marovitz
27effab989 Warn when generating unsupported shader 2024-09-28 19:03:01 -04:00
Isaac Marovitz
d0d5c76f06 Pass sampler to Blit shader 2024-09-28 19:03:01 -04:00
Isaac Marovitz
a03471a8ab Shader comments 2024-09-28 19:03:01 -04:00
Isaac Marovitz
93c71110e1 HelperShaders class 2024-09-28 19:03:01 -04:00
Isaac Marovitz
00fce5a51d Undertale boots 2024-09-28 19:03:01 -04:00
Isaac Marovitz
ce5f5a6442 Check if packed depth is supported 2024-09-28 19:03:01 -04:00
Isaac Marovitz
541cdfebb7 Fix RGB Seizure 2024-09-28 19:03:01 -04:00
Isaac Marovitz
07be20c369 Barry is here mashallah 2024-09-28 19:03:01 -04:00
Isaac Marovitz
aaa140e510 Seizure my beloved is working 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6d722d83ba SetData 2024-09-28 19:03:01 -04:00
Isaac Marovitz
6c3435aaac Look ma no crash 2024-09-28 19:03:01 -04:00
Isaac Marovitz
425177a876 Whitespace 2024-09-28 19:03:01 -04:00
Isaac Marovitz
e3da359acf TODO 2024-09-28 19:03:01 -04:00
Isaac Marovitz
96bbc86331 BeginComputePass 2024-09-28 19:03:01 -04:00
Isaac Marovitz
3d42543f03 SetDepthTest 2024-09-28 19:03:01 -04:00
Isaac Marovitz
0f52165e86 SetStencilTest 2024-09-28 19:03:01 -04:00
Isaac Marovitz
628772f685 Forgot depth 2024-09-28 19:03:01 -04:00