intellisense improvement + API tweak
parent
8973b3e658
commit
8a3d93d2dc
|
@ -22,6 +22,105 @@ namespace MoonWorks.Graphics
|
||||||
Handle = handle;
|
Handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderPass">The render pass object to begin.</param>
|
||||||
|
/// <param name="framebuffer">The framebuffer used by the render pass.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderPass">The render pass object to begin.</param>
|
||||||
|
/// <param name="framebuffer">The framebuffer used by the render pass.</param>
|
||||||
|
/// <param name="renderArea">The screen area of the render pass.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="renderPass">The render pass object to begin.</param>
|
||||||
|
/// <param name="framebuffer">The framebuffer used by the render pass.</param>
|
||||||
|
/// <param name="renderArea">The screen area of the render pass.</param>
|
||||||
|
/// <param name="clearColors">Color clear values for each render target in the framebuffer.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begins a render pass.
|
/// Begins a render pass.
|
||||||
/// All render state, resource binding, and draw commands must be made within 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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="renderPass">The render pass object to begin.</param>
|
|
||||||
/// <param name="framebuffer">The framebuffer used by the render pass.</param>
|
|
||||||
/// <param name="renderArea">The screen area of the render pass.</param>
|
|
||||||
/// <param name="clearColors">Color clear values for each render target in the framebuffer.</param>
|
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="renderPass">The render pass object to begin.</param>
|
|
||||||
/// <param name="framebuffer">The framebuffer used by the render pass.</param>
|
|
||||||
/// <param name="renderArea">The screen area of the render pass.</param>
|
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Binds a compute pipeline so that compute work may be dispatched.
|
/// Binds a compute pipeline so that compute work may be dispatched.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -600,6 +632,65 @@ namespace MoonWorks.Graphics
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prepares a texture to be presented to a window.
|
||||||
|
/// This particular variant of this method will present to the entire window area.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="texture">The texture to present.</param>
|
||||||
|
/// <param name="filter">The filter to use when the texture size differs from the window size.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prepares a texture slice to be presented to a window.
|
||||||
|
/// This particular variant of this method will present to the entire window area.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="textureSlice">The texture slice to present.</param>
|
||||||
|
/// <param name="filter">The filter to use when the texture size differs from the window size.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepares a texture to be presented to a window.
|
/// Prepares a texture to be presented to a window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -666,61 +757,24 @@ namespace MoonWorks.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepares a texture slice to be presented to a window.
|
/// Copies array data into a buffer.
|
||||||
/// This particular variant of this method will present to the entire window area.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="textureSlice">The texture slice to present.</param>
|
/// <param name="buffer">The buffer to copy to.</param>
|
||||||
/// <param name="filter">The filter to use when the texture size differs from the window size.</param>
|
/// <param name="data">The array to copy from.</param>
|
||||||
public void QueuePresent(
|
/// <param name="bufferOffsetInBytes">Specifies where in the buffer to start copying.</param>
|
||||||
in TextureSlice textureSlice,
|
/// <param name="setDataOption">Specifies whether the buffer should be copied in immediate or deferred mode. When in doubt, use deferred.</param>
|
||||||
Filter filter,
|
public unsafe void SetBufferData<T>(
|
||||||
OSWindow window
|
Buffer buffer,
|
||||||
)
|
T[] data,
|
||||||
|
uint bufferOffsetInBytes = 0
|
||||||
|
) where T : unmanaged
|
||||||
{
|
{
|
||||||
Refresh.Refresh_QueuePresent(
|
SetBufferData(
|
||||||
Device.Handle,
|
buffer,
|
||||||
Handle,
|
data,
|
||||||
textureSlice.ToRefreshTextureSlice(),
|
bufferOffsetInBytes,
|
||||||
IntPtr.Zero,
|
0,
|
||||||
(Refresh.Filter) filter,
|
(uint) data.Length
|
||||||
window.Handle
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prepares a texture to be presented to a window.
|
|
||||||
/// This particular variant of this method will present to the entire window area.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture">The texture to present.</param>
|
|
||||||
/// <param name="filter">The filter to use when the texture size differs from the window size.</param>
|
|
||||||
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
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,58 +837,17 @@ namespace MoonWorks.Graphics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Copies array data into a buffer.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="buffer">The buffer to copy to.</param>
|
|
||||||
/// <param name="data">The array to copy from.</param>
|
|
||||||
/// <param name="bufferOffsetInBytes">Specifies where in the buffer to start copying.</param>
|
|
||||||
/// <param name="setDataOption">Specifies whether the buffer should be copied in immediate or deferred mode. When in doubt, use deferred.</param>
|
|
||||||
public unsafe void SetBufferData<T>(
|
|
||||||
Buffer buffer,
|
|
||||||
T[] data,
|
|
||||||
uint bufferOffsetInBytes = 0
|
|
||||||
) where T : unmanaged
|
|
||||||
{
|
|
||||||
SetBufferData(
|
|
||||||
buffer,
|
|
||||||
data,
|
|
||||||
bufferOffsetInBytes,
|
|
||||||
0,
|
|
||||||
(uint) data.Length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously copies data into a texture.
|
/// Asynchronously copies data into a texture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="textureSlice">The texture slice to copy into.</param>
|
/// <param name="data">An array of data to copy into the texture.</param>
|
||||||
/// <param name="dataPtr">A pointer to an array of data to copy from.</param>
|
public unsafe void SetTextureData<T>(Texture texture, T[] data) where T : unmanaged
|
||||||
/// <param name="dataLengthInBytes">The amount of data to copy from the array.</param>
|
|
||||||
public void SetTextureData(in TextureSlice textureSlice, IntPtr dataPtr, uint dataLengthInBytes)
|
|
||||||
{
|
{
|
||||||
Refresh.Refresh_SetTextureData(
|
SetTextureData(new TextureSlice(texture), data);
|
||||||
Device.Handle,
|
|
||||||
Handle,
|
|
||||||
textureSlice.ToRefreshTextureSlice(),
|
|
||||||
dataPtr,
|
|
||||||
dataLengthInBytes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously copies data into a texture.
|
/// Asynchronously copies data into a texture slice.
|
||||||
/// This variant copies into the entire texture.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataPtr">A pointer to an array of data to copy from.</param>
|
|
||||||
/// <param name="dataLengthInBytes">The amount of data to copy from the array.</param>
|
|
||||||
public void SetTextureData(Texture texture, IntPtr dataPtr, uint dataLengthInBytes)
|
|
||||||
{
|
|
||||||
SetTextureData(new TextureSlice(texture), dataPtr, dataLengthInBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Asynchronously copies data into the texture.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="textureSlice">The texture slice to copy into.</param>
|
/// <param name="textureSlice">The texture slice to copy into.</param>
|
||||||
/// <param name="data">An array of data to copy into the texture.</param>
|
/// <param name="data">An array of data to copy into the texture.</param>
|
||||||
|
@ -855,13 +868,30 @@ namespace MoonWorks.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously copies data into a texture.
|
/// Asynchronously copies data into a texture slice.
|
||||||
/// This variant copies data into the entire texture.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">An array of data to copy into the texture.</param>
|
/// <param name="textureSlice">The texture slice to copy into.</param>
|
||||||
public unsafe void SetTextureData<T>(Texture texture, T[] data) where T : unmanaged
|
/// <param name="dataPtr">A pointer to an array of data to copy from.</param>
|
||||||
|
/// <param name="dataLengthInBytes">The amount of data to copy from the array.</param>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously copies data into a texture.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataPtr">A pointer to an array of data to copy from.</param>
|
||||||
|
/// <param name="dataLengthInBytes">The amount of data to copy from the array.</param>
|
||||||
|
public void SetTextureData(Texture texture, IntPtr dataPtr, uint dataLengthInBytes)
|
||||||
|
{
|
||||||
|
SetTextureData(new TextureSlice(texture), dataPtr, dataLengthInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -16,8 +16,7 @@ namespace MoonWorks.Graphics
|
||||||
public GraphicsDevice(
|
public GraphicsDevice(
|
||||||
IntPtr deviceWindowHandle,
|
IntPtr deviceWindowHandle,
|
||||||
Refresh.PresentMode presentMode,
|
Refresh.PresentMode presentMode,
|
||||||
bool debugMode,
|
bool debugMode
|
||||||
int initialCommandBufferPoolSize = 4
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var presentationParameters = new Refresh.PresentationParameters
|
var presentationParameters = new Refresh.PresentationParameters
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace MoonWorks.Graphics
|
||||||
public IEnumerable<RenderTarget> ColorTargets => colorTargets;
|
public IEnumerable<RenderTarget> ColorTargets => colorTargets;
|
||||||
|
|
||||||
public RenderPass RenderPass { get; }
|
public RenderPass RenderPass { get; }
|
||||||
|
public uint Width { get; }
|
||||||
|
public uint Height { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a framebuffer.
|
/// Creates a framebuffer.
|
||||||
|
@ -76,6 +78,9 @@ namespace MoonWorks.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPass = renderPass;
|
RenderPass = renderPass;
|
||||||
|
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace MoonWorks.Window
|
||||||
{
|
{
|
||||||
internal IntPtr Handle { get; }
|
internal IntPtr Handle { get; }
|
||||||
public ScreenMode ScreenMode { get; }
|
public ScreenMode ScreenMode { get; }
|
||||||
|
public uint Width { get; }
|
||||||
|
public uint Height { get; }
|
||||||
|
|
||||||
private bool IsDisposed;
|
private bool IsDisposed;
|
||||||
|
|
||||||
|
@ -33,6 +35,9 @@ namespace MoonWorks.Window
|
||||||
(int) windowCreateInfo.WindowHeight,
|
(int) windowCreateInfo.WindowHeight,
|
||||||
windowFlags
|
windowFlags
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Width = windowCreateInfo.WindowWidth;
|
||||||
|
Height = windowCreateInfo.WindowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeScreenMode(ScreenMode screenMode)
|
public void ChangeScreenMode(ScreenMode screenMode)
|
||||||
|
|
Loading…
Reference in New Issue