diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs
index 42576fc..3d80531 100644
--- a/src/Graphics/CommandBuffer.cs
+++ b/src/Graphics/CommandBuffer.cs
@@ -22,6 +22,105 @@ namespace MoonWorks.Graphics
Handle = handle;
}
+ ///
+ /// Begins a render pass.
+ /// All render state, resource binding, and draw commands must be made within a render pass.
+ /// It is an error to call this after calling BeginRenderPass but before calling EndRenderPass.
+ ///
+ /// The render pass object to begin.
+ /// The framebuffer used by the render pass.
+ public unsafe void BeginRenderPass(
+ RenderPass renderPass,
+ Framebuffer framebuffer
+ )
+ {
+ var renderArea = new Rect
+ {
+ X = 0,
+ Y = 0,
+ W = (int) framebuffer.Width,
+ H = (int) framebuffer.Height
+ };
+
+ Refresh.Refresh_BeginRenderPass(
+ Device.Handle,
+ Handle,
+ renderPass.Handle,
+ framebuffer.Handle,
+ renderArea.ToRefresh(),
+ IntPtr.Zero,
+ 0,
+ IntPtr.Zero
+ );
+ }
+
+ ///
+ /// Begins a render pass.
+ /// All render state, resource binding, and draw commands must be made within a render pass.
+ /// It is an error to call this after calling BeginRenderPass but before calling EndRenderPass.
+ ///
+ /// The render pass object to begin.
+ /// The framebuffer used by the render pass.
+ /// The screen area of the render pass.
+ public unsafe void BeginRenderPass(
+ RenderPass renderPass,
+ Framebuffer framebuffer,
+ in Rect renderArea
+ )
+ {
+ Refresh.Refresh_BeginRenderPass(
+ Device.Handle,
+ Handle,
+ renderPass.Handle,
+ framebuffer.Handle,
+ renderArea.ToRefresh(),
+ IntPtr.Zero,
+ 0,
+ IntPtr.Zero
+ );
+ }
+
+ ///
+ /// Begins a render pass.
+ /// All render state, resource binding, and draw commands must be made within a render pass.
+ /// It is an error to call this after calling BeginRenderPass but before calling EndRenderPass.
+ ///
+ /// The render pass object to begin.
+ /// The framebuffer used by the render pass.
+ /// The screen area of the render pass.
+ /// Color clear values for each render target in the framebuffer.
+ public unsafe void BeginRenderPass(
+ RenderPass renderPass,
+ Framebuffer framebuffer,
+ in Rect renderArea,
+ params Vector4[] clearColors
+ )
+ {
+ Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
+
+ for (var i = 0; i < clearColors.Length; i++)
+ {
+ colors[i] = new Refresh.Vec4
+ {
+ x = clearColors[i].X,
+ y = clearColors[i].Y,
+ z = clearColors[i].Z,
+ w = clearColors[i].W
+ };
+ }
+
+ Refresh.Refresh_BeginRenderPass(
+ Device.Handle,
+ Handle,
+ renderPass.Handle,
+ framebuffer.Handle,
+ renderArea.ToRefresh(),
+ (IntPtr) colors,
+ (uint) clearColors.Length,
+ IntPtr.Zero
+ );
+ }
+
///
/// Begins a render pass.
/// All render state, resource binding, and draw commands must be made within a render pass.
@@ -93,73 +192,6 @@ namespace MoonWorks.Graphics
);
}
- ///
- /// Begins a render pass.
- /// All render state, resource binding, and draw commands must be made within a render pass.
- /// It is an error to call this after calling BeginRenderPass but before calling EndRenderPass.
- ///
- /// The render pass object to begin.
- /// The framebuffer used by the render pass.
- /// The screen area of the render pass.
- /// Color clear values for each render target in the framebuffer.
- public unsafe void BeginRenderPass(
- RenderPass renderPass,
- Framebuffer framebuffer,
- in Rect renderArea,
- params Vector4[] clearColors
- )
- {
- Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length];
-
- for (var i = 0; i < clearColors.Length; i++)
- {
- colors[i] = new Refresh.Vec4
- {
- x = clearColors[i].X,
- y = clearColors[i].Y,
- z = clearColors[i].Z,
- w = clearColors[i].W
- };
- }
-
- Refresh.Refresh_BeginRenderPass(
- Device.Handle,
- Handle,
- renderPass.Handle,
- framebuffer.Handle,
- renderArea.ToRefresh(),
- (IntPtr) colors,
- (uint) clearColors.Length,
- IntPtr.Zero
- );
- }
-
- ///
- /// Begins a render pass.
- /// All render state, resource binding, and draw commands must be made within a render pass.
- /// It is an error to call this after calling BeginRenderPass but before calling EndRenderPass.
- ///
- /// The render pass object to begin.
- /// The framebuffer used by the render pass.
- /// The screen area of the render pass.
- public unsafe void BeginRenderPass(
- RenderPass renderPass,
- Framebuffer framebuffer,
- in Rect renderArea
- )
- {
- Refresh.Refresh_BeginRenderPass(
- Device.Handle,
- Handle,
- renderPass.Handle,
- framebuffer.Handle,
- renderArea.ToRefresh(),
- IntPtr.Zero,
- 0,
- IntPtr.Zero
- );
- }
-
///
/// Binds a compute pipeline so that compute work may be dispatched.
///
@@ -600,6 +632,65 @@ namespace MoonWorks.Graphics
);
}
+ ///
+ /// Prepares a texture to be presented to a window.
+ /// This particular variant of this method will present to the entire window area.
+ ///
+ /// The texture to present.
+ /// The filter to use when the texture size differs from the window size.
+ public void QueuePresent(
+ Texture texture,
+ Filter filter,
+ OSWindow window
+ )
+ {
+ var refreshTextureSlice = new Refresh.TextureSlice
+ {
+ texture = texture.Handle,
+ rectangle = new Refresh.Rect
+ {
+ x = 0,
+ y = 0,
+ w = (int) texture.Width,
+ h = (int) texture.Height
+ },
+ layer = 0,
+ level = 0,
+ depth = 0
+ };
+
+ Refresh.Refresh_QueuePresent(
+ Device.Handle,
+ Handle,
+ refreshTextureSlice,
+ IntPtr.Zero,
+ (Refresh.Filter) filter,
+ window.Handle
+ );
+ }
+
+ ///
+ /// Prepares a texture slice to be presented to a window.
+ /// This particular variant of this method will present to the entire window area.
+ ///
+ /// The texture slice to present.
+ /// The filter to use when the texture size differs from the window size.
+ public void QueuePresent(
+ in TextureSlice textureSlice,
+ Filter filter,
+ OSWindow window
+ )
+ {
+ Refresh.Refresh_QueuePresent(
+ Device.Handle,
+ Handle,
+ textureSlice.ToRefreshTextureSlice(),
+ IntPtr.Zero,
+ (Refresh.Filter) filter,
+ window.Handle
+ );
+ }
+
///
/// Prepares a texture to be presented to a window.
///
@@ -666,61 +757,24 @@ namespace MoonWorks.Graphics
}
///
- /// Prepares a texture slice to be presented to a window.
- /// This particular variant of this method will present to the entire window area.
+ /// Copies array data into a buffer.
///
- /// The texture slice to present.
- /// The filter to use when the texture size differs from the window size.
- public void QueuePresent(
- in TextureSlice textureSlice,
- Filter filter,
- OSWindow window
- )
+ /// The buffer to copy to.
+ /// The array to copy from.
+ /// Specifies where in the buffer to start copying.
+ /// Specifies whether the buffer should be copied in immediate or deferred mode. When in doubt, use deferred.
+ public unsafe void SetBufferData(
+ Buffer buffer,
+ T[] data,
+ uint bufferOffsetInBytes = 0
+ ) where T : unmanaged
{
- Refresh.Refresh_QueuePresent(
- Device.Handle,
- Handle,
- textureSlice.ToRefreshTextureSlice(),
- IntPtr.Zero,
- (Refresh.Filter) filter,
- window.Handle
- );
- }
-
- ///
- /// Prepares a texture to be presented to a window.
- /// This particular variant of this method will present to the entire window area.
- ///
- /// The texture to present.
- /// The filter to use when the texture size differs from the window size.
- public void QueuePresent(
- Texture texture,
- Filter filter,
- OSWindow window
- )
- {
- var refreshTextureSlice = new Refresh.TextureSlice
- {
- texture = texture.Handle,
- rectangle = new Refresh.Rect
- {
- x = 0,
- y = 0,
- w = (int) texture.Width,
- h = (int) texture.Height
- },
- layer = 0,
- level = 0,
- depth = 0
- };
-
- Refresh.Refresh_QueuePresent(
- Device.Handle,
- Handle,
- refreshTextureSlice,
- IntPtr.Zero,
- (Refresh.Filter) filter,
- window.Handle
+ SetBufferData(
+ buffer,
+ data,
+ bufferOffsetInBytes,
+ 0,
+ (uint) data.Length
);
}
@@ -783,58 +837,17 @@ namespace MoonWorks.Graphics
}
}
- ///
- /// Copies array data into a buffer.
- ///
- /// The buffer to copy to.
- /// The array to copy from.
- /// Specifies where in the buffer to start copying.
- /// Specifies whether the buffer should be copied in immediate or deferred mode. When in doubt, use deferred.
- public unsafe void SetBufferData(
- Buffer buffer,
- T[] data,
- uint bufferOffsetInBytes = 0
- ) where T : unmanaged
- {
- SetBufferData(
- buffer,
- data,
- bufferOffsetInBytes,
- 0,
- (uint) data.Length
- );
- }
-
///
/// Asynchronously copies data into a texture.
///
- /// The texture slice to copy into.
- /// A pointer to an array of data to copy from.
- /// The amount of data to copy from the array.
- public void SetTextureData(in TextureSlice textureSlice, IntPtr dataPtr, uint dataLengthInBytes)
+ /// An array of data to copy into the texture.
+ public unsafe void SetTextureData(Texture texture, T[] data) where T : unmanaged
{
- Refresh.Refresh_SetTextureData(
- Device.Handle,
- Handle,
- textureSlice.ToRefreshTextureSlice(),
- dataPtr,
- dataLengthInBytes
- );
+ SetTextureData(new TextureSlice(texture), data);
}
///
- /// Asynchronously copies data into a texture.
- /// This variant copies into the entire texture.
- ///
- /// A pointer to an array of data to copy from.
- /// The amount of data to copy from the array.
- public void SetTextureData(Texture texture, IntPtr dataPtr, uint dataLengthInBytes)
- {
- SetTextureData(new TextureSlice(texture), dataPtr, dataLengthInBytes);
- }
-
- ///
- /// Asynchronously copies data into the texture.
+ /// Asynchronously copies data into a texture slice.
///
/// The texture slice to copy into.
/// An array of data to copy into the texture.
@@ -855,13 +868,30 @@ namespace MoonWorks.Graphics
}
///
- /// Asynchronously copies data into a texture.
- /// This variant copies data into the entire texture.
+ /// Asynchronously copies data into a texture slice.
///
- /// An array of data to copy into the texture.
- public unsafe void SetTextureData(Texture texture, T[] data) where T : unmanaged
+ /// The texture slice to copy into.
+ /// A pointer to an array of data to copy from.
+ /// The amount of data to copy from the array.
+ public void SetTextureData(in TextureSlice textureSlice, IntPtr dataPtr, uint dataLengthInBytes)
{
- SetTextureData(new TextureSlice(texture), data);
+ Refresh.Refresh_SetTextureData(
+ Device.Handle,
+ Handle,
+ textureSlice.ToRefreshTextureSlice(),
+ dataPtr,
+ dataLengthInBytes
+ );
+ }
+
+ ///
+ /// Asynchronously copies data into a texture.
+ ///
+ /// A pointer to an array of data to copy from.
+ /// The amount of data to copy from the array.
+ public void SetTextureData(Texture texture, IntPtr dataPtr, uint dataLengthInBytes)
+ {
+ SetTextureData(new TextureSlice(texture), dataPtr, dataLengthInBytes);
}
///
diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs
index 59c499a..74f1a4f 100644
--- a/src/Graphics/GraphicsDevice.cs
+++ b/src/Graphics/GraphicsDevice.cs
@@ -16,8 +16,7 @@ namespace MoonWorks.Graphics
public GraphicsDevice(
IntPtr deviceWindowHandle,
Refresh.PresentMode presentMode,
- bool debugMode,
- int initialCommandBufferPoolSize = 4
+ bool debugMode
)
{
var presentationParameters = new Refresh.PresentationParameters
diff --git a/src/Graphics/Resources/Framebuffer.cs b/src/Graphics/Resources/Framebuffer.cs
index 5d3439f..223ee9c 100644
--- a/src/Graphics/Resources/Framebuffer.cs
+++ b/src/Graphics/Resources/Framebuffer.cs
@@ -17,6 +17,8 @@ namespace MoonWorks.Graphics
public IEnumerable ColorTargets => colorTargets;
public RenderPass RenderPass { get; }
+ public uint Width { get; }
+ public uint Height { get; }
///
/// Creates a framebuffer.
@@ -76,6 +78,9 @@ namespace MoonWorks.Graphics
}
RenderPass = renderPass;
+
+ Width = width;
+ Height = height;
}
}
}
diff --git a/src/Window/OSWindow.cs b/src/Window/OSWindow.cs
index c6feda5..c94ba3d 100644
--- a/src/Window/OSWindow.cs
+++ b/src/Window/OSWindow.cs
@@ -7,6 +7,8 @@ namespace MoonWorks.Window
{
internal IntPtr Handle { get; }
public ScreenMode ScreenMode { get; }
+ public uint Width { get; }
+ public uint Height { get; }
private bool IsDisposed;
@@ -33,6 +35,9 @@ namespace MoonWorks.Window
(int) windowCreateInfo.WindowHeight,
windowFlags
);
+
+ Width = windowCreateInfo.WindowWidth;
+ Height = windowCreateInfo.WindowHeight;
}
public void ChangeScreenMode(ScreenMode screenMode)