Compare commits

..

368 Commits

Author SHA1 Message Date
Isaac Marovitz 9c22f58bf3
Merge c1fa24ee78 into ef81658fbd 2024-09-18 21:04:58 +02:00
Isaac Marovitz c1fa24ee78 Check for null resources before declaring them resident 2024-09-15 08:42:19 -04:00
Isaac Marovitz 80e8e1999b Fix null sampler crash 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1ff9c1098b Fix counted indirect draws
Fixes Monster Hunter Rise and Apollo Justice
2024-09-15 08:42:19 -04:00
Isaac Marovitz 4451c33287 Program hash set 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2c3e7f5b43 Auto-backed samplers 2024-09-15 08:42:19 -04:00
Isaac Marovitz cfb66bc723 Refactor binding logic + Bind image arrays 2024-09-15 08:42:19 -04:00
Isaac Marovitz cc43956d67 Fix primitive id in shader gen
Fixes Dark Souls
2024-09-15 08:42:19 -04:00
Isaac Marovitz 61cfd8e72f Fix cubemap array length
Fixes crash in Sonic Frontiers
2024-09-15 08:42:19 -04:00
Isaac Marovitz 117f1d1a0c Properly create stencil views of combined formats
Fixes Link’s Awakening
2024-09-15 08:42:19 -04:00
Isaac Marovitz ca3aaf70de Add missing set texture for depth stencil blit
Mostly fixes Sonic Frontiers & Link’s Awakening
2024-09-15 08:42:19 -04:00
Isaac Marovitz 2f953bbff1 Fix typo in stride change shader
Fixes Castlevania Dominus Collection
2024-09-15 08:42:19 -04:00
Isaac Marovitz 9c4258176d Fix invalid depth stencil state when no depth stencil is present
Partially fixes Sonic Frontiers and Castlevania Dominus Collection
2024-09-15 08:42:19 -04:00
Isaac Marovitz 152227c297 Style 2024-09-15 08:42:19 -04:00
Isaac Marovitz 3e215bc1bd Metal: Unsupported topology indexed draw conversion (#40)
* Convert unsupported indexed buffer topologies

* Fix index count and dispatch size

* Cleanup

* Fix typos
2024-09-15 08:42:19 -04:00
Isaac Marovitz 30469e8e37 Fix null resources breaking arg buffer alignment 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7f6aa40683 Remove RenderPipelineDescriptorResult 2024-09-15 08:42:19 -04:00
Isaac Marovitz f68d7b8c8c D32FS8 to D24S8 Conversion 2024-09-15 08:42:19 -04:00
Isaac Marovitz e432fa8429 Upstream changes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1eb4dfff31 Logic Operations 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9318652ca2 Fix array size query 2024-09-15 08:42:19 -04:00
Isaac Marovitz 551b293951 Debug Groups 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8170f918e9 IaIndexing
Fixes shader problems in Donkey Kong Country Tropical Freeze, and Fire Emblem: Three Houses
2024-09-15 08:42:19 -04:00
Isaac Marovitz 324befedac Rasterizer Discard + Multisample State 2024-09-15 08:42:19 -04:00
Isaac Marovitz 01136a4c7f Metal: Argument Buffer Pre-Pass (#38)
* Init

* Fix missing flags

* Cleanup
2024-09-15 08:42:19 -04:00
riperiperi b9da21ac3e Patch some leaks and only perform copies on valid textures (#37) 2024-09-15 08:42:19 -04:00
Isaac Marovitz 968f8b6919 Get render command encoder after finalising buffers
Fixes crash in Fire Emblem: Houses
2024-09-15 08:42:19 -04:00
Isaac Marovitz c4ffee17b6 Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8813cf195d Fix non atomic image loads again 2024-09-15 08:42:19 -04:00
Isaac Marovitz d309598867 Finally fix (most) image atomics 2024-09-15 08:42:19 -04:00
Isaac Marovitz d4a690f680 Precise Float Fixes
Fixes artifacts in TOTK
2024-09-15 08:42:19 -04:00
Isaac Marovitz 0d9162cca7 Fix image atomics 2024-09-15 08:42:19 -04:00
Isaac Marovitz a63a60f365 Fix Non-Float Textures + Image Read + FSI Buffers
Fixes Mario Party Superstars
2024-09-15 08:42:19 -04:00
Isaac Marovitz 97b03a5397 Image Constant Fixes
Allows Mario Party Superstars to boot
2024-09-15 08:42:19 -04:00
Isaac Marovitz 110f289b32 Helper Shader fixes for non float formats 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2b25aee6d4 Shader Extra Set Support + Cleanup (#36)
Separate samplers are now supported and arrays in constant sets are bound
2024-09-15 08:42:19 -04:00
Isaac Marovitz fd88f859e3 InstGenMemory Refactor + Bindless Support 2024-09-15 08:42:19 -04:00
Isaac Marovitz f0abbd90a9 TextureArray & ImageArray Creation + State 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1864f4e795 Fix hex number type ambiguity
Fixes cutscenes in Super Mario Sunshine
2024-09-15 08:42:19 -04:00
Isaac Marovitz 5233b40623 Use RGBA8Unorm for R4G4B4A4Unorm
Gets SM64 to boot
2024-09-15 08:42:19 -04:00
Isaac Marovitz 297f8b3dea Dual Source Blend Support in Shader
Fixes Super Mario Galaxy and The Legend of Zelda: Skyward Sword HD
2024-09-15 08:42:19 -04:00
Isaac Marovitz 58bed976b5 Get Tomb Raider working 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4ad89b34c6 Remove DummyBufferTextures
Mostly gets VTG on Compute working again
2024-09-15 08:42:19 -04:00
Isaac Marovitz 4d3c368a13 Properly register TextureBuffer usage + Store Auto ref 2024-09-15 08:42:19 -04:00
Isaac Marovitz 498b12a5f0 Partial indirect draw support 2024-09-15 08:42:19 -04:00
Gabriel A 597f9ca888 Fixes 2024-09-15 08:42:19 -04:00
Gabriel A 2ca850bea3 Start building more accurate vertex as compute usage info 2024-09-15 08:42:19 -04:00
Isaac Marovitz 32703aba5e Bind TextureBuffers 2024-09-15 08:42:19 -04:00
Isaac Marovitz 00a6f5871a Remove ClearSegments for now
Currently unimplemented and issues are arising with building BindingSegments in general.
2024-09-15 08:42:19 -04:00
Isaac Marovitz f77124ed95 Fix compute generation failure in NieR 2024-09-15 08:42:19 -04:00
Isaac Marovitz 18bbf4f1e8 Some debug improvements 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8476c00b23 Stop complaining about clip distance 2024-09-15 08:42:19 -04:00
Isaac Marovitz f2ab1e7102 Shader Gen Fixes
Fixes Luigi’s Mansion 2 HD
2024-09-15 08:42:19 -04:00
Isaac Marovitz 9d096d6c37 DepthStencil Blits 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9a8ee29152 Multisample Blits
Partially fixes Sonic Colors Ultimate
2024-09-15 08:42:19 -04:00
Isaac Marovitz a898548baa Fix image bindings 2024-09-15 08:42:19 -04:00
Isaac Marovitz 14054a318b FSI (with raster order groups) 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4e7b4bf5a3 SwizzleAdd (NOT TESTED) 2024-09-15 08:42:19 -04:00
Isaac Marovitz 50306f1b87 Consolodate barriers 2024-09-15 08:42:19 -04:00
Isaac Marovitz a559e7afae Shader Memory Barriers
Fixes some of the shader generation failures in Sonic Frontiers
2024-09-15 08:42:19 -04:00
Isaac Marovitz 37087a6f63 Image binding support
Kirby still has a problem with NaN 3D Texture
2024-09-15 08:42:19 -04:00
Isaac Marovitz 698b64bd60 Image shader gen support 2024-09-15 08:42:19 -04:00
Isaac Marovitz b31d46dd71 Shader cache support 2024-09-15 08:42:19 -04:00
Isaac Marovitz 3469ec036f Make dotnet format happy 2024-09-15 08:42:19 -04:00
Isaac Marovitz e76044cf75 GAL ResourceUsage Changes
TODO: Guest Barrier Defer
2024-09-15 08:42:19 -04:00
Isaac Marovitz 9bca68784c Better vertex buffer management 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1f07787ac2 Fix LOD 2024-09-15 08:42:19 -04:00
Isaac Marovitz 101c5b9fb5 Better index buffer management 2024-09-15 08:42:19 -04:00
Isaac Marovitz f4ac7d4087 Formatting cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz 57083dc8c1 Formatting 2024-09-15 08:42:19 -04:00
Isaac Marovitz 45100454a0 Update binding model description comment 2024-09-15 08:42:19 -04:00
riperiperi 8eacb14de5 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-15 08:42:19 -04:00
Isaac Marovitz 11f9b26254 Fix invariant position not doing its job 2024-09-15 08:42:19 -04:00
riperiperi fc870fca28 implement compressed/uncompressed copy, fix other copies, fix int/uint output shaders (#33) 2024-09-15 08:42:19 -04:00
Isaac Marovitz b24ecf03f2 Fix blend state optimisation breaking attachments
Fixes SM3DW
2024-09-15 08:42:19 -04:00
riperiperi 83f72741db Fix warnings 2024-09-15 08:42:19 -04:00
riperiperi 4b47d7b5bc Maintain identity swizzle view of textures for rendering 2024-09-15 08:42:19 -04:00
riperiperi 75b0ddf85b 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-15 08:42:19 -04:00
Isaac Marovitz 50284713eb Cleanup + Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4363fa0ced Fix trying to reserve size 0 in staging buffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz dbda96f26c Fix zero buff not being reset 2024-09-15 08:42:19 -04:00
Isaac Marovitz e17e6ec994 Dirty Arg Buffers on Program Change 2024-09-15 08:42:19 -04:00
Isaac Marovitz a47d9fd1d2 Least allocations in the west 2024-09-15 08:42:19 -04:00
Isaac Marovitz 3646e18076 Don’t use Enum.HasFlag 2024-09-15 08:42:19 -04:00
Isaac Marovitz fd2e64c0c7 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-15 08:42:19 -04:00
Isaac Marovitz 25a4c375ad Update comment for Metal 2024-09-15 08:42:19 -04:00
Isaac Marovitz 82eec9a147 Don’t do inline vertex buffer updates
Somehow broke zero buff MTLVertexDescriptor, but fixes broken geoemtry so I’m pushing anyway
2024-09-15 08:42:19 -04:00
riperiperi 411874ae4b 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-15 08:42:19 -04:00
riperiperi fb5255fc17 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-15 08:42:19 -04:00
Isaac Marovitz d4b1e95359 Dont bind images in texture slots 2024-09-15 08:42:19 -04:00
Isaac Marovitz afc130fb88 Stop depth/stencil blits from crashing everything 2024-09-15 08:42:19 -04:00
riperiperi 40002a4a48 Fix Geometry/TFB on compute, Buffer Textures, add Window Resizing (#28) 2024-09-15 08:42:19 -04:00
riperiperi 3c25b87e1d 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-15 08:42:19 -04:00
Isaac Marovitz bc3ec9ded8 Fragment input interpolation qualifiers
Fixes Mario’s shadow in SMO
2024-09-15 08:42:19 -04:00
Isaac Marovitz 534038d31f CommandBufferBarrier 2024-09-15 08:42:19 -04:00
riperiperi 8dad2953a4 Add constrained border colours to samplers (#26) 2024-09-15 08:42:19 -04:00
Isaac Marovitz 43b27faf9d Don’t bind byte format converted index buffers at requested index 2024-09-15 08:42:19 -04:00
Isaac Marovitz 963bbf7267 Render target deduplication
not sure if this is working
2024-09-15 08:42:19 -04:00
Isaac Marovitz 925897e163 Fix CBP not doing its job
Thanks peri (again)
2024-09-15 08:42:19 -04:00
Isaac Marovitz 70a05909ed Fix blend descriptors not dirting render pipeline
Thanks peri
2024-09-15 08:42:19 -04:00
Isaac Marovitz 3b95361d75 Support non-index quad draws
Fixes Deltarune
2024-09-15 08:42:19 -04:00
Isaac Marovitz 5ea6442886 Be better about memory 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4ec7062727 Fix stencil clears 2024-09-15 08:42:19 -04:00
Isaac Marovitz e269be41aa Enable Alpha Test workaround on Metal 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2cb46a953b Fix Cull FrontAndBack 2024-09-15 08:42:19 -04:00
Isaac Marovitz f5db6ba50a Warning about host map buffer creation 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9b4a5ef939 Fix fragment point_coord in 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5566979d5e 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-15 08:42:19 -04:00
Isaac Marovitz 3ad15aa114 VoteAllEqual, FindLSB/MSB 2024-09-15 08:42:19 -04:00
Isaac Marovitz 664d1efa18 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-15 08:42:19 -04:00
Isaac Marovitz 2dd5e272d7 Actually clear the right render target 2024-09-15 08:42:19 -04:00
Isaac Marovitz b2fdb4cfdd Big GetData()
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2024-09-15 08:42:19 -04:00
Isaac Marovitz c92b74e376 Fix Animal Crossing Crash 2024-09-15 08:42:19 -04:00
Isaac Marovitz 386f9b00a9 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-15 08:42:19 -04:00
Isaac Marovitz 533c4c021d PreloadCbs + FlushCommandsIfWeightExceeding 2024-09-15 08:42:19 -04:00
Isaac Marovitz a4a8e317ec Cleanup Pipeline
Housekeeping

More housekeeping
2024-09-15 08:42:19 -04:00
Isaac Marovitz ad790e6bde PersistentFlushBuffer + BackgroundResources 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7c4ed084a3 Match S8UintD24Unorm to Depth24UnormStencil8
Kind of works for es2gears
2024-09-15 08:42:19 -04:00
Isaac Marovitz 144a19d686 Fix FEZ not showing anything
Does not fix the underlying shortcomings of the cache system
2024-09-15 08:42:19 -04:00
Isaac Marovitz c4ecbe02b9 Clear cached converted buffers on signaled write 2024-09-15 08:42:19 -04:00
Isaac Marovitz dd619f9f0b FIx regression 2024-09-15 08:42:19 -04:00
Isaac Marovitz 477af39703 Helper shader cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz a74532b7c4 Use buffer manager for color blit 2024-09-15 08:42:19 -04:00
Isaac Marovitz 703c8c3139 Buffer Conversions (#23)
* Why is this not working

* Revert helper shader changes for now

* Byte Index Buffer Restride
2024-09-15 08:42:19 -04:00
riperiperi 0853353ad8 don't recreate render pipeline unless we're about to draw, pass view depth properly (#22) 2024-09-15 08:42:19 -04:00
Isaac Marovitz dd203b84eb 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-15 08:42:19 -04:00
Isaac Marovitz 802d4f043c Log failed format conversions 2024-09-15 08:42:19 -04:00
Isaac Marovitz 607eadda79 Print shader code involved in failed linking 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7ef43a6d3f Don’t use DidModifyRange 2024-09-15 08:42:19 -04:00
Isaac Marovitz 330440b569 Fix sample compare 2024-09-15 08:42:19 -04:00
Isaac Marovitz 395a6cc218 Depth Bias 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7d35adc73a Map R5G5B5A1Unorm 2024-09-15 08:42:19 -04:00
Samuliak b6786558fb override Equals for render pipeline hash 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5182a03697 Disable scaled vertex formats 2024-09-15 08:42:19 -04:00
Isaac Marovitz dac9d3146c Disable Vector Indexing Bug Workaround 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6509fc8a24 Fix modulo operator
Support sample offsets

Include FragmentIn as additional arg

Always declare frag output struct

SubgroupLaneId
2024-09-15 08:42:19 -04:00
Isaac Marovitz 4fd048bfd7 Workaround for Wonder 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6184eefaa3 Fix 3D -> 3D Texture Copies 2024-09-15 08:42:19 -04:00
Isaac Marovitz cc25ebd744 Fix Clear Viewport 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7e693d5baa Fix sample-less reads with lod 2024-09-15 08:42:19 -04:00
Isaac Marovitz ac1a133c80 Fix Pack and UnpackHalf2x16 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5c44c3c359 Handle Array Format SetData 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2c2aa0472a Cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz d6309a6242 Implement IoVariable.FrontFacing 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4480197b70 Fix LOD sample typo 2024-09-15 08:42:19 -04:00
Isaac Marovitz 105638de6d Rebase Changes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 01536c833d More cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz eabc2fb781 Cleanup + Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz f92233fcb3 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-15 08:42:19 -04:00
Isaac Marovitz 4fa4c78aa4 Handle stride 0 on regular buffers 2024-09-15 08:42:19 -04:00
Isaac Marovitz 07230581ce Buffer Descriptor Step Functions 2024-09-15 08:42:19 -04:00
Isaac Marovitz d15716d4e2 Sample LOD Level 2024-09-15 08:42:19 -04:00
Isaac Marovitz c3378cd933 Fix FragmentOutputColor Type 2024-09-15 08:42:19 -04:00
Isaac Marovitz 00cf9f5281 Stencil Ref Value 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7d78545385 Stencil Fixes 2024-09-15 08:42:19 -04:00
Isaac Marovitz ec7168cffe RenderTargetColorMasks 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1edefacd30 Make dotnet format happy 2024-09-15 08:42:19 -04:00
SamoZ256 224c714150 Zero vertex buffer (#17)
* cast src size to float

* implement zero buffers
2024-09-15 08:42:19 -04:00
Isaac Marovitz 1e3b0787d8 Implement Texture CopyTo 2024-09-15 08:42:19 -04:00
Isaac Marovitz 3ccd086b26 Cleanup present 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7f12a233f1 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-15 08:42:19 -04:00
SamoZ256 63bd08f12d 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-15 08:42:19 -04:00
SamoZ256 1d19cc7d51 Fix Scott Pilgrim (#15)
* check for null vertex functions

* format

* Format

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-09-15 08:42:19 -04:00
Isaac Marovitz 5a055a0650 Suppress GC Finalize on StateCache 2024-09-15 08:42:19 -04:00
Isaac Marovitz 25076a2669 Use Stack instead of List 2024-09-15 08:42:19 -04:00
Isaac Marovitz afcb74fcf8 Whitespace formatting 2024-09-15 08:42:19 -04:00
Samuliak 26876b8ec6 dispose all temporary buffers 2024-09-15 08:42:19 -04:00
Samuliak 91fdd90fb8 dispose temporary metal buffer 2024-09-15 08:42:19 -04:00
Samuliak 7d79075846 dispose drawable texture view 2024-09-15 08:42:19 -04:00
Samuliak 5ca5a3f2d8 implement texture get data 2024-09-15 08:42:19 -04:00
Samuliak cce450c8c5 fix: don't dispose stencil state before using 2024-09-15 08:42:19 -04:00
Samuliak 1965ac74a8 allow null depth stencil render targets 2024-09-15 08:42:19 -04:00
Samuliak f8a81aac84 reset certain state before doing blit or clear 2024-09-15 08:42:19 -04:00
Samuliak 8a5748aa28 reset viewport before blit 2024-09-15 08:42:19 -04:00
Samuliak c2ab9f4b43 dispose encoder state manager 2024-09-15 08:42:19 -04:00
Samuliak ad1fe10533 dispose all objects in encoder state manager 2024-09-15 08:42:19 -04:00
Samuliak dd61bb4a84 dispose caches 2024-09-15 08:42:19 -04:00
Samuliak c44586c47d warn about barriers 2024-09-15 08:42:19 -04:00
Samuliak 65994f1a98 do memory barriers 2024-09-15 08:42:19 -04:00
Samuliak 949313b98a remove useless parameters 2024-09-15 08:42:19 -04:00
Samuliak 6ba438bb17 set the inline state after restoring state 2024-09-15 08:42:19 -04:00
Samuliak 9d96b01a0e make states private 2024-09-15 08:42:19 -04:00
Samuliak b24852c835 fix: incorrect merge stuff 2024-09-15 08:42:19 -04:00
Samuliak 30e150534b don't interrupt render pass before color clear 2024-09-15 08:42:19 -04:00
Samuliak 0dcd0b0655 implement save and restore state system 2024-09-15 08:42:19 -04:00
Samuliak 666e258a7e revert deferred clears 2024-09-15 08:42:19 -04:00
Samuliak f1dfba2958 prepare for deferred clears 2024-09-15 08:42:19 -04:00
Samuliak af4238280c resolve merge conflicts 2024-09-15 08:42:19 -04:00
Isaac Marovitz 839c3159fc Rebase 2024-09-15 08:42:19 -04:00
Isaac Marovitz d1493f2b24 Cleanup + Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8cc955180f Start Proper Dispose 2024-09-15 08:42:19 -04:00
Samuliak 0a698d575b do texture barrier tiled 2024-09-15 08:42:19 -04:00
Samuliak 490efa8cff do texture barrier 2024-09-15 08:42:19 -04:00
Samuliak 8a91e0bfe6 implement depth stencil cache 2024-09-15 08:42:19 -04:00
Isaac Marovitz 93f817ef1d Fix typo in SamplerType.TextureBuffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz 49e1058ab4 Fix StoreActions & Don’t Clamp Scissor for Now 2024-09-15 08:42:19 -04:00
Isaac Marovitz 0bb24a052d Depth Clear 2024-09-15 08:42:19 -04:00
Isaac Marovitz 72b9559e86 Shitty Clears + Inline Buffer Improvements? 2024-09-15 08:42:19 -04:00
Isaac Marovitz 0dfb755a01 FragmentOutputDepth Fixes 2024-09-15 08:42:19 -04:00
Isaac Marovitz bdb57934ef Depth Sampler Fixes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8c001adce6 Revert position changes 2024-09-15 08:42:19 -04:00
Isaac Marovitz a463a32671 Nvm it should be in.position 2024-09-15 08:42:19 -04:00
Isaac Marovitz d54df5783e More shader fixes 2024-09-15 08:42:19 -04:00
Samuliak dde3ce117c fix: incorrect layer count of texture view 2024-09-15 08:42:19 -04:00
Samuliak bd1f215149 don't use mask on size query 2024-09-15 08:42:19 -04:00
Samuliak 9e14a8f2fa declare local memory 2024-09-15 08:42:19 -04:00
Samuliak 5e3706a8da support multiple render targets & fix: incorrect texture name 2024-09-15 08:42:19 -04:00
Samuliak d86237f49c put render pipeline cache into a separate file 2024-09-15 08:42:19 -04:00
Samuliak a6b20f4129 implement pipeline cache 2024-09-15 08:42:19 -04:00
Isaac Marovitz 13aa76f66c Use return value of BeginRenderPass 2024-09-15 08:42:19 -04:00
Isaac Marovitz 305a092dcc Cleanup 2024-09-15 08:42:19 -04:00
Samuliak 6366ca0e60 remove outdated comment 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2ed2ff5b81 Fix table 2024-09-15 08:42:19 -04:00
Isaac Marovitz 931f23b25a Dont hardcode Vertex Format 2024-09-15 08:42:19 -04:00
Samuliak 28c5bf843e style 2024-09-15 08:42:19 -04:00
Samuliak 658b1aa84f bring back inline updates for some state 2024-09-15 08:42:19 -04:00
Samuliak 2a53211217 fix: don't rebind pipeline unless dirty 2024-09-15 08:42:19 -04:00
Samuliak d5f2b7d28b don't bind null vertex buffers 2024-09-15 08:42:19 -04:00
Samuliak 6af4581e42 mark state as dirty 2024-09-15 08:42:19 -04:00
Samuliak 5526c8129f add todo notice 2024-09-15 08:42:19 -04:00
Samuliak c1a6b9831c don't end render pass when not neccessary 2024-09-15 08:42:19 -04:00
Isaac Marovitz d4628ce4c0 Remove rebase garbage 2024-09-15 08:42:19 -04:00
Isaac Marovitz a4c395b0ad Be smart and use a bitmask not a list 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1b67ee0133 Cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9696fd3eba Fix Vertex Attributes in Wonder & Kirby 2024-09-15 08:42:19 -04:00
Isaac Marovitz ecb8bffe03 Implement SetDepthClamp 2024-09-15 08:42:19 -04:00
Isaac Marovitz 91eea95437 Implement SetBlendState 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2a2003837b Be consistent with things that lack support 2024-09-15 08:42:19 -04:00
Isaac Marovitz dd6135463a Ignore SetDepthMode 2024-09-15 08:42:19 -04:00
Isaac Marovitz c061e7391a Make Texture Volatile on dispose 2024-09-15 08:42:19 -04:00
Isaac Marovitz 450b8ad382 Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 702a99f4c4 Fix present 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9a8761ddb9 Fix Depth/Stencil attachments 2024-09-15 08:42:19 -04:00
Isaac Marovitz dd22b0c0bd Break everything :D 2024-09-15 08:42:19 -04:00
Isaac Marovitz 00c2c98c50 Clamp ScissorRect 2024-09-15 08:42:19 -04:00
Isaac Marovitz f40bdc1f18 Set DepthAttachmentPixelFormat 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6a2db0b198 Set Depth Attachment Texture 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8526444dc6 Clamp Viewport ZNear & ZFar 2024-09-15 08:42:19 -04:00
Samuliak b633337af1 format 2024-09-15 08:42:19 -04:00
Samuliak ef7741cec1 use 0 instead of undef 2024-09-15 08:42:19 -04:00
Samuliak a96f63b8b5 fix: pass array index as an additional argument to sample 2024-09-15 08:42:19 -04:00
Samuliak 87764fcc26 don't declare samplers for separate textures 2024-09-15 08:42:19 -04:00
Samuliak 811be972b7 don't hardcode texture type 2024-09-15 08:42:19 -04:00
Samuliak 99600bbd6f offset storage buffer bindings by 15 2024-09-15 08:42:19 -04:00
Samuliak 0dace0c4f7 fix: incorrect abs instruction 2024-09-15 08:42:19 -04:00
Samuliak 7bfe99f951 add: vertex and instance id arguments 2024-09-15 08:42:19 -04:00
Samuliak 0bce31d898 determine type of buffer by its field types 2024-09-15 08:42:19 -04:00
Isaac Marovitz 70a8c72742 Rebase + Format 2024-09-15 08:42:19 -04:00
Samuliak 467aa5fc3e use unknown texture usage 2024-09-15 08:42:19 -04:00
Samuliak f6e9a88ce7 don't hardcode render pipeline attachments 2024-09-15 08:42:19 -04:00
Samuliak 9be9d2ada0 create GetSwizzle helper function 2024-09-15 08:42:19 -04:00
Samuliak 7bfe9564a6 add: textures and samplers as shader arguments & fix: issue with casting 2024-09-15 08:42:19 -04:00
Samuliak 903a330767 support fragment coord as an input to a shader 2024-09-15 08:42:19 -04:00
Samuliak f97fb23764 support texture views 2024-09-15 08:42:19 -04:00
Isaac Marovitz 266c550e94 Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5a17653e1b Rebase + GAL Changes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 09f88ec0eb Remove TODOs 2024-09-15 08:42:19 -04:00
Isaac Marovitz 657e344c08 Fix Scissor/Viewport state & Validation Error 2024-09-15 08:42:19 -04:00
Isaac Marovitz e3819a02bb Require Argument Buffers Tier 2 2024-09-15 08:42:19 -04:00
Isaac Marovitz af00bc0fb5 Buffer bindings in shader…
Will need to be reworked
2024-09-15 08:42:19 -04:00
Isaac Marovitz 49724e4344 Bind Uniform & Storage Buffers 2024-09-15 08:42:19 -04:00
Isaac Marovitz 23768f4fd1 Fix buffer access syntax 2024-09-15 08:42:19 -04:00
Isaac Marovitz f9b601d038 Dispose pipeline before window 2024-09-15 08:42:19 -04:00
Isaac Marovitz 188728bc1e Set scissors & viewports 2024-09-15 08:42:19 -04:00
Isaac Marovitz fd50a0a204 Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8b68f69c85 Format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 03dce2a4b4 Fix some crashes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5f677465e0 Fix Cubemap & Array Texture Creation 2024-09-15 08:42:19 -04:00
Isaac Marovitz 504dbec78e Properly check for 3D 2024-09-15 08:42:19 -04:00
Isaac Marovitz 46409ec557 Fix swizzle for certain formats 2024-09-15 08:42:19 -04:00
Isaac Marovitz b96e2e72f2 Blit at the end of the render 2024-09-15 08:42:19 -04:00
Isaac Marovitz 664eda5a0e Load attachments 2024-09-15 08:42:19 -04:00
Isaac Marovitz c34c0b0855 Cleanup Shader I/O 2024-09-15 08:42:19 -04:00
Isaac Marovitz 91db4d8637 Fix fragment shader bindings 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4238c7d15e Fix VertexBuffers
Naive non-managed approach
2024-09-15 08:42:19 -04:00
Isaac Marovitz 26f038c52b Fix some shader gen problems… 2024-09-15 08:42:19 -04:00
Isaac Marovitz f0e2a5eca3 Formatting 2024-09-15 08:42:19 -04:00
Isaac Marovitz d860fcb392 Make TypeConversion failure an error 2024-09-15 08:42:19 -04:00
Isaac Marovitz cae51cfe8d Fix MSL Reinterpret Casts 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6e8e454270 Dont set Vertex Attributes for now 2024-09-15 08:42:19 -04:00
Isaac Marovitz 564fbf51df Remove capture code 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7c63870e62 Bind Textures & Samplers 2024-09-15 08:42:19 -04:00
Isaac Marovitz c54a8118bd Revise ISampler 2024-09-15 08:42:19 -04:00
Isaac Marovitz c63a740263 Try again 2024-09-15 08:42:19 -04:00
Isaac Marovitz d21036ec5d Resolve warning 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2520696ddc Formatting 2024-09-15 08:42:19 -04:00
Isaac Marovitz d67c293c57 FIx build 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2d60ab38af Fix some rebase errors 2024-09-15 08:42:19 -04:00
Isaac Marovitz f370c90bc1 End Pass on Dispose 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1a66dbd8ee Don’t change Render State if Vertex Function is Invalid 2024-09-15 08:42:19 -04:00
Isaac Marovitz c088883e44 “Report” Driver 2024-09-15 08:42:19 -04:00
Isaac Marovitz 937244b289 Adjust function signature 2024-09-15 08:42:19 -04:00
Isaac Marovitz b0bca99454 Get it building again 2024-09-15 08:42:19 -04:00
Isaac Marovitz 36314f504b Render Targets 2024-09-15 08:42:19 -04:00
Isaac Marovitz cf706e080b format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 450944b40a Formatting 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8dc7e5aea7 smh 2024-09-15 08:42:19 -04:00
Isaac Marovitz 518f6f7a49 Dont specify [[stage_in]] on fragment 2024-09-15 08:42:19 -04:00
Isaac Marovitz d3ef8c9c52 If one shader fails, whole program fails 2024-09-15 08:42:19 -04:00
Isaac Marovitz d5cc90af9d Fix fragment shaders (and fuck everything up) 2024-09-15 08:42:19 -04:00
Isaac Marovitz cc5ac6017f Vertex buffer data 2024-09-15 08:42:19 -04:00
Isaac Marovitz dd2306b16e Dont be stupid 2024-09-15 08:42:19 -04:00
Isaac Marovitz 07e77ecb64 Dont set 0 attributes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6a511b7acc Reset Descriptor instead of making a new object 2024-09-15 08:42:19 -04:00
Isaac Marovitz c0708208eb Set Vertex Descriptor properly 2024-09-15 08:42:19 -04:00
Isaac Marovitz dcb638b573 Start vertex descriptor work 2024-09-15 08:42:19 -04:00
Isaac Marovitz a3b64b794a Implement CreateProgram 2024-09-15 08:42:19 -04:00
Isaac Marovitz c8a74fcccc Fix fragment output color 2024-09-15 08:42:19 -04:00
Isaac Marovitz 80688f28b9 Set TargetLanguage for Metal to MSL 2024-09-15 08:42:19 -04:00
Isaac Marovitz 91651897ec 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-15 08:42:19 -04:00
Isaac Marovitz 3ab4b0a8b1 Fix ETC2 PTA formats
Format
2024-09-15 08:42:19 -04:00
Isaac Marovitz 198566ce5c Partial TextureQuerySamples 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9a50e13375 Fix instructions 2024-09-15 08:42:19 -04:00
Isaac Marovitz 74e2e37502 LDR ASTC 2024-09-15 08:42:19 -04:00
Isaac Marovitz a7294f9b34 Get build working again (values likely wrong) 2024-09-15 08:42:19 -04:00
Isaac Marovitz 87bf31d425 dotnet format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7d7d32e9bc 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-15 08:42:19 -04:00
Isaac Marovitz 6a1a72b328 Boot TOTK 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2285fe90bb Boot Sonic Mania 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7bdff7895d Update for new Shader IR format 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6193271fb6 Update src/Ryujinx.Graphics.Metal/Pipeline.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2024-09-15 08:42:19 -04:00
Isaac Marovitz 39c190c4e1 Vertex Input Attributes 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9c3b053679 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-15 08:42:19 -04:00
Isaac Marovitz 10adb54f0c Fix Metal Validation Error 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5ef4aa171e SDL2 Headless Metal Backend support 2024-09-15 08:42:19 -04:00
Isaac Marovitz 04758f8753 Easier capture stuff 2024-09-15 08:42:19 -04:00
Isaac Marovitz 228508acad Define MaxFramesPerCapture 2024-09-15 08:42:19 -04:00
Isaac Marovitz daa00aa019 Cleanup encoder getting + Fix capture overflow 2024-09-15 08:42:19 -04:00
Isaac Marovitz 3e6d7231cf Formatting 2024-09-15 08:42:19 -04:00
Isaac Marovitz 686582c291 Start of MSL instructions
Remaining functions
2024-09-15 08:42:19 -04:00
Isaac Marovitz bbc286400c Warn when generating unsupported shader 2024-09-15 08:42:19 -04:00
Isaac Marovitz bf36461cd4 Pass sampler to Blit shader 2024-09-15 08:42:19 -04:00
Isaac Marovitz a6dd6d7fe2 Shader comments 2024-09-15 08:42:19 -04:00
Isaac Marovitz 45782ac377 HelperShaders class 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2f9d68dfad Undertale boots 2024-09-15 08:42:19 -04:00
Isaac Marovitz 92b5f25fe1 Check if packed depth is supported 2024-09-15 08:42:19 -04:00
Isaac Marovitz e7ea69290c Fix RGB Seizure 2024-09-15 08:42:19 -04:00
Isaac Marovitz d30806faa2 Barry is here mashallah 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9ed9d54b8e Seizure my beloved is working 2024-09-15 08:42:19 -04:00
Isaac Marovitz f42a0d4199 SetData 2024-09-15 08:42:19 -04:00
Isaac Marovitz 08990ab56c Look ma no crash 2024-09-15 08:42:19 -04:00
Isaac Marovitz 67f66cca17 Whitespace 2024-09-15 08:42:19 -04:00
Isaac Marovitz 956425943f TODO 2024-09-15 08:42:19 -04:00
Isaac Marovitz 7202bd070a BeginComputePass 2024-09-15 08:42:19 -04:00
Isaac Marovitz 2477326df7 SetDepthTest 2024-09-15 08:42:19 -04:00
Isaac Marovitz 023670cfee SetStencilTest 2024-09-15 08:42:19 -04:00
Isaac Marovitz f09ab42731 Forgot depth 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5550d59198 Texture usage 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9ae482d11b CopyBuffer to Buffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz b23a6cbe91 CopyTo Buffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz a0dd90001d SetData without region 2024-09-15 08:42:19 -04:00
Isaac Marovitz 857d720c12 Rewrite SetData for GPU 2024-09-15 08:42:19 -04:00
Isaac Marovitz 8cffe3faef Clear Buffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz 5b18ff534f Use Ryujinx Logger 2024-09-15 08:42:19 -04:00
Isaac Marovitz bf78d2f77e One encoder at a time 2024-09-15 08:42:19 -04:00
Isaac Marovitz 93158a624a Fix byte alignment 2024-09-15 08:42:19 -04:00
Isaac Marovitz d054ed3736 Finish SetData /w region 2024-09-15 08:42:19 -04:00
Isaac Marovitz 9541e34016 Spoof Counters 2024-09-15 08:42:19 -04:00
Isaac Marovitz cdad6f19cc BufferAccess 2024-09-15 08:42:19 -04:00
Isaac Marovitz 483f9dfec0 Delete and Get Data from Buffer 2024-09-15 08:42:19 -04:00
Isaac Marovitz 23bfcca421 Bump SharpMetal 2024-09-15 08:42:19 -04:00
Isaac Marovitz 74626c282a Start Texture region-based CopyTo 2024-09-15 08:42:19 -04:00
Isaac Marovitz d2e9f1c7a9 IoMap 2024-09-15 08:42:19 -04:00
Isaac Marovitz 1034cddc4c Fix error 2024-09-15 08:42:19 -04:00
Isaac Marovitz 052b4b7f79 Renderer cleanup 2024-09-15 08:42:19 -04:00
Isaac Marovitz 6cfb1c38f7 Texture Copys 2024-09-15 08:42:19 -04:00
Isaac Marovitz 4a0f575593 Texture, Pipeline, Sample, Renderer Improvements 2024-09-15 08:42:19 -04:00
Isaac Marovitz f39708a805 Start Metal Backend
Revert build yml changes
2024-09-15 08:42:19 -04:00
16 changed files with 90 additions and 79 deletions

View File

@ -1,4 +1,4 @@
using Ryujinx.Common.Memory; using System.Buffers;
namespace Ryujinx.Graphics.GAL namespace Ryujinx.Graphics.GAL
{ {
@ -18,30 +18,30 @@ namespace Ryujinx.Graphics.GAL
PinnedSpan<byte> GetData(int layer, int level); PinnedSpan<byte> GetData(int layer, int level);
/// <summary> /// <summary>
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// the operation completes. /// the operation completes.
/// </summary> /// </summary>
/// <param name="data">Texture data bytes</param> /// <param name="data">Texture data bytes</param>
void SetData(MemoryOwner<byte> data); void SetData(IMemoryOwner<byte> data);
/// <summary> /// <summary>
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// the operation completes. /// the operation completes.
/// </summary> /// </summary>
/// <param name="data">Texture data bytes</param> /// <param name="data">Texture data bytes</param>
/// <param name="layer">Target layer</param> /// <param name="layer">Target layer</param>
/// <param name="level">Target level</param> /// <param name="level">Target level</param>
void SetData(MemoryOwner<byte> data, int layer, int level); void SetData(IMemoryOwner<byte> data, int layer, int level);
/// <summary> /// <summary>
/// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
/// the operation completes. /// the operation completes.
/// </summary> /// </summary>
/// <param name="data">Texture data bytes</param> /// <param name="data">Texture data bytes</param>
/// <param name="layer">Target layer</param> /// <param name="layer">Target layer</param>
/// <param name="level">Target level</param> /// <param name="level">Target level</param>
/// <param name="region">Target sub-region of the texture to update</param> /// <param name="region">Target sub-region of the texture to update</param>
void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region); void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region);
void SetStorage(BufferRange buffer); 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.Model;
using Ryujinx.Graphics.GAL.Multithreading.Resources; using Ryujinx.Graphics.GAL.Multithreading.Resources;
using System.Buffers;
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{ {
@ -8,9 +8,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
{ {
public readonly CommandType CommandType => CommandType.TextureSetData; public readonly CommandType CommandType => CommandType.TextureSetData;
private TableRef<ThreadedTexture> _texture; private TableRef<ThreadedTexture> _texture;
private TableRef<MemoryOwner<byte>> _data; private TableRef<IMemoryOwner<byte>> _data;
public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data) public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data)
{ {
_texture = texture; _texture = texture;
_data = data; _data = data;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,16 @@ namespace Ryujinx.Graphics.Metal
_pipeline = pipeline; _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) public void SetImages(int index, ITexture[] images)
{ {
for (int i = 0; i < images.Length; i++) for (int i = 0; i < images.Length; i++)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{ {
private readonly MemoryOwner<byte> _rawDataOwner; private readonly MemoryOwner<byte> _rawDataOwner;
private Span<byte> Raw => _rawDataOwner.Span; private Span<byte> Raw => _rawDataOwner.Memory.Span;
private ref ParcelHeader Header => ref MemoryMarshal.Cast<byte, ParcelHeader>(Raw)[0]; 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;
using System.Buffers;
namespace Ryujinx.Memory namespace Ryujinx.Memory
{ {
@ -7,7 +7,7 @@ namespace Ryujinx.Memory
{ {
private readonly IWritableBlock _block; private readonly IWritableBlock _block;
private readonly ulong _va; private readonly ulong _va;
private readonly MemoryOwner<byte> _memoryOwner; private readonly IMemoryOwner<byte> _memoryOwner;
private readonly bool _tracked; private readonly bool _tracked;
private bool NeedsWriteback => _block != null; private bool NeedsWriteback => _block != null;
@ -22,7 +22,7 @@ namespace Ryujinx.Memory
Memory = memory; Memory = memory;
} }
public WritableRegion(IWritableBlock block, ulong va, MemoryOwner<byte> memoryOwner, bool tracked = false) public WritableRegion(IWritableBlock block, ulong va, IMemoryOwner<byte> memoryOwner, bool tracked = false)
: this(block, va, memoryOwner.Memory, tracked) : this(block, va, memoryOwner.Memory, tracked)
{ {
_memoryOwner = memoryOwner; _memoryOwner = memoryOwner;