77 Commits

Author SHA1 Message Date
Isaac Marovitz
d42f0e5945 Image binding support
Kirby still has a problem with NaN 3D Texture
2024-12-23 21:40:22 -06:00
Isaac Marovitz
1f133040bd Better vertex buffer management 2024-12-23 21:39:47 -06:00
Isaac Marovitz
fcd2adecc5 Better index buffer management 2024-12-23 21:39:43 -06:00
Isaac Marovitz
b468569665 Formatting cleanup 2024-12-23 21:39:36 -06:00
Isaac Marovitz
353a6ca4bb Formatting 2024-12-23 21:39:31 -06:00
Isaac Marovitz
d2f965885a Fix blend state optimisation breaking attachments
Fixes SM3DW
2024-12-23 21:39:07 -06:00
riperiperi
26da57cccd Maintain identity swizzle view of textures for rendering 2024-12-23 21:39:03 -06:00
Isaac Marovitz
58527e02ee Cleanup + Format 2024-12-23 21:38:54 -06:00
Isaac Marovitz
4d5b128a81 Fix trying to reserve size 0 in staging buffer 2024-12-23 21:38:46 -06:00
Isaac Marovitz
49a814a400 Fix zero buff not being reset 2024-12-23 21:38:42 -06:00
Isaac Marovitz
09546205b5 Dirty Arg Buffers on Program Change 2024-12-23 21:38:39 -06:00
Isaac Marovitz
d2a4a9e9a7 Least allocations in the west 2024-12-23 21:38:37 -06:00
Isaac Marovitz
d3f273cad1 Don’t use Enum.HasFlag 2024-12-23 21:38:35 -06:00
Isaac Marovitz
60722a1837 Metal: Better Bindings (#29)
* Tell GAL to use Vk model (and break everything)

* ResourceBindingSegments

* Set information on backend caps

* Get ready to break everything

* Refactor EncoderStateManager

* Remove padding from helper shaders

* Fix ref array sizes

* Seperate vert & frag buffers

* Shader-side changes

* Fixes

* Fix some helper shader resource layouts

* Sort by binding id

* Fix helper shader layouts

* Don’t do inline vertex buffer updates

* Check for null storage
2024-12-23 21:38:32 -06:00
Isaac Marovitz
144397c3da Don’t do inline vertex buffer updates
Somehow broke zero buff MTLVertexDescriptor, but fixes broken geoemtry so I’m pushing anyway
2024-12-23 21:38:17 -06:00
riperiperi
879c93cf73 Preload command speedup, Texture/buffer data flush, blit shader fix (#30)
* Move encoder state to be tied to command buffer, so preload and background cbs have their own encoder state

* Texture buffer/data flush, blit shader fix
2024-12-23 21:38:13 -06:00
riperiperi
4b53d18bef Fix Geometry/TFB on compute, Buffer Textures, add Window Resizing (#28) 2024-12-23 21:38:00 -06:00
riperiperi
bbbc9e529d State and cache optimization (#27)
* WIP pipeline/depth state cache rework

* Fix some issues

* Fix some more default values

* Reduce allocations for state changes

* fix helpershader stuff

* explanation comment

* fix depth bias
2024-12-23 21:37:58 -06:00
Isaac Marovitz
3b2beda27f Don’t bind byte format converted index buffers at requested index 2024-12-23 21:37:48 -06:00
Isaac Marovitz
de8e03c350 Render target deduplication
not sure if this is working
2024-12-23 21:37:45 -06:00
Isaac Marovitz
16bc02ea2a Fix blend descriptors not dirting render pipeline
Thanks peri
2024-12-23 21:37:41 -06:00
Isaac Marovitz
a9633981a8 Be better about memory 2024-12-23 21:37:36 -06:00
Isaac Marovitz
4f699ef96a Fix Cull FrontAndBack 2024-12-23 21:37:07 -06:00
Isaac Marovitz
dae0f3cded Argument Buffers (#24)
* Stuff

* More arg buffer stuff

* Fixes

* Rebase

* Pass storage buffers to inline functions

* Fix binding

* Fix typo + Fix a couple shaders

* Enforce ids

* Dispose

* Mark used buffers as resident

* Update depth clear shader

* Fix non-contiguous struct defs

* Update ChangeBufferStride

* Fix StorageBuffer assignments

* Fix odyssey crash

* Retain buffer bindings

* Pad Std140

* Set texture data with safe buffers

* Clone buffers

* Always declare vert in

* Stop clears from breaking OpenGL games

* Fix depth clear

* Use invariant position

* Horribly inefficient texture & sampler arg buffers

* Fix missing struct access

* Minimise rebinds as much as possible

* Build arg buffers on staging buffer
2024-12-23 21:37:01 -06:00
Isaac Marovitz
9b138a413c Actually clear the right render target 2024-12-23 21:36:54 -06:00
Isaac Marovitz
197184657f Cleanup Pipeline
Housekeeping

More housekeeping
2024-12-23 21:36:44 -06:00
Isaac Marovitz
c911db8309 Fix FEZ not showing anything
Does not fix the underlying shortcomings of the cache system
2024-12-23 21:35:50 -06:00
Isaac Marovitz
b8779c6e09 Buffer Conversions (#23)
* Why is this not working

* Revert helper shader changes for now

* Byte Index Buffer Restride
2024-12-23 21:35:38 -06:00
Isaac Marovitz
dda746c0fb Metal: Buffers Take 2 (#21)
* Basic BufferManager

* Start Scoped Command Buffers

* Fences stuff

* Remember to cleanup sync manager

* Auto, Command Buffer Dependants

* Cleanup

* Cleanup + Fix Texture->Buffer Copies

* Slow buffer upload

* Cleanup + Rework TextureBuffer

* Don’t get unsafe

* Cleanup

* Goddamn it

* Staging Buffer + Interrupt Action + Flush
2024-12-23 21:35:33 -06:00
Isaac Marovitz
5423ad9ae1 Depth Bias 2024-12-23 21:35:13 -06:00
Isaac Marovitz
9ab2cd94c1 Fix Clear Viewport 2024-12-23 21:34:55 -06:00
Isaac Marovitz
9ebf82f184 More cleanup 2024-12-23 21:33:17 -06:00
Isaac Marovitz
f00cf8704f Metal: Compute Shaders (#19)
* check for too bix texture bindings

* implement lod query

* print shader stage name

* always have fragment input

* resolve merge conflicts

* fix: lod query

* fix: casting texture coords

* support non-array memories

* use structure types for buffers

* implement compute pipeline cache

* compute dispatch

* improve error message

* rebind compute state

* bind compute textures

* pass local size as an argument to dispatch

* implement texture buffers

* hack: change vertex index to vertex id

* pass support buffer as an argument to every function

* return at the end of function

* fix: certain missing compute bindings

* implement texture base

* improve texture binding system

* remove useless exception

* move texture handle to texture base

* fix: segfault when using disposed textures

---------

Co-authored-by: Samuliak <samuliak77@gmail.com>
Co-authored-by: SamoZ256 <96914946+SamoZ256@users.noreply.github.com>
2024-12-23 21:33:12 -06:00
Isaac Marovitz
65da0569a3 Handle stride 0 on regular buffers 2024-12-23 21:33:09 -06:00
Isaac Marovitz
d811532a9f Buffer Descriptor Step Functions 2024-12-23 21:33:07 -06:00
Isaac Marovitz
2e99df371f Stencil Ref Value 2024-12-23 21:32:56 -06:00
Isaac Marovitz
ac8af32744 Stencil Fixes 2024-12-23 21:32:54 -06:00
Isaac Marovitz
a58568d036 RenderTargetColorMasks 2024-12-23 21:32:52 -06:00
SamoZ256
505f830556 Zero vertex buffer (#17)
* cast src size to float

* implement zero buffers
2024-12-23 21:32:47 -06:00
Isaac Marovitz
f7941a0a8b Metal: Advanced Present (#6)
* Initial DrawTexture support & Advanced Present

* TODO: Get Scissors Working

* Chnage scissor state management

* Rebase problems…

* Rebase fixes again

* Update DrawTexture + Fix Topology

* Fix flipping

* Add clear action support

* Cleanup
2024-12-23 21:32:40 -06:00
SamoZ256
6cc4d46e8c Clone the state & flip viewport vertically (#16)
* implement texture get data

* reset all state before blit & clone state

* format

* support blit regions

* implement source region for blit

* replace bottom with top

* account for 0 size

* support image flipping

* revert presentation fixes & y flip

* revert

* flip viewport vertically

* switch face winding

* comment

* use SetBytes for texture clear

* implement missing compute builtins

* change storage and texture buffer alignment

* correct compute builtins

* don't use nullable for textures and samplers

* remove incorrect texture get data implementation

* Cleanup IntPtrs

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-12-23 21:32:34 -06:00
SamoZ256
18b852e05d Fix Scott Pilgrim (#15)
* check for null vertex functions

* format

* Format

---------

Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
2024-12-23 21:32:02 -06:00
Isaac Marovitz
881ab59177 Use Stack instead of List 2024-12-23 21:31:57 -06:00
Isaac Marovitz
327c1576f7 Whitespace formatting 2024-12-23 21:31:54 -06:00
Samuliak
9f01cce95f fix: don't dispose stencil state before using 2024-12-23 21:31:30 -06:00
Samuliak
0abbbdc277 allow null depth stencil render targets 2024-12-23 21:31:28 -06:00
Samuliak
d5437f3dbf reset viewport before blit 2024-12-23 21:31:24 -06:00
Samuliak
af341f88df dispose all objects in encoder state manager 2024-12-23 21:30:58 -06:00
Samuliak
1ff81393be dispose caches 2024-12-23 21:30:55 -06:00
Samuliak
280efb2ed6 set the inline state after restoring state 2024-12-23 21:30:46 -06:00