Commit Graph

384 Commits (threaded_video_fix)

Author SHA1 Message Date
cosmonaut 385783a846 restructure audio cleanup 2023-12-08 16:33:52 -08:00
cosmonaut 450b08cbd8 Atomically call graphics resource destroy function 2023-12-08 16:07:38 -08:00
cosmonaut 528fb7ac7c fix potential heap corruption on audio shutdown 2023-12-08 15:06:17 -08:00
cosmonaut e961a18a83 UpdatingSourceVoice + warn on audio leak 2023-11-20 18:56:22 -08:00
cosmonaut 772a0378bb avoid calling Thread.Join from finalizer 2023-11-20 17:59:26 -08:00
cosmonaut 40fb313d12 change AudioResource WeakRef to GCHandle 2023-11-20 17:52:44 -08:00
cosmonaut a736ed031d clean up graphics resource code 2023-11-20 17:09:22 -08:00
cosmonaut b2a0ca3515 replace WeakReference with weak GCHandle 2023-11-20 15:18:06 -08:00
cosmonaut 36a88afe52 add no-op delegate to gamepad connect events 2023-11-14 11:19:21 -08:00
cosmonaut 6c93350f7f Add OnGamepadConnected and OnGamepadDisconnected events (#51)
Reviewed-on: #51
2023-11-13 19:10:29 +00:00
cosmonaut 18d92aeec8 remove Fix64 dependency on System.Random 2023-10-13 13:38:26 -07:00
cosmonaut e616b0fa62 resource management and logging improvements 2023-10-04 14:45:17 -07:00
cosmonaut daae1a34b9 fix a few more compile errors 2023-09-19 17:14:48 -07:00
cosmonaut 2e5657789c fix a Conversions issue 2023-09-19 17:11:14 -07:00
cosmonaut 0c76c568a4 document the Game class 2023-09-19 17:04:28 -07:00
cosmonaut abdcac1608 change AudioDevice constructor to internal 2023-09-19 17:04:03 -07:00
cosmonaut d8064862bf move PackedVector classes to MoonWorks.Graphics.PackedVector 2023-09-19 16:50:08 -07:00
cosmonaut b223c31c8b even more frame limiter clarification 2023-09-19 13:48:50 -07:00
cosmonaut dd79090028 update frame limiter docs some more 2023-09-19 13:47:19 -07:00
cosmonaut 653f90c29f correct frame limiter documentation mistake 2023-09-19 13:46:41 -07:00
cosmonaut 402c26131d fix erroneous GetData length warning 2023-09-19 13:40:48 -07:00
cosmonaut b026b9e81f add lots more doc comments 2023-09-19 13:19:41 -07:00
cosmonaut e0f05881b0 new MoonWorks.Graphics.Fence API 2023-09-18 23:18:21 -07:00
cosmonaut 7e18764942 add doc comments for the Input namespace 2023-09-14 11:23:04 -07:00
cosmonaut 1bff459be6 move default reverb params to a static var 2023-09-12 15:24:45 -07:00
cosmonaut be77e8bad1 add exponentiation functions to Fix64 2023-09-07 17:30:35 -07:00
cosmonaut 7f6b6a7bae fix voices not respecting the faux mastering voice 2023-08-10 10:46:19 -07:00
cosmonaut 1de3c73bb7 fix voices being created in the Playing state 2023-08-09 16:10:00 -07:00
cosmonaut e77c87c772 register new SourceVoices as active 2023-08-09 15:58:18 -07:00
cosmonaut 088e7c4b6f add debug check for zero length buffer copy 2023-08-07 10:12:46 -07:00
cosmonaut f298a5ec11 fix StreamingVoice loop behavior 2023-08-04 12:14:14 -07:00
cosmonaut 0cd2c799ee Audio Restructuring (#50)
This is a complete redesign of the MoonWorks Audio API.

Voices are the new major concept. All Voices can be configured with volume, pitch, filters, panning and reverb. SourceVoices take in AudioBuffers and use them to play sound. They contain their own playback state.

There are multiple kinds of SourceVoices:
TransientVoice: Used for short sound effects where the client will not be keeping track of a reference over multiple frames.
PersistentVoice: Used when the client needs to hold on to a Voice reference long-term.
StreamingVoice: Used for playing back AudioDataStreamable objects.
SoundSequence: Used to play back a series of AudioBuffers in sequence. They have a callback so that AudioBuffers can be added dynamically by the client.

SourceVoices are intended to be pooled. You can obtain one from the AudioDevice pool by calling AudioDevice.Obtain<T> where T is the type of SourceVoice you wish to obtain. When you call Return on the voice it will be returned to the pool. TransientVoices are automatically returned to the pool when they have finished playing back their AudioBuffer.

SourceVoices can send audio to SubmixVoices. This is a convenient way to manage categories of audio. For example the client could have a MusicSubmix that all music-related voices send to. Then the volume of all music can be changed at once without the client having to manage all the individual music voices.

By default all voices send audio to AudioDevice.MasteringVoice. This is also a SubmixVoice that can be controlled like any other voice.

AudioDataStreamable is used in conjunction with a StreamingVoice to play back streaming audio from an ogg or qoa file.

AudioDataWav, AudioDataOgg, and AudioDataQoa all have a static CreateBuffer method that can be used to create an AudioBuffer from an audio file.

Reviewed-on: #50
2023-08-03 19:54:02 +00:00
cosmonaut 81cd397013 fix AudioDevice crash on shutdown 2023-07-28 15:02:20 -07:00
cosmonaut e73c7ede55 rename SoundQueue to SoundSequence 2023-07-28 13:21:50 -07:00
cosmonaut 83f1cc24db rename OnBufferNeeded to OnSoundNeeded 2023-07-28 13:10:01 -07:00
cosmonaut 1d86d0c210 add SoundQueue 2023-07-28 13:02:50 -07:00
cosmonaut dbbd6540ab fix StaticSoundInstance.Pause not actually pausing 2023-06-30 11:51:20 -07:00
cosmonaut 74ae295036 fix audio thread race condition on StaticAudio.GetInstance 2023-06-29 15:01:22 -07:00
cosmonaut 36ddb03d8f only check video exception on thread fault 2023-06-29 12:14:46 -07:00
cosmonaut bf3ad0c8b0 add Game.ShowRuntimeError method 2023-06-29 11:30:32 -07:00
cosmonaut f761d4f76e re-throw exceptions from video thread 2023-06-29 11:30:16 -07:00
cosmonaut 4c731401ff fix vertical axis on axis buttons being backwards 2023-06-28 18:19:34 -07:00
cosmonaut 071518732e set axis button threshold default to 0.5 2023-06-28 17:17:57 -07:00
cosmonaut 1adb76d5c7 exception handlers for video decoder threads 2023-06-28 13:20:33 -07:00
cosmonaut 5ff7da927a try-catch inside AudioThreadMain 2023-06-28 13:20:18 -07:00
cosmonaut 7e79e4a11d fix validator warnings on Quit 2023-06-15 17:45:26 -07:00
cosmonaut fc0937b2ff fix crash caused by audio weak references 2023-06-14 18:22:49 -07:00
cosmonaut c83997609f fix some scenarios where video pointers should not be replaced 2023-06-13 19:18:23 -07:00
cosmonaut b65d4e391c public Fix64 RawValue 2023-06-12 09:53:44 -07:00
cosmonaut 56bab545ba add MouseButton.Button lookup 2023-06-09 18:15:15 -07:00
cosmonaut 2ae116c72b fix window dimensions when starting in fullscreen 2023-06-09 16:27:43 -07:00
cosmonaut bd3e70b096 make KeyboardButton.KeyCode public 2023-06-09 16:17:41 -07:00
cosmonaut b1fe7f96b2 recenter window on windowed mode change 2023-06-09 11:42:20 -07:00
cosmonaut 496eb670ab AV1 Video instead of Theora (#49)
VideoPlayer now takes AV1 video instead of Ogg Theora. This brings a significant decode speed improvement. The decoder now also operates in a threaded manner, which should prevent runtime stalls when fetching video frames.

Reviewed-on: #49
2023-06-07 21:18:44 +00:00
cosmonaut 00f4bfdeae optimize StreamingSoundQoa.Create 2023-05-22 19:24:26 -07:00
cosmonaut adeba633e5 csproj tweaks to support app publish 2023-05-22 18:28:13 -07:00
cosmonaut 300ef9f88e fix unnecessary copy in PackFontRanges 2023-05-22 11:41:19 -07:00
cosmonaut 76684eaa33 fix memory leak in StreamingSoundQoa.Create 2023-05-11 19:45:07 -07:00
cosmonaut c037b4cb69 fix StaticSoundInstance race condition and state 2023-05-11 18:59:26 -07:00
cosmonaut 5df08727c1 Sound instancing rework 2023-05-11 17:56:40 -07:00
cosmonaut 537517afb9 remove buffer size log 2023-05-10 15:13:19 -07:00
cosmonaut bd405dfbf0 QOA Support (#48)
Reviewed-on: #48
2023-05-05 22:26:32 +00:00
cosmonaut 2d7bb24b5c rename Texture load methods for clarity 2023-04-19 00:50:59 -07:00
cosmonaut 0ea60a376b new image loader API 2023-04-19 00:41:18 -07:00
cosmonaut e3c2f0e119 fix controller hot swapping 2023-04-05 16:52:36 -07:00
cosmonaut 3584e670ee add array overloads to avoid explicit generic parameter 2023-04-05 12:40:34 -07:00
cosmonaut 5a2f7eadb8 change array param to span in Buffer.GetData 2023-04-05 11:32:12 -07:00
cosmonaut 1e3f04235e remove array parameters from API functions 2023-04-05 11:07:16 -07:00
cosmonaut dd06205399 stop static sound instance on Free 2023-04-05 01:18:13 -07:00
cosmonaut 1cf04a7279 assets stream data directly into unmanaged memory 2023-04-05 00:47:02 -07:00
cosmonaut 3bd435746b StaticSound external byte buffer constructor 2023-04-04 17:12:03 -07:00
cosmonaut 8134761e44 load images from memory + QOI support 2023-04-03 17:28:00 -07:00
cosmonaut 8209051a3c remove non-static Normalize + return identity on zero vector 2023-03-29 10:06:37 -07:00
cosmonaut 80f3711f4c add Quit method to Game 2023-03-16 16:48:52 -07:00
cosmonaut 3a6b73e637 add int clamp to MathHelper 2023-03-14 14:42:13 -07:00
cosmonaut 12e7e6b9c1 add Color.FromHSV 2023-03-09 15:14:16 -08:00
cosmonaut 455f4048df MathHelper.Quantize uses round instead of floor 2023-03-09 13:52:45 -08:00
cosmonaut 1f0e3b5040 Audio Improvements (#47)
- Audio is now processed on a background thread instead of the main thread
- Audio tick rate is now ~200Hz
- MoonWorks.Math.Easings class completely rewritten to be easier to understand and use
- SoundInstance properties no longer call into FAudio unless the value actually changed
- SoundInstance property values can now be interpolated over time (tweens)
- SoundInstance tweens can be delayed
- SoundInstance sets a sane filter frequency default when switching filter type
- StreamingSound classes can be designated to update automatically on the audio thread or manually
- StreamingSound buffer consumption should now set Stopped state in a more sane way
- Added ReverbEffect, which creates a submix voice for a reverb effect
- SoundInstance can apply a ReverbEffect, which enables the Reverb property
- Audio resource tracking improvements
- Some tweaks to VideoPlayer to make its behavior more consistent

Reviewed-on: #47
2023-03-07 23:28:57 +00:00
cosmonaut f8b14ea94f add ReverbEffect 2023-03-01 17:47:09 -08:00
cosmonaut 472da0edd2 add Hidden property to Mouse 2023-03-01 13:47:25 -08:00
cosmonaut bd825b6c91 allow pushing raw uniform data 2023-02-23 16:59:34 -08:00
cosmonaut 515c2ebbca fix controller double open 2023-02-23 16:59:19 -08:00
cosmonaut 86322e9373 log controller open errors 2023-02-21 16:00:16 -08:00
cosmonaut e9aacb44da Add synchronized audio playback mechanism 2023-02-16 15:12:35 -08:00
cosmonaut 5baa1d7b40 Fix video shader base path lookup 2023-02-08 12:44:36 -08:00
cosmonaut 36ce74b58a tweak video shader filenames 2023-02-03 15:07:32 -08:00
cosmonaut 40d12357c0 Remove MoonWorks.Collision (#46)
After months of tweaking and refactoring I have realized that collision is like rendering - it's so fundamental to the structure of your game that making broad decisions about how it should work from a library level is too restrictive and difficult to optimize. Anyone skilled enough to use MoonWorks should be easily able to roll their own collision detection.

Reviewed-on: #46
2023-02-03 19:51:36 +00:00
TheSpydog b39526ca90 Textures now have a sample count, not render passes (#45)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #45
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-31 20:27:26 +00:00
TheSpydog 88d9119830 Remove warning from DrawInstancedPrimitives doc comment (#44)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #44
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-24 00:14:46 +00:00
TheSpydog 05de9a4066 Make video shaders optional and search for them in the root output directory (#42)
Whenever the video shaders change, they can be rebuilt with refreshc and distributed alongside the moonlibs.

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #42
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-21 23:37:01 +00:00
TheSpydog b1d30a9e6c Remove isFixed param from AcquireCommandBuffer call (#41)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #41
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-14 18:04:53 +00:00
TheSpydog 030745361b Fix BC7 loading for textures without DDSD_CAPS/FMT (#40)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #40
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-07 01:46:59 +00:00
cosmonaut c43df10c2a vertex binding API improvements 2023-01-05 13:41:48 -08:00
cosmonaut 95981f0f03 rework vertex input state creation to avoid reflection 2023-01-04 17:34:01 -08:00
TheSpydog 230c1b41b4 Add IndirectDrawCommand struct (#39)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #39
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-04 18:44:56 +00:00
TheSpydog 6f8858c8b7 RasterizerState / BlendFactor ABI break (#38)
Updates the APIs to match [this Refresh PR](MoonsideGames/Refresh#27).

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #38
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2022-12-29 03:22:47 +00:00
TheSpydog f96298f991 Add validation checks for AcquireSwapchainTexture and BindVertexBuffers (#37)
This replaces the Refresh-side check for window claim status in AcquireSwapchainTexture, and adds validation to ensure that BindVertexBuffers is not called before BindGraphicsPipeline.

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #37
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2022-12-29 03:18:36 +00:00
cosmonaut d76633bdfc change sizeof calls to Marshal.SizeOf in interop situations 2022-12-13 19:01:40 -08:00
cosmonaut debb76f62a validate scissor dimensions 2022-12-13 16:09:32 -08:00
cosmonaut ca61e94b13 optimize mouse update 2022-12-13 15:13:43 -08:00