From 7d7437721c1027fe630e926c23393cfae4678eca Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 12 Jan 2022 13:01:32 -0800 Subject: [PATCH] uniforms are now pushed via command buffer --- lib/RefreshCS | 2 +- src/Graphics/CommandBuffer.cs | 57 ++++++++++++++++++++++ src/Graphics/Resources/ComputePipeline.cs | 15 ------ src/Graphics/Resources/GraphicsPipeline.cs | 30 ------------ 4 files changed, 58 insertions(+), 46 deletions(-) diff --git a/lib/RefreshCS b/lib/RefreshCS index 1befeda8..34bf0b69 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit 1befeda8f51e9104de127e1480985771d4a4b380 +Subproject commit 34bf0b69aedfdb50ce4d161173a955998746dad8 diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index efe359c8..309918fc 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -371,6 +371,63 @@ namespace MoonWorks.Graphics BindFragmentSamplers(textureSamplerBindings, textureSamplerBindings.Length); } + /// + /// Pushes vertex shader uniforms to the device. + /// + /// A starting offset value to be used with draw calls. + public unsafe uint PushVertexShaderUniforms( + params T[] uniforms + ) where T : unmanaged + { + fixed (T* ptr = &uniforms[0]) + { + return Refresh.Refresh_PushVertexShaderUniforms( + Device.Handle, + Handle, + (IntPtr) ptr, + (uint) (uniforms.Length * Marshal.SizeOf()) + ); + } + } + + /// + /// Pushes fragment shader uniforms to the device. + /// + /// A starting offset to be used with draw calls. + public unsafe uint PushFragmentShaderUniforms( + params T[] uniforms + ) where T : unmanaged + { + fixed (T* ptr = &uniforms[0]) + { + return Refresh.Refresh_PushFragmentShaderUniforms( + Device.Handle, + Handle, + (IntPtr) ptr, + (uint) (uniforms.Length * Marshal.SizeOf()) + ); + } + } + + /// + /// Pushes compute shader uniforms to the device. + /// + /// A starting offset to be used with dispatch calls. + public unsafe uint PushComputeShaderUniforms( + params T[] uniforms + ) where T : unmanaged + { + fixed (T* ptr = &uniforms[0]) + { + return Refresh.Refresh_PushComputeShaderUniforms( + Device.Handle, + Handle, + (IntPtr) ptr, + (uint) (uniforms.Length * Marshal.SizeOf()) + ); + } + } + /// /// Clears the render targets on the current framebuffer to a single color or depth/stencil value. /// NOTE: It is recommended that you clear when beginning render passes unless you have a good reason to clear mid-pass. diff --git a/src/Graphics/Resources/ComputePipeline.cs b/src/Graphics/Resources/ComputePipeline.cs index a4739395..8cb6a5db 100644 --- a/src/Graphics/Resources/ComputePipeline.cs +++ b/src/Graphics/Resources/ComputePipeline.cs @@ -40,20 +40,5 @@ namespace MoonWorks.Graphics ComputeShaderState = computeShaderState; } - - public unsafe uint PushComputeShaderUniforms( - params T[] uniforms - ) where T : unmanaged - { - fixed (T* ptr = &uniforms[0]) - { - return Refresh.Refresh_PushComputeShaderUniforms( - Device.Handle, - Handle, - (IntPtr) ptr, - (uint) (uniforms.Length * Marshal.SizeOf()) - ); - } - } } } diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index d0310b76..78752076 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -128,35 +128,5 @@ namespace MoonWorks.Graphics FragmentShaderState = fragmentShaderState; RenderPass = renderPass; } - - public unsafe uint PushVertexShaderUniforms( - params T[] uniforms - ) where T : unmanaged - { - fixed (T* ptr = &uniforms[0]) - { - return Refresh.Refresh_PushVertexShaderUniforms( - Device.Handle, - Handle, - (IntPtr) ptr, - (uint) (uniforms.Length * Marshal.SizeOf()) - ); - } - } - - public unsafe uint PushFragmentShaderUniforms( - params T[] uniforms - ) where T : unmanaged - { - fixed (T* ptr = &uniforms[0]) - { - return Refresh.Refresh_PushFragmentShaderUniforms( - Device.Handle, - Handle, - (IntPtr) ptr, - (uint) (uniforms.Length * Marshal.SizeOf()) - ); - } - } } }