Compare commits

..

370 Commits

Author SHA1 Message Date
Isaac Marovitz 9d32527675
Merge 79075e8386 into 73f985d27c 2024-09-19 10:49:57 +08:00
jhorv 73f985d27c
Replace passing by IMemoryOwner<byte> with passing by concrete MemoryOwner<byte> (#7171)
* refactor(perf): pass MemoryOwner<byte> around as itself rather than IMemoryOwner<byte>

* fix(perf): get span via MemoryOwner<byte>.Span property instead of through Memory property

* fix: incorrect comment change
2024-09-18 23:00:54 -03:00
Isaac Marovitz 79075e8386
GAL Changes 2024-09-18 23:52:24 +02:00
Isaac Marovitz 97bc91af52
Check for null resources before declaring them resident 2024-09-18 23:28:25 +02:00
Isaac Marovitz b0628d3d50
Fix null sampler crash 2024-09-18 23:28:25 +02:00
Isaac Marovitz 53cd0c0e7a
Fix counted indirect draws
Fixes Monster Hunter Rise and Apollo Justice
2024-09-18 23:28:24 +02:00
Isaac Marovitz e81329c7b0
Program hash set 2024-09-18 23:28:24 +02:00
Isaac Marovitz c62e00d90f
Auto-backed samplers 2024-09-18 23:28:24 +02:00
Isaac Marovitz 26f6e77008
Refactor binding logic + Bind image arrays 2024-09-18 23:28:23 +02:00
Isaac Marovitz 34eddbcf6a
Fix primitive id in shader gen
Fixes Dark Souls
2024-09-18 23:28:23 +02:00
Isaac Marovitz 94579f2042
Fix cubemap array length
Fixes crash in Sonic Frontiers
2024-09-18 23:28:23 +02:00
Isaac Marovitz c14d8cf2ee
Properly create stencil views of combined formats
Fixes Link’s Awakening
2024-09-18 23:28:22 +02:00
Isaac Marovitz f5cb7e0f67
Add missing set texture for depth stencil blit
Mostly fixes Sonic Frontiers & Link’s Awakening
2024-09-18 23:28:22 +02:00
Isaac Marovitz 252fd678fc
Fix typo in stride change shader
Fixes Castlevania Dominus Collection
2024-09-18 23:28:21 +02:00
Isaac Marovitz 76d7bef031
Fix invalid depth stencil state when no depth stencil is present
Partially fixes Sonic Frontiers and Castlevania Dominus Collection
2024-09-18 23:28:21 +02:00
Isaac Marovitz 6e332be51c
Style 2024-09-18 23:28:21 +02:00
Isaac Marovitz d30d23bd0f
Metal: Unsupported topology indexed draw conversion (#40)
* Convert unsupported indexed buffer topologies

* Fix index count and dispatch size

* Cleanup

* Fix typos
2024-09-18 23:28:21 +02:00
Isaac Marovitz 4439e7dcdc
Fix null resources breaking arg buffer alignment 2024-09-18 23:28:20 +02:00
Isaac Marovitz 3bd4dc7f2b
Remove RenderPipelineDescriptorResult 2024-09-18 23:28:20 +02:00
Isaac Marovitz 363c4a80ff
D32FS8 to D24S8 Conversion 2024-09-18 23:28:20 +02:00
Isaac Marovitz 3d30f0f907
Upstream changes 2024-09-18 23:28:20 +02:00
Isaac Marovitz 81c6b29232
Logic Operations 2024-09-18 23:28:20 +02:00
Isaac Marovitz 29f6262260
Fix array size query 2024-09-18 23:28:19 +02:00
Isaac Marovitz a0ac4921ad
Debug Groups 2024-09-18 23:28:19 +02:00
Isaac Marovitz cee1a8ee60
IaIndexing
Fixes shader problems in Donkey Kong Country Tropical Freeze, and Fire Emblem: Three Houses
2024-09-18 23:28:19 +02:00
Isaac Marovitz 8766378ce8
Rasterizer Discard + Multisample State 2024-09-18 23:28:19 +02:00
Isaac Marovitz ba63762ff5
Metal: Argument Buffer Pre-Pass (#38)
* Init

* Fix missing flags

* Cleanup
2024-09-18 23:28:18 +02:00
riperiperi 03c475d4b5
Patch some leaks and only perform copies on valid textures (#37) 2024-09-18 23:28:18 +02:00
Isaac Marovitz 9e05ee9a4d
Get render command encoder after finalising buffers
Fixes crash in Fire Emblem: Houses
2024-09-18 23:28:18 +02:00
Isaac Marovitz 3876f60c7f
Format 2024-09-18 23:28:18 +02:00
Isaac Marovitz 8674ea6752
Fix non atomic image loads again 2024-09-18 23:28:17 +02:00
Isaac Marovitz 4fed5634c2
Finally fix (most) image atomics 2024-09-18 23:28:17 +02:00
Isaac Marovitz 3e474d84e8
Precise Float Fixes
Fixes artifacts in TOTK
2024-09-18 23:28:17 +02:00
Isaac Marovitz 4848335975
Fix image atomics 2024-09-18 23:28:17 +02:00
Isaac Marovitz 5dc244ae68
Fix Non-Float Textures + Image Read + FSI Buffers
Fixes Mario Party Superstars
2024-09-18 23:28:17 +02:00
Isaac Marovitz c30c609624
Image Constant Fixes
Allows Mario Party Superstars to boot
2024-09-18 23:28:16 +02:00
Isaac Marovitz 95318b9abe
Helper Shader fixes for non float formats 2024-09-18 23:28:16 +02:00
Isaac Marovitz 3336c86fe5
Shader Extra Set Support + Cleanup (#36)
Separate samplers are now supported and arrays in constant sets are bound
2024-09-18 23:28:16 +02:00
Isaac Marovitz fa1f91f96c
InstGenMemory Refactor + Bindless Support 2024-09-18 23:28:16 +02:00
Isaac Marovitz ce2124437d
TextureArray & ImageArray Creation + State 2024-09-18 23:28:16 +02:00
Isaac Marovitz 4eb74a310b
Fix hex number type ambiguity
Fixes cutscenes in Super Mario Sunshine
2024-09-18 23:28:15 +02:00
Isaac Marovitz c1745a27ab
Use RGBA8Unorm for R4G4B4A4Unorm
Gets SM64 to boot
2024-09-18 23:28:15 +02:00
Isaac Marovitz 13afe36f63
Dual Source Blend Support in Shader
Fixes Super Mario Galaxy and The Legend of Zelda: Skyward Sword HD
2024-09-18 23:28:15 +02:00
Isaac Marovitz 2fdd352255
Get Tomb Raider working 2024-09-18 23:28:15 +02:00
Isaac Marovitz 4ddecbb6fe
Remove DummyBufferTextures
Mostly gets VTG on Compute working again
2024-09-18 23:28:14 +02:00
Isaac Marovitz 3429ee2318
Properly register TextureBuffer usage + Store Auto ref 2024-09-18 23:28:14 +02:00
Isaac Marovitz 479ea9f8e8
Partial indirect draw support 2024-09-18 23:28:14 +02:00
Gabriel A 7de9bffe91
Fixes 2024-09-18 23:28:14 +02:00
Gabriel A a72ce9998f
Start building more accurate vertex as compute usage info 2024-09-18 23:28:13 +02:00
Isaac Marovitz 1987309fda
Bind TextureBuffers 2024-09-18 23:28:13 +02:00
Isaac Marovitz b3e002f8dc
Remove ClearSegments for now
Currently unimplemented and issues are arising with building BindingSegments in general.
2024-09-18 23:28:13 +02:00
Isaac Marovitz e8e18f2578
Fix compute generation failure in NieR 2024-09-18 23:28:12 +02:00
Isaac Marovitz 27e9671da4
Some debug improvements 2024-09-18 23:28:12 +02:00
Isaac Marovitz 0449964760
Stop complaining about clip distance 2024-09-18 23:28:12 +02:00
Isaac Marovitz c6bfc660ef
Shader Gen Fixes
Fixes Luigi’s Mansion 2 HD
2024-09-18 23:28:12 +02:00
Isaac Marovitz f07d957bda
DepthStencil Blits 2024-09-18 23:28:11 +02:00
Isaac Marovitz 10110198f7
Multisample Blits
Partially fixes Sonic Colors Ultimate
2024-09-18 23:28:11 +02:00
Isaac Marovitz bdcc2fd90e
Fix image bindings 2024-09-18 23:28:11 +02:00
Isaac Marovitz 6be0890f34
FSI (with raster order groups) 2024-09-18 23:28:11 +02:00
Isaac Marovitz 1bb3f28504
SwizzleAdd (NOT TESTED) 2024-09-18 23:28:11 +02:00
Isaac Marovitz b4cf2d1cc9
Consolodate barriers 2024-09-18 23:28:10 +02:00
Isaac Marovitz 61c7d3bb9c
Shader Memory Barriers
Fixes some of the shader generation failures in Sonic Frontiers
2024-09-18 23:28:10 +02:00
Isaac Marovitz fdf5d49985
Image binding support
Kirby still has a problem with NaN 3D Texture
2024-09-18 23:28:10 +02:00
Isaac Marovitz 1500af5808
Image shader gen support 2024-09-18 23:28:10 +02:00
Isaac Marovitz 32a3d1df4d
Shader cache support 2024-09-18 23:28:09 +02:00
Isaac Marovitz a32b619f5c
Make dotnet format happy 2024-09-18 23:28:09 +02:00
Isaac Marovitz a8794b2d58
GAL ResourceUsage Changes
TODO: Guest Barrier Defer
2024-09-18 23:28:09 +02:00
Isaac Marovitz 02b9b92723
Better vertex buffer management 2024-09-18 23:28:08 +02:00
Isaac Marovitz 1b2097c6eb
Fix LOD 2024-09-18 23:28:08 +02:00
Isaac Marovitz 10c042b6ab
Better index buffer management 2024-09-18 23:28:08 +02:00
Isaac Marovitz fa9d38c779
Formatting cleanup 2024-09-18 23:28:07 +02:00
Isaac Marovitz f8e232404e
Formatting 2024-09-18 23:28:07 +02:00
Isaac Marovitz 1a56e4477a
Update binding model description comment 2024-09-18 23:28:07 +02:00
riperiperi 8369f15bf5
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-18 23:28:07 +02:00
Isaac Marovitz 6f440f53f4
Fix invariant position not doing its job 2024-09-18 23:28:06 +02:00
riperiperi 16a9b18c26
implement compressed/uncompressed copy, fix other copies, fix int/uint output shaders (#33) 2024-09-18 23:28:06 +02:00
Isaac Marovitz 5a8e070c04
Fix blend state optimisation breaking attachments
Fixes SM3DW
2024-09-18 23:28:06 +02:00
riperiperi e1568613af
Fix warnings 2024-09-18 23:28:06 +02:00
riperiperi 01094222c7
Maintain identity swizzle view of textures for rendering 2024-09-18 23:28:06 +02:00
riperiperi 4b95934fef
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-18 23:28:05 +02:00
Isaac Marovitz c92a9e0ae5
Cleanup + Format 2024-09-18 23:28:05 +02:00
Isaac Marovitz d111b152d1
Fix trying to reserve size 0 in staging buffer 2024-09-18 23:28:05 +02:00
Isaac Marovitz bf1884c259
Fix zero buff not being reset 2024-09-18 23:28:05 +02:00
Isaac Marovitz 19b089a236
Dirty Arg Buffers on Program Change 2024-09-18 23:28:05 +02:00
Isaac Marovitz 9a0d50817c
Least allocations in the west 2024-09-18 23:28:04 +02:00
Isaac Marovitz 4909b73332
Don’t use Enum.HasFlag 2024-09-18 23:28:04 +02:00
Isaac Marovitz 18a3ee16bb
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-18 23:28:04 +02:00
Isaac Marovitz 2507d351af
Update comment for Metal 2024-09-18 23:28:04 +02:00
Isaac Marovitz f59fae3612
Don’t do inline vertex buffer updates
Somehow broke zero buff MTLVertexDescriptor, but fixes broken geoemtry so I’m pushing anyway
2024-09-18 23:28:03 +02:00
riperiperi 117c5c1645
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-18 23:28:03 +02:00
riperiperi e3dd174f28
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-18 23:28:03 +02:00
Isaac Marovitz 459d1d6e54
Dont bind images in texture slots 2024-09-18 23:28:03 +02:00
Isaac Marovitz f3feabad2e
Stop depth/stencil blits from crashing everything 2024-09-18 23:28:03 +02:00
riperiperi a33187f7db
Fix Geometry/TFB on compute, Buffer Textures, add Window Resizing (#28) 2024-09-18 23:28:02 +02:00
riperiperi ac5932cd02
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-18 23:27:50 +02:00
Isaac Marovitz 88ce186191
Fragment input interpolation qualifiers
Fixes Mario’s shadow in SMO
2024-09-18 23:27:49 +02:00
Isaac Marovitz b950e12ab8
CommandBufferBarrier 2024-09-18 23:27:49 +02:00
riperiperi 5f1d3fd744
Add constrained border colours to samplers (#26) 2024-09-18 23:27:49 +02:00
Isaac Marovitz cb65fdf95a
Don’t bind byte format converted index buffers at requested index 2024-09-18 23:27:49 +02:00
Isaac Marovitz f61f587d37
Render target deduplication
not sure if this is working
2024-09-18 23:27:48 +02:00
Isaac Marovitz 55a5b1e75e
Fix CBP not doing its job
Thanks peri (again)
2024-09-18 23:27:48 +02:00
Isaac Marovitz 17a27cf59b
Fix blend descriptors not dirting render pipeline
Thanks peri
2024-09-18 23:27:48 +02:00
Isaac Marovitz e2c0b1b1ec
Support non-index quad draws
Fixes Deltarune
2024-09-18 23:27:48 +02:00
Isaac Marovitz ba21266a3e
Be better about memory 2024-09-18 23:27:47 +02:00
Isaac Marovitz ea95713056
Fix stencil clears 2024-09-18 23:27:47 +02:00
Isaac Marovitz 97c22e2f1a
Enable Alpha Test workaround on Metal 2024-09-18 23:27:47 +02:00
Isaac Marovitz 8a006514d3
Fix Cull FrontAndBack 2024-09-18 23:27:46 +02:00
Isaac Marovitz f16693e4e1
Warning about host map buffer creation 2024-09-18 23:27:46 +02:00
Isaac Marovitz 4dad6d12b9
Fix fragment point_coord in 2024-09-18 23:27:46 +02:00
Isaac Marovitz e6f4745bb5
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-18 23:27:45 +02:00
Isaac Marovitz 23b9a780ee
VoteAllEqual, FindLSB/MSB 2024-09-18 23:27:45 +02:00
Isaac Marovitz 3fe47449b4
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-18 23:27:45 +02:00
Isaac Marovitz b54bfb1a7c
Actually clear the right render target 2024-09-18 23:27:45 +02:00
Isaac Marovitz 3fd758532b
Big GetData()
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2024-09-18 23:27:44 +02:00
Isaac Marovitz 461933b8cd
Fix Animal Crossing Crash 2024-09-18 23:27:44 +02:00
Isaac Marovitz e4fa286698
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-18 23:27:44 +02:00
Isaac Marovitz a83eb53abf
PreloadCbs + FlushCommandsIfWeightExceeding 2024-09-18 23:27:44 +02:00
Isaac Marovitz 6550f1cd66
Cleanup Pipeline
Housekeeping

More housekeeping
2024-09-18 23:27:43 +02:00
Isaac Marovitz 36f7d4eafa
PersistentFlushBuffer + BackgroundResources 2024-09-18 23:27:43 +02:00
Isaac Marovitz c59142a500
Match S8UintD24Unorm to Depth24UnormStencil8
Kind of works for es2gears
2024-09-18 23:27:43 +02:00
Isaac Marovitz be78e7a1a5
Fix FEZ not showing anything
Does not fix the underlying shortcomings of the cache system
2024-09-18 23:27:43 +02:00
Isaac Marovitz 0561d708f8
Clear cached converted buffers on signaled write 2024-09-18 23:27:42 +02:00
Isaac Marovitz a197340e22
FIx regression 2024-09-18 23:27:42 +02:00
Isaac Marovitz de4d4016b3
Helper shader cleanup 2024-09-18 23:27:42 +02:00
Isaac Marovitz 705ec71f65
Use buffer manager for color blit 2024-09-18 23:27:42 +02:00
Isaac Marovitz 04982f792e
Buffer Conversions (#23)
* Why is this not working

* Revert helper shader changes for now

* Byte Index Buffer Restride
2024-09-18 23:27:41 +02:00
riperiperi 45239b3810
don't recreate render pipeline unless we're about to draw, pass view depth properly (#22) 2024-09-18 23:27:41 +02:00
Isaac Marovitz e016da58e1
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-18 23:27:41 +02:00
Isaac Marovitz 7158c8ddc2
Log failed format conversions 2024-09-18 23:27:40 +02:00
Isaac Marovitz dee19f8227
Print shader code involved in failed linking 2024-09-18 23:27:40 +02:00
Isaac Marovitz 774359f6b7
Don’t use DidModifyRange 2024-09-18 23:27:40 +02:00
Isaac Marovitz 04703f0191
Fix sample compare 2024-09-18 23:27:40 +02:00
Isaac Marovitz b0f167a13b
Depth Bias 2024-09-18 23:27:40 +02:00
Isaac Marovitz e6eb997892
Map R5G5B5A1Unorm 2024-09-18 23:27:39 +02:00
Samuliak 87b46ad5c1
override Equals for render pipeline hash 2024-09-18 23:27:39 +02:00
Isaac Marovitz 1d96ca6c80
Disable scaled vertex formats 2024-09-18 23:27:39 +02:00
Isaac Marovitz a2328bd8fb
Disable Vector Indexing Bug Workaround 2024-09-18 23:27:39 +02:00
Isaac Marovitz 4a4ac78373
Fix modulo operator
Support sample offsets

Include FragmentIn as additional arg

Always declare frag output struct

SubgroupLaneId
2024-09-18 23:27:38 +02:00
Isaac Marovitz 8e2e6c48de
Workaround for Wonder 2024-09-18 23:27:38 +02:00
Isaac Marovitz 0c351a6caa
Fix 3D -> 3D Texture Copies 2024-09-18 23:27:38 +02:00
Isaac Marovitz fe7b8c4514
Fix Clear Viewport 2024-09-18 23:27:38 +02:00
Isaac Marovitz 66f68e08a3
Fix sample-less reads with lod 2024-09-18 23:27:37 +02:00
Isaac Marovitz fdfd457d6e
Fix Pack and UnpackHalf2x16 2024-09-18 23:27:37 +02:00
Isaac Marovitz 5322de91b5
Handle Array Format SetData 2024-09-18 23:27:37 +02:00
Isaac Marovitz d694878d2c
Cleanup 2024-09-18 23:27:37 +02:00
Isaac Marovitz 5b47001b38
Implement IoVariable.FrontFacing 2024-09-18 23:27:36 +02:00
Isaac Marovitz 159db87d86
Fix LOD sample typo 2024-09-18 23:27:36 +02:00
Isaac Marovitz 8a6fde9fea
Rebase Changes 2024-09-18 23:27:36 +02:00
Isaac Marovitz 2996f96a42
More cleanup 2024-09-18 23:27:36 +02:00
Isaac Marovitz 638b9e5f69
Cleanup + Format 2024-09-18 23:27:35 +02:00
Isaac Marovitz 3ff27f541e
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-18 23:27:35 +02:00
Isaac Marovitz cc747047cd
Handle stride 0 on regular buffers 2024-09-18 23:26:44 +02:00
Isaac Marovitz de2a8cece4
Buffer Descriptor Step Functions 2024-09-18 23:26:43 +02:00
Isaac Marovitz 4e130e7e38
Sample LOD Level 2024-09-18 23:26:43 +02:00
Isaac Marovitz 63ab5b0639
Fix FragmentOutputColor Type 2024-09-18 23:26:43 +02:00
Isaac Marovitz 2941f02c87
Stencil Ref Value 2024-09-18 23:26:42 +02:00
Isaac Marovitz 01122ca032
Stencil Fixes 2024-09-18 23:26:42 +02:00
Isaac Marovitz d8f9aaeaac
RenderTargetColorMasks 2024-09-18 23:26:42 +02:00
Isaac Marovitz 9238b6723c
Make dotnet format happy 2024-09-18 23:26:41 +02:00
SamoZ256 2225aa17e3
Zero vertex buffer (#17)
* cast src size to float

* implement zero buffers
2024-09-18 23:26:41 +02:00
Isaac Marovitz 4f649f5650
Implement Texture CopyTo 2024-09-18 23:26:40 +02:00
Isaac Marovitz eac8ac23ad
Cleanup present 2024-09-18 23:26:40 +02:00
Isaac Marovitz b7915ac3cf
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-18 23:26:40 +02:00
SamoZ256 8cbdbad67f
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-18 23:26:39 +02:00
SamoZ256 5f6d375b00
Fix Scott Pilgrim (#15)
* check for null vertex functions

* format

* Format

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-09-18 23:26:39 +02:00
Isaac Marovitz f837be962f
Suppress GC Finalize on StateCache 2024-09-18 23:26:39 +02:00
Isaac Marovitz a14ca383b2
Use Stack instead of List 2024-09-18 23:26:38 +02:00
Isaac Marovitz c19dee2f8e
Whitespace formatting 2024-09-18 23:26:38 +02:00
Samuliak f7fc475ee4
dispose all temporary buffers 2024-09-18 23:26:38 +02:00
Samuliak de01995e95
dispose temporary metal buffer 2024-09-18 23:26:37 +02:00
Samuliak 330935e780
dispose drawable texture view 2024-09-18 23:26:37 +02:00
Samuliak c8d51c693e
implement texture get data 2024-09-18 23:26:37 +02:00
Samuliak 09983b8188
fix: don't dispose stencil state before using 2024-09-18 23:26:36 +02:00
Samuliak 24158b2e1c
allow null depth stencil render targets 2024-09-18 23:26:36 +02:00
Samuliak 6d12cb529d
reset certain state before doing blit or clear 2024-09-18 23:26:36 +02:00
Samuliak 934a5941b9
reset viewport before blit 2024-09-18 23:26:35 +02:00
Samuliak 680f950a59
dispose encoder state manager 2024-09-18 23:26:35 +02:00
Samuliak af4b762ce3
dispose all objects in encoder state manager 2024-09-18 23:26:35 +02:00
Samuliak 952ed6bb41
dispose caches 2024-09-18 23:26:35 +02:00
Samuliak 4a97c2b64d
warn about barriers 2024-09-18 23:26:34 +02:00
Samuliak cb183b3945
do memory barriers 2024-09-18 23:26:34 +02:00
Samuliak b051cda16a
remove useless parameters 2024-09-18 23:26:33 +02:00
Samuliak c3c75b2939
set the inline state after restoring state 2024-09-18 23:26:33 +02:00
Samuliak 541f1096b7
make states private 2024-09-18 23:26:33 +02:00
Samuliak 6296de1a65
fix: incorrect merge stuff 2024-09-18 23:26:32 +02:00
Samuliak bff52c221b
don't interrupt render pass before color clear 2024-09-18 23:26:32 +02:00
Samuliak 37272c6223
implement save and restore state system 2024-09-18 23:26:32 +02:00
Samuliak 56fcfba689
revert deferred clears 2024-09-18 23:26:31 +02:00
Samuliak 19c5391e7d
prepare for deferred clears 2024-09-18 23:26:31 +02:00
Samuliak f93d309bff
resolve merge conflicts 2024-09-18 23:26:30 +02:00
Isaac Marovitz 854c25e0a6
Rebase 2024-09-18 23:26:30 +02:00
Isaac Marovitz a42b70890b
Cleanup + Format 2024-09-18 23:26:30 +02:00
Isaac Marovitz 67e83af943
Start Proper Dispose 2024-09-18 23:26:29 +02:00
Samuliak 8ad4ee2892
do texture barrier tiled 2024-09-18 23:26:29 +02:00
Samuliak 5bf7e146fa
do texture barrier 2024-09-18 23:26:29 +02:00
Samuliak 94b253476e
implement depth stencil cache 2024-09-18 23:26:28 +02:00
Isaac Marovitz 57d68ce7f0
Fix typo in SamplerType.TextureBuffer 2024-09-18 23:26:28 +02:00
Isaac Marovitz d5f510a745
Fix StoreActions & Don’t Clamp Scissor for Now 2024-09-18 23:26:27 +02:00
Isaac Marovitz f836258728
Depth Clear 2024-09-18 23:26:27 +02:00
Isaac Marovitz d79f6b9743
Shitty Clears + Inline Buffer Improvements? 2024-09-18 23:26:26 +02:00
Isaac Marovitz 52978986c7
FragmentOutputDepth Fixes 2024-09-18 23:26:26 +02:00
Isaac Marovitz 1984c5af7e
Depth Sampler Fixes 2024-09-18 23:26:26 +02:00
Isaac Marovitz 8e9f7f4829
Revert position changes 2024-09-18 23:26:25 +02:00
Isaac Marovitz 3044457dca
Nvm it should be in.position 2024-09-18 23:26:25 +02:00
Isaac Marovitz 290b8657d2
More shader fixes 2024-09-18 23:26:25 +02:00
Samuliak 0b2984e4b6
fix: incorrect layer count of texture view 2024-09-18 23:26:24 +02:00
Samuliak 0d7fb3aaef
don't use mask on size query 2024-09-18 23:26:24 +02:00
Samuliak 89c29152d0
declare local memory 2024-09-18 23:26:23 +02:00
Samuliak c3575ce115
support multiple render targets & fix: incorrect texture name 2024-09-18 23:26:23 +02:00
Samuliak bde83d8469
put render pipeline cache into a separate file 2024-09-18 23:26:23 +02:00
Samuliak d77f5a7fb1
implement pipeline cache 2024-09-18 23:26:22 +02:00
Isaac Marovitz 4d24cc6e63
Use return value of BeginRenderPass 2024-09-18 23:26:22 +02:00
Isaac Marovitz 9e799f5589
Cleanup 2024-09-18 23:26:22 +02:00
Samuliak 19f53084fc
remove outdated comment 2024-09-18 23:26:22 +02:00
Isaac Marovitz d72e63978e
Fix table 2024-09-18 23:26:21 +02:00
Isaac Marovitz a1851c480e
Dont hardcode Vertex Format 2024-09-18 23:26:21 +02:00
Samuliak e2fc86a67e
style 2024-09-18 23:26:21 +02:00
Samuliak f3885d72e5
bring back inline updates for some state 2024-09-18 23:26:20 +02:00
Samuliak 4235eddfd2
fix: don't rebind pipeline unless dirty 2024-09-18 23:26:20 +02:00
Samuliak 45f7e4ce53
don't bind null vertex buffers 2024-09-18 23:26:20 +02:00
Samuliak 5c34de072c
mark state as dirty 2024-09-18 23:26:19 +02:00
Samuliak 77ca515e06
add todo notice 2024-09-18 23:26:19 +02:00
Samuliak c3d1f93bc1
don't end render pass when not neccessary 2024-09-18 23:26:19 +02:00
Isaac Marovitz 9e8b333d9c
Remove rebase garbage 2024-09-18 23:26:18 +02:00
Isaac Marovitz ac96cb7587
Be smart and use a bitmask not a list 2024-09-18 23:26:18 +02:00
Isaac Marovitz 503291e5d9
Cleanup 2024-09-18 23:26:18 +02:00
Isaac Marovitz 408b72bce1
Fix Vertex Attributes in Wonder & Kirby 2024-09-18 23:26:17 +02:00
Isaac Marovitz 205df92942
Implement SetDepthClamp 2024-09-18 23:26:17 +02:00
Isaac Marovitz f72a5ccdf9
Implement SetBlendState 2024-09-18 23:26:17 +02:00
Isaac Marovitz 12fc642fb6
Be consistent with things that lack support 2024-09-18 23:26:17 +02:00
Isaac Marovitz c70f7005dd
Ignore SetDepthMode 2024-09-18 23:26:16 +02:00
Isaac Marovitz 500aff53b1
Make Texture Volatile on dispose 2024-09-18 23:26:16 +02:00
Isaac Marovitz 0a7cec1a29
Format 2024-09-18 23:26:15 +02:00
Isaac Marovitz 07e329a37c
Fix present 2024-09-18 23:26:15 +02:00
Isaac Marovitz 1433218fad
Fix Depth/Stencil attachments 2024-09-18 23:26:15 +02:00
Isaac Marovitz 741b74a991
Break everything :D 2024-09-18 23:26:14 +02:00
Isaac Marovitz 369476f775
Clamp ScissorRect 2024-09-18 23:26:14 +02:00
Isaac Marovitz 271d185861
Set DepthAttachmentPixelFormat 2024-09-18 23:26:13 +02:00
Isaac Marovitz a568e19434
Set Depth Attachment Texture 2024-09-18 23:26:13 +02:00
Isaac Marovitz 6d3df3a4ab
Clamp Viewport ZNear & ZFar 2024-09-18 23:26:13 +02:00
Samuliak 97f8c836d6
format 2024-09-18 23:26:13 +02:00
Samuliak 200da3dc55
use 0 instead of undef 2024-09-18 23:26:12 +02:00
Samuliak 4a65260655
fix: pass array index as an additional argument to sample 2024-09-18 23:26:12 +02:00
Samuliak d13e4c5101
don't declare samplers for separate textures 2024-09-18 23:26:12 +02:00
Samuliak 5741fb90f9
don't hardcode texture type 2024-09-18 23:26:11 +02:00
Samuliak 05eedc5066
offset storage buffer bindings by 15 2024-09-18 23:26:11 +02:00
Samuliak e4534bb0e0
fix: incorrect abs instruction 2024-09-18 23:26:11 +02:00
Samuliak 299ca72b7a
add: vertex and instance id arguments 2024-09-18 23:26:10 +02:00
Samuliak d1a60c7053
determine type of buffer by its field types 2024-09-18 23:26:10 +02:00
Isaac Marovitz 6e524358d4
Rebase + Format 2024-09-18 23:26:09 +02:00
Samuliak 0cda74a780
use unknown texture usage 2024-09-18 23:26:09 +02:00
Samuliak 74cee40e33
don't hardcode render pipeline attachments 2024-09-18 23:26:09 +02:00
Samuliak f9e24fd087
create GetSwizzle helper function 2024-09-18 23:26:08 +02:00
Samuliak 00009666a7
add: textures and samplers as shader arguments & fix: issue with casting 2024-09-18 23:26:08 +02:00
Samuliak 1956a60616
support fragment coord as an input to a shader 2024-09-18 23:26:08 +02:00
Samuliak 9835682c75
support texture views 2024-09-18 23:26:07 +02:00
Isaac Marovitz 451053c3d9
Format 2024-09-18 23:26:07 +02:00
Isaac Marovitz f56b826da9
Rebase + GAL Changes 2024-09-18 23:26:07 +02:00
Isaac Marovitz aa53977e98
Remove TODOs 2024-09-18 23:26:06 +02:00
Isaac Marovitz 37b08ebaef
Fix Scissor/Viewport state & Validation Error 2024-09-18 23:26:06 +02:00
Isaac Marovitz 841e3bb3f9
Require Argument Buffers Tier 2 2024-09-18 23:26:06 +02:00
Isaac Marovitz 9ce7c5550c
Buffer bindings in shader…
Will need to be reworked
2024-09-18 23:26:05 +02:00
Isaac Marovitz 0162925ff6
Bind Uniform & Storage Buffers 2024-09-18 23:26:05 +02:00
Isaac Marovitz db6788ec3a
Fix buffer access syntax 2024-09-18 23:26:04 +02:00
Isaac Marovitz 1f7a5901ad
Dispose pipeline before window 2024-09-18 23:26:04 +02:00
Isaac Marovitz fa349408b1
Set scissors & viewports 2024-09-18 23:26:04 +02:00
Isaac Marovitz 9afcbda196
Format 2024-09-18 23:26:03 +02:00
Isaac Marovitz 65146bd3e4
Format 2024-09-18 23:26:03 +02:00
Isaac Marovitz 3e40dd08ec
Fix some crashes 2024-09-18 23:26:03 +02:00
Isaac Marovitz 0f41219e5f
Fix Cubemap & Array Texture Creation 2024-09-18 23:26:02 +02:00
Isaac Marovitz 6d3f3b30b8
Properly check for 3D 2024-09-18 23:26:02 +02:00
Isaac Marovitz f611fc7103
Fix swizzle for certain formats 2024-09-18 23:26:02 +02:00
Isaac Marovitz 1b7634f232
Blit at the end of the render 2024-09-18 23:26:01 +02:00
Isaac Marovitz 54865122aa
Load attachments 2024-09-18 23:26:01 +02:00
Isaac Marovitz 3f8c111eef
Cleanup Shader I/O 2024-09-18 23:26:00 +02:00
Isaac Marovitz cc8bc3f921
Fix fragment shader bindings 2024-09-18 23:26:00 +02:00
Isaac Marovitz 8fd4270012
Fix VertexBuffers
Naive non-managed approach
2024-09-18 23:25:59 +02:00
Isaac Marovitz a179c6111c
Fix some shader gen problems… 2024-09-18 23:25:59 +02:00
Isaac Marovitz 4560fe762b
Formatting 2024-09-18 23:25:59 +02:00
Isaac Marovitz 711fba5475
Make TypeConversion failure an error 2024-09-18 23:25:58 +02:00
Isaac Marovitz f7c9d77968
Fix MSL Reinterpret Casts 2024-09-18 23:25:58 +02:00
Isaac Marovitz 0de46a3a70
Dont set Vertex Attributes for now 2024-09-18 23:25:58 +02:00
Isaac Marovitz 67269fd9a9
Remove capture code 2024-09-18 23:25:57 +02:00
Isaac Marovitz 4b80b015fb
Bind Textures & Samplers 2024-09-18 23:25:56 +02:00
Isaac Marovitz 7febe159fe
Revise ISampler 2024-09-18 23:25:56 +02:00
Isaac Marovitz a104af7410
Try again 2024-09-18 23:25:55 +02:00
Isaac Marovitz c9f7d7e85a
Resolve warning 2024-09-18 23:25:55 +02:00
Isaac Marovitz 6e2dfefd8f
Formatting 2024-09-18 23:25:55 +02:00
Isaac Marovitz 84d9ec13b9
FIx build 2024-09-18 23:25:54 +02:00
Isaac Marovitz f959a910eb
Fix some rebase errors 2024-09-18 23:25:54 +02:00
Isaac Marovitz c3aba3a6d5
End Pass on Dispose 2024-09-18 23:25:53 +02:00
Isaac Marovitz 84d0b3b052
Don’t change Render State if Vertex Function is Invalid 2024-09-18 23:25:53 +02:00
Isaac Marovitz d397e9477a
“Report” Driver 2024-09-18 23:25:53 +02:00
Isaac Marovitz 45f5d99436
Adjust function signature 2024-09-18 23:25:52 +02:00
Isaac Marovitz 1d36be2537
Get it building again 2024-09-18 23:25:52 +02:00
Isaac Marovitz bd95b023c5
Render Targets 2024-09-18 23:25:51 +02:00
Isaac Marovitz 134e258751
format 2024-09-18 23:25:51 +02:00
Isaac Marovitz dbdd9b9d80
Formatting 2024-09-18 23:25:51 +02:00
Isaac Marovitz 2d156a3c08
smh 2024-09-18 23:25:50 +02:00
Isaac Marovitz 5452048292
Dont specify [[stage_in]] on fragment 2024-09-18 23:25:50 +02:00
Isaac Marovitz cec40e5bd5
If one shader fails, whole program fails 2024-09-18 23:25:50 +02:00
Isaac Marovitz 6e3b317d26
Fix fragment shaders (and fuck everything up) 2024-09-18 23:25:49 +02:00
Isaac Marovitz 1ac82d527b
Vertex buffer data 2024-09-18 23:25:49 +02:00
Isaac Marovitz 5eff585e8f
Dont be stupid 2024-09-18 23:25:49 +02:00
Isaac Marovitz 91c040d649
Dont set 0 attributes 2024-09-18 23:25:48 +02:00
Isaac Marovitz bb09ab818c
Reset Descriptor instead of making a new object 2024-09-18 23:25:48 +02:00
Isaac Marovitz 2051e274ee
Set Vertex Descriptor properly 2024-09-18 23:25:48 +02:00
Isaac Marovitz 52640171bf
Start vertex descriptor work 2024-09-18 23:25:47 +02:00
Isaac Marovitz a2df7f3fe9
Implement CreateProgram 2024-09-18 23:25:47 +02:00
Isaac Marovitz a0ebf80fd6
Fix fragment output color 2024-09-18 23:25:46 +02:00
Isaac Marovitz f83c75eb7e
Set TargetLanguage for Metal to MSL 2024-09-18 23:25:46 +02:00
Isaac Marovitz 983701dd7c
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-18 23:25:46 +02:00
Isaac Marovitz 97d69265fe
Fix ETC2 PTA formats
Format
2024-09-18 23:25:45 +02:00
Isaac Marovitz 7cd5d6aca9
Partial TextureQuerySamples 2024-09-18 23:25:45 +02:00
Isaac Marovitz e8e7e1b009
Fix instructions 2024-09-18 23:25:45 +02:00
Isaac Marovitz a19fbe3d5f
LDR ASTC 2024-09-18 23:25:44 +02:00
Isaac Marovitz 08d10c16c6
Get build working again (values likely wrong) 2024-09-18 23:25:44 +02:00
Isaac Marovitz d0f1278806
dotnet format 2024-09-18 23:25:44 +02:00
Isaac Marovitz 51b6a156df
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-18 23:25:43 +02:00
Isaac Marovitz d2cfbebc2f
Boot TOTK 2024-09-18 23:25:43 +02:00
Isaac Marovitz ee6081757d
Boot Sonic Mania 2024-09-18 23:25:42 +02:00
Isaac Marovitz fcf3094dfa
Update for new Shader IR format 2024-09-18 23:25:42 +02:00
Isaac Marovitz dbdc2d574c
Update src/Ryujinx.Graphics.Metal/Pipeline.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2024-09-18 23:25:42 +02:00
Isaac Marovitz f92c36c3dd
Vertex Input Attributes 2024-09-18 23:25:41 +02:00
Isaac Marovitz d251892077
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-18 23:25:41 +02:00
Isaac Marovitz ad79f611a9
Fix Metal Validation Error 2024-09-18 23:25:41 +02:00
Isaac Marovitz face61951f
SDL2 Headless Metal Backend support 2024-09-18 23:25:40 +02:00
Isaac Marovitz 9b23487b56
Easier capture stuff 2024-09-18 23:25:40 +02:00
Isaac Marovitz b39bf5ca94
Define MaxFramesPerCapture 2024-09-18 23:25:39 +02:00
Isaac Marovitz f80b83a3e6
Cleanup encoder getting + Fix capture overflow 2024-09-18 23:25:39 +02:00
Isaac Marovitz 222aded39b
Formatting 2024-09-18 23:25:39 +02:00
Isaac Marovitz da7f3e128f
Start of MSL instructions
Remaining functions
2024-09-18 23:25:38 +02:00
Isaac Marovitz 9bff5bcaf6
Warn when generating unsupported shader 2024-09-18 23:25:38 +02:00
Isaac Marovitz 288cc5bc04
Pass sampler to Blit shader 2024-09-18 23:25:37 +02:00
Isaac Marovitz 6b264ec9f7
Shader comments 2024-09-18 23:25:37 +02:00
Isaac Marovitz 30e43b58b5
HelperShaders class 2024-09-18 23:25:36 +02:00
Isaac Marovitz fd37d100f8
Undertale boots 2024-09-18 23:25:36 +02:00
Isaac Marovitz 1da7e7bc70
Check if packed depth is supported 2024-09-18 23:25:35 +02:00
Isaac Marovitz e8ebda10ef
Fix RGB Seizure 2024-09-18 23:25:35 +02:00
Isaac Marovitz b8ac60e00c
Barry is here mashallah 2024-09-18 23:25:35 +02:00
Isaac Marovitz c0bffaf547
Seizure my beloved is working 2024-09-18 23:25:34 +02:00
Isaac Marovitz acfb22e58c
SetData 2024-09-18 23:25:34 +02:00
Isaac Marovitz 52a48606b4
Look ma no crash 2024-09-18 23:25:34 +02:00
Isaac Marovitz 516be49f3a
Whitespace 2024-09-18 23:25:33 +02:00
Isaac Marovitz 73b1f9a316
TODO 2024-09-18 23:25:33 +02:00
Isaac Marovitz ce8c2aaf5c
BeginComputePass 2024-09-18 23:25:33 +02:00
Isaac Marovitz fda112a8ce
SetDepthTest 2024-09-18 23:25:32 +02:00
Isaac Marovitz d20878124d
SetStencilTest 2024-09-18 23:25:32 +02:00
Isaac Marovitz c376395b24
Forgot depth 2024-09-18 23:25:32 +02:00
Isaac Marovitz daff3c4598
Texture usage 2024-09-18 23:25:32 +02:00
Isaac Marovitz 44cdeacd12
CopyBuffer to Buffer 2024-09-18 23:25:31 +02:00
Isaac Marovitz 9a26724929
CopyTo Buffer 2024-09-18 23:25:31 +02:00
Isaac Marovitz 2ccd45936e
SetData without region 2024-09-18 23:25:30 +02:00
Isaac Marovitz 1b4cb49cdd
Rewrite SetData for GPU 2024-09-18 23:25:30 +02:00
Isaac Marovitz 960a1a8209
Clear Buffer 2024-09-18 23:25:30 +02:00
Isaac Marovitz 41d5d1849d
Use Ryujinx Logger 2024-09-18 23:25:29 +02:00
Isaac Marovitz a9d6228ec4
One encoder at a time 2024-09-18 23:25:29 +02:00
Isaac Marovitz 14981b477d
Fix byte alignment 2024-09-18 23:25:29 +02:00
Isaac Marovitz b943370602
Finish SetData /w region 2024-09-18 23:25:28 +02:00
Isaac Marovitz 50cc73a9b2
Spoof Counters 2024-09-18 23:25:28 +02:00
Isaac Marovitz 93054ce3dc
BufferAccess 2024-09-18 23:25:28 +02:00
Isaac Marovitz 964233d458
Delete and Get Data from Buffer 2024-09-18 23:25:28 +02:00
Isaac Marovitz db3c60f91f
Bump SharpMetal 2024-09-18 23:25:28 +02:00
Isaac Marovitz c97cac3e53
Start Texture region-based CopyTo 2024-09-18 23:25:27 +02:00
Isaac Marovitz 9b994b52e9
IoMap 2024-09-18 23:25:27 +02:00
Isaac Marovitz 190311d4b0
Fix error 2024-09-18 23:25:27 +02:00
Isaac Marovitz eaa04a206a
Renderer cleanup 2024-09-18 23:25:27 +02:00
Isaac Marovitz 2cea603124
Texture Copys 2024-09-18 23:25:27 +02:00
Isaac Marovitz a7101a778e
Texture, Pipeline, Sample, Renderer Improvements 2024-09-18 23:25:27 +02:00
Isaac Marovitz d70b5b29dd
Start Metal Backend
Revert build yml changes
2024-09-18 23:25:26 +02:00
16 changed files with 79 additions and 90 deletions

View File

@ -1,4 +1,4 @@
using System.Buffers;
using Ryujinx.Common.Memory;
namespace Ryujinx.Graphics.GAL
{
@ -18,30 +18,30 @@ namespace Ryujinx.Graphics.GAL
PinnedSpan<byte> GetData(int layer, int level);
/// <summary>
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
/// the operation completes.
/// </summary>
/// <param name="data">Texture data bytes</param>
void SetData(IMemoryOwner<byte> data);
void SetData(MemoryOwner<byte> data);
/// <summary>
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
/// the operation completes.
/// </summary>
/// <param name="data">Texture data bytes</param>
/// <param name="layer">Target layer</param>
/// <param name="level">Target level</param>
void SetData(IMemoryOwner<byte> data, int layer, int level);
void SetData(MemoryOwner<byte> data, int layer, int level);
/// <summary>
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
/// the operation completes.
/// </summary>
/// <param name="data">Texture data bytes</param>
/// <param name="layer">Target layer</param>
/// <param name="level">Target level</param>
/// <param name="region">Target sub-region of the texture to update</param>
void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region);
void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region);
void SetStorage(BufferRange buffer);

View File

@ -1,6 +1,6 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using Ryujinx.Graphics.GAL.Multithreading.Resources;
using System.Buffers;
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
@ -8,9 +8,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
public readonly CommandType CommandType => CommandType.TextureSetData;
private TableRef<ThreadedTexture> _texture;
private TableRef<IMemoryOwner<byte>> _data;
private TableRef<MemoryOwner<byte>> _data;
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data)
public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data)
{
_texture = texture;
_data = data;

View File

@ -1,6 +1,6 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using Ryujinx.Graphics.GAL.Multithreading.Resources;
using System.Buffers;
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
public readonly CommandType CommandType => CommandType.TextureSetDataSlice;
private TableRef<ThreadedTexture> _texture;
private TableRef<IMemoryOwner<byte>> _data;
private TableRef<MemoryOwner<byte>> _data;
private int _layer;
private int _level;
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level)
public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data, int layer, int level)
{
_texture = texture;
_data = data;

View File

@ -1,6 +1,6 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using Ryujinx.Graphics.GAL.Multithreading.Resources;
using System.Buffers;
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
@ -8,12 +8,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{
public readonly CommandType CommandType => CommandType.TextureSetDataSliceRegion;
private TableRef<ThreadedTexture> _texture;
private TableRef<IMemoryOwner<byte>> _data;
private TableRef<MemoryOwner<byte>> _data;
private int _layer;
private int _level;
private Rectangle<int> _region;
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level, Rectangle<int> region)
public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data, int layer, int level, Rectangle<int> region)
{
_texture = texture;
_data = data;

View File

@ -1,6 +1,6 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL.Multithreading.Commands.Texture;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using System.Buffers;
namespace Ryujinx.Graphics.GAL.Multithreading.Resources
{
@ -111,21 +111,21 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
_renderer.New<TextureSetDataCommand>().Set(Ref(this), Ref(data));
_renderer.QueueCommand();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
_renderer.New<TextureSetDataSliceCommand>().Set(Ref(this), Ref(data), layer, level);
_renderer.QueueCommand();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
_renderer.New<TextureSetDataSliceRegionCommand>().Set(Ref(this), Ref(data), layer, level, region);
_renderer.QueueCommand();

View File

@ -1,10 +1,10 @@
using Ryujinx.Common;
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Texture;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -353,7 +353,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
if (target != null)
{
IMemoryOwner<byte> data;
MemoryOwner<byte> data;
if (srcLinear)
{
data = LayoutConverter.ConvertLinearStridedToLinear(

View File

@ -7,7 +7,6 @@ using Ryujinx.Graphics.Texture.Astc;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -662,7 +661,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
IMemoryOwner<byte> result = ConvertToHostCompatibleFormat(data);
MemoryOwner<byte> result = ConvertToHostCompatibleFormat(data);
if (ScaleFactor != 1f && AllowScaledSetData())
{
@ -685,7 +684,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Uploads new texture data to the host GPU.
/// </summary>
/// <param name="data">New data</param>
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
BlacklistScale();
@ -704,7 +703,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="data">New data</param>
/// <param name="layer">Target layer</param>
/// <param name="level">Target level</param>
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
BlacklistScale();
@ -722,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="layer">Target layer</param>
/// <param name="level">Target level</param>
/// <param name="region">Target sub-region of the texture to update</param>
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
BlacklistScale();
@ -740,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="level">Mip level to convert</param>
/// <param name="single">True to convert a single slice</param>
/// <returns>Converted data</returns>
public IMemoryOwner<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false)
public MemoryOwner<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false)
{
int width = Info.Width;
int height = Info.Height;
@ -755,7 +754,7 @@ namespace Ryujinx.Graphics.Gpu.Image
int sliceDepth = single ? 1 : depth;
IMemoryOwner<byte> linear;
MemoryOwner<byte> linear;
if (Info.IsLinear)
{
@ -788,7 +787,7 @@ namespace Ryujinx.Graphics.Gpu.Image
data);
}
IMemoryOwner<byte> result = linear;
MemoryOwner<byte> result = linear;
// Handle compressed cases not supported by the host:
// - ASTC is usually not supported on desktop cards.
@ -832,19 +831,19 @@ namespace Ryujinx.Graphics.Gpu.Image
case Format.Etc2RgbaUnorm:
using (result)
{
return ETC2Decoder.DecodeRgba(result.Memory.Span, width, height, sliceDepth, levels, layers);
return ETC2Decoder.DecodeRgba(result.Span, width, height, sliceDepth, levels, layers);
}
case Format.Etc2RgbPtaSrgb:
case Format.Etc2RgbPtaUnorm:
using (result)
{
return ETC2Decoder.DecodePta(result.Memory.Span, width, height, sliceDepth, levels, layers);
return ETC2Decoder.DecodePta(result.Span, width, height, sliceDepth, levels, layers);
}
case Format.Etc2RgbSrgb:
case Format.Etc2RgbUnorm:
using (result)
{
return ETC2Decoder.DecodeRgb(result.Memory.Span, width, height, sliceDepth, levels, layers);
return ETC2Decoder.DecodeRgb(result.Span, width, height, sliceDepth, levels, layers);
}
}
}
@ -856,43 +855,43 @@ namespace Ryujinx.Graphics.Gpu.Image
case Format.Bc1RgbaUnorm:
using (result)
{
return BCnDecoder.DecodeBC1(result.Memory.Span, width, height, sliceDepth, levels, layers);
return BCnDecoder.DecodeBC1(result.Span, width, height, sliceDepth, levels, layers);
}
case Format.Bc2Srgb:
case Format.Bc2Unorm:
using (result)
{
return BCnDecoder.DecodeBC2(result.Memory.Span, width, height, sliceDepth, levels, layers);
return BCnDecoder.DecodeBC2(result.Span, width, height, sliceDepth, levels, layers);
}
case Format.Bc3Srgb:
case Format.Bc3Unorm:
using (result)
{
return BCnDecoder.DecodeBC3(result.Memory.Span, width, height, sliceDepth, levels, layers);
return BCnDecoder.DecodeBC3(result.Span, width, height, sliceDepth, levels, layers);
}
case Format.Bc4Snorm:
case Format.Bc4Unorm:
using (result)
{
return BCnDecoder.DecodeBC4(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm);
return BCnDecoder.DecodeBC4(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm);
}
case Format.Bc5Snorm:
case Format.Bc5Unorm:
using (result)
{
return BCnDecoder.DecodeBC5(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm);
return BCnDecoder.DecodeBC5(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm);
}
case Format.Bc6HSfloat:
case Format.Bc6HUfloat:
using (result)
{
return BCnDecoder.DecodeBC6(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat);
return BCnDecoder.DecodeBC6(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat);
}
case Format.Bc7Srgb:
case Format.Bc7Unorm:
using (result)
{
return BCnDecoder.DecodeBC7(result.Memory.Span, width, height, sliceDepth, levels, layers);
return BCnDecoder.DecodeBC7(result.Span, width, height, sliceDepth, levels, layers);
}
}
}
@ -900,7 +899,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
using (result)
{
var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Memory.Span, width);
var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Span, width);
if (_context.Capabilities.SupportsR4G4B4A4Format)
{
@ -910,7 +909,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
using (converted)
{
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(converted.Memory.Span, width);
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(converted.Span, width);
}
}
}
@ -921,7 +920,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
using (result)
{
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width);
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Span, width);
}
}
}
@ -933,24 +932,24 @@ namespace Ryujinx.Graphics.Gpu.Image
case Format.R5G6B5Unorm:
using (result)
{
return PixelConverter.ConvertR5G6B5ToR8G8B8A8(result.Memory.Span, width);
return PixelConverter.ConvertR5G6B5ToR8G8B8A8(result.Span, width);
}
case Format.B5G5R5A1Unorm:
case Format.R5G5B5X1Unorm:
case Format.R5G5B5A1Unorm:
using (result)
{
return PixelConverter.ConvertR5G5B5ToR8G8B8A8(result.Memory.Span, width, Format == Format.R5G5B5X1Unorm);
return PixelConverter.ConvertR5G5B5ToR8G8B8A8(result.Span, width, Format == Format.R5G5B5X1Unorm);
}
case Format.A1B5G5R5Unorm:
using (result)
{
return PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result.Memory.Span, width);
return PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result.Span, width);
}
case Format.R4G4B4A4Unorm:
using (result)
{
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width);
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Span, width);
}
}
}

View File

@ -1,3 +1,4 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Texture;
@ -5,7 +6,6 @@ using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@ -445,7 +445,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..];
IMemoryOwner<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
MemoryOwner<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
Storage.SetData(result, info.BaseLayer + layer, info.BaseLevel + level);
}

View File

@ -27,16 +27,6 @@ namespace Ryujinx.Graphics.Metal
_pipeline = pipeline;
}
public void SetFormats(int index, Format[] imageFormats)
{
for (int i = 0; i < imageFormats.Length; i++)
{
_textureRefs[index + i].ImageFormat = imageFormats[i];
}
SetDirty();
}
public void SetImages(int index, ITexture[] images)
{
for (int i = 0; i < images.Length; i++)

View File

@ -661,7 +661,7 @@ namespace Ryujinx.Graphics.Metal
_encoderStateManager.UpdateIndexBuffer(buffer, type);
}
public void SetImage(ShaderStage stage, int binding, ITexture image, Format imageFormat)
public void SetImage(ShaderStage stage, int binding, ITexture image)
{
if (image is TextureBase img)
{

View File

@ -1,7 +1,7 @@
using OpenTK.Graphics.OpenGL;
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using System;
using System.Buffers;
namespace Ryujinx.Graphics.OpenGL.Image
{
@ -55,9 +55,9 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
var dataSpan = data.Memory.Span;
var dataSpan = data.Span;
Buffer.SetData(_buffer, _bufferOffset, dataSpan[..Math.Min(dataSpan.Length, _bufferSize)]);
@ -65,13 +65,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
throw new NotSupportedException();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
throw new NotSupportedException();
}

View File

@ -1,8 +1,8 @@
using OpenTK.Graphics.OpenGL;
using Ryujinx.Common;
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using System;
using System.Buffers;
using System.Diagnostics;
namespace Ryujinx.Graphics.OpenGL.Image
@ -448,13 +448,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
}
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
using (data = EnsureDataFormat(data))
{
unsafe
{
var dataSpan = data.Memory.Span;
var dataSpan = data.Span;
fixed (byte* ptr = dataSpan)
{
ReadFrom((IntPtr)ptr, dataSpan.Length);
@ -463,13 +463,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
}
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
using (data = EnsureDataFormat(data))
{
unsafe
{
fixed (byte* ptr = data.Memory.Span)
fixed (byte* ptr = data.Span)
{
int width = Math.Max(Info.Width >> level, 1);
int height = Math.Max(Info.Height >> level, 1);
@ -480,7 +480,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
}
}
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
using (data = EnsureDataFormat(data))
{
@ -489,7 +489,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
unsafe
{
fixed (byte* ptr = data.Memory.Span)
fixed (byte* ptr = data.Span)
{
ReadFrom2D(
(IntPtr)ptr,
@ -522,13 +522,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
ReadFrom2D(data, layer, level, x, y, width, height, mipSize);
}
private IMemoryOwner<byte> EnsureDataFormat(IMemoryOwner<byte> data)
private MemoryOwner<byte> EnsureDataFormat(MemoryOwner<byte> data)
{
if (Format == Format.S8UintD24Unorm)
{
using (data)
{
return FormatConverter.ConvertS8D24ToD24S8(data.Memory.Span);
return FormatConverter.ConvertS8D24ToD24S8(data.Span);
}
}

View File

@ -1,7 +1,7 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
using System;
using System.Buffers;
using System.Collections.Generic;
using Format = Ryujinx.Graphics.GAL.Format;
using VkFormat = Silk.NET.Vulkan.Format;
@ -84,20 +84,20 @@ namespace Ryujinx.Graphics.Vulkan
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
_gd.SetBufferData(_bufferHandle, _offset, data.Memory.Span);
_gd.SetBufferData(_bufferHandle, _offset, data.Span);
data.Dispose();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
throw new NotSupportedException();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
throw new NotSupportedException();
}

View File

@ -1,7 +1,7 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -746,23 +746,23 @@ namespace Ryujinx.Graphics.Vulkan
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data)
public void SetData(MemoryOwner<byte> data)
{
SetData(data.Memory.Span, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false);
SetData(data.Span, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false);
data.Dispose();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level)
public void SetData(MemoryOwner<byte> data, int layer, int level)
{
SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true);
SetData(data.Span, layer, level, 1, 1, singleSlice: true);
data.Dispose();
}
/// <inheritdoc/>
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
{
SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true, region);
SetData(data.Span, layer, level, 1, 1, singleSlice: true, region);
data.Dispose();
}

View File

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{
private readonly MemoryOwner<byte> _rawDataOwner;
private Span<byte> Raw => _rawDataOwner.Memory.Span;
private Span<byte> Raw => _rawDataOwner.Span;
private ref ParcelHeader Header => ref MemoryMarshal.Cast<byte, ParcelHeader>(Raw)[0];

View File

@ -1,5 +1,5 @@
using Ryujinx.Common.Memory;
using System;
using System.Buffers;
namespace Ryujinx.Memory
{
@ -7,7 +7,7 @@ namespace Ryujinx.Memory
{
private readonly IWritableBlock _block;
private readonly ulong _va;
private readonly IMemoryOwner<byte> _memoryOwner;
private readonly MemoryOwner<byte> _memoryOwner;
private readonly bool _tracked;
private bool NeedsWriteback => _block != null;
@ -22,7 +22,7 @@ namespace Ryujinx.Memory
Memory = memory;
}
public WritableRegion(IWritableBlock block, ulong va, IMemoryOwner<byte> memoryOwner, bool tracked = false)
public WritableRegion(IWritableBlock block, ulong va, MemoryOwner<byte> memoryOwner, bool tracked = false)
: this(block, va, memoryOwner.Memory, tracked)
{
_memoryOwner = memoryOwner;