From 29a86c2040cef04231c65cb820e656516d84bbf7 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 5 Feb 2021 19:51:10 -0800 Subject: [PATCH] move uniform pushes to pipeline --- lib/RefreshCS | 2 +- src/Graphics/CommandBuffer.cs | 45 ---------------------- src/Graphics/Resources/ComputePipeline.cs | 16 ++++++++ src/Graphics/Resources/GraphicsPipeline.cs | 30 +++++++++++++++ 4 files changed, 47 insertions(+), 46 deletions(-) diff --git a/lib/RefreshCS b/lib/RefreshCS index fcb16a6..a92549a 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit fcb16a6121f556b2aebfbb7e72b71e94041dc1d1 +Subproject commit a92549a91395900f30fe9010dfe86e19fedd4e85 diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index a80a170..6cc414e 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -69,21 +69,6 @@ namespace MoonWorks.Graphics ); } - 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()) - ); - } - } - public unsafe void BindComputeBuffers( params Buffer[] buffers ) { @@ -128,36 +113,6 @@ namespace MoonWorks.Graphics ); } - 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()) - ); - } - } - public unsafe void BindVertexBuffers( uint firstBinding, params BufferBinding[] bufferBindings diff --git a/src/Graphics/Resources/ComputePipeline.cs b/src/Graphics/Resources/ComputePipeline.cs index 67ed759..a473939 100644 --- a/src/Graphics/Resources/ComputePipeline.cs +++ b/src/Graphics/Resources/ComputePipeline.cs @@ -1,5 +1,6 @@ using RefreshCS; using System; +using System.Runtime.InteropServices; namespace MoonWorks.Graphics { @@ -39,5 +40,20 @@ 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 21e11d3..863244d 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -124,5 +124,35 @@ 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()) + ); + } + } } }