forked from MoonsideGames/MoonWorks
change refs + a SetData convenience method
parent
a6ea645e91
commit
db44c3e37a
|
@ -1 +1 @@
|
|||
Subproject commit ba183e8c0f9d21e4397d76941078b4969d4f6686
|
||||
Subproject commit 718aaad80ebf075192e05bf7af97241d7cf7e726
|
|
@ -19,8 +19,8 @@ namespace MoonWorks.Graphics
|
|||
public unsafe void BeginRenderPass(
|
||||
RenderPass renderPass,
|
||||
Framebuffer framebuffer,
|
||||
ref Rect renderArea,
|
||||
ref DepthStencilValue depthStencilClearValue,
|
||||
in Rect renderArea,
|
||||
in DepthStencilValue depthStencilClearValue,
|
||||
params Color[] clearColors
|
||||
) {
|
||||
var refreshRenderArea = renderArea.ToRefresh();
|
||||
|
@ -33,10 +33,10 @@ namespace MoonWorks.Graphics
|
|||
Handle,
|
||||
renderPass.Handle,
|
||||
framebuffer.Handle,
|
||||
ref refreshRenderArea,
|
||||
refreshRenderArea,
|
||||
(IntPtr) clearColorPtr,
|
||||
(uint)clearColors.Length,
|
||||
ref refreshDepthStencilClearValue
|
||||
refreshDepthStencilClearValue
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace MoonWorks.Graphics
|
|||
public unsafe void BeginRenderPass(
|
||||
RenderPass renderPass,
|
||||
Framebuffer framebuffer,
|
||||
ref Rect renderArea,
|
||||
in Rect renderArea,
|
||||
params Color[] clearColors
|
||||
) {
|
||||
var refreshRenderArea = renderArea.ToRefresh();
|
||||
|
@ -56,7 +56,7 @@ namespace MoonWorks.Graphics
|
|||
Handle,
|
||||
renderPass.Handle,
|
||||
framebuffer.Handle,
|
||||
ref refreshRenderArea,
|
||||
refreshRenderArea,
|
||||
(IntPtr) clearColorPtr,
|
||||
(uint) clearColors.Length,
|
||||
IntPtr.Zero
|
||||
|
@ -246,18 +246,18 @@ namespace MoonWorks.Graphics
|
|||
}
|
||||
|
||||
public void Clear(
|
||||
ref Refresh.Rect clearRect,
|
||||
in Refresh.Rect clearRect,
|
||||
Refresh.ClearOptionsFlags clearOptions,
|
||||
ref Refresh.Color[] colors,
|
||||
in Refresh.Color[] colors,
|
||||
float depth,
|
||||
int stencil
|
||||
) {
|
||||
Refresh.Refresh_Clear(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref clearRect,
|
||||
in clearRect,
|
||||
clearOptions,
|
||||
ref colors,
|
||||
in colors,
|
||||
(uint) colors.Length,
|
||||
depth,
|
||||
stencil
|
||||
|
@ -351,8 +351,8 @@ namespace MoonWorks.Graphics
|
|||
Refresh.Refresh_QueuePresent(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref refreshTextureSlice,
|
||||
ref refreshRect,
|
||||
refreshTextureSlice,
|
||||
refreshRect,
|
||||
(Refresh.Filter)filter
|
||||
);
|
||||
}
|
||||
|
@ -368,8 +368,8 @@ namespace MoonWorks.Graphics
|
|||
Refresh.Refresh_QueuePresent(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref refreshTextureSlice,
|
||||
ref refreshRect,
|
||||
refreshTextureSlice,
|
||||
refreshRect,
|
||||
(Refresh.Filter) filter
|
||||
);
|
||||
}
|
||||
|
@ -378,12 +378,10 @@ namespace MoonWorks.Graphics
|
|||
in TextureSlice textureSlice,
|
||||
Filter filter
|
||||
) {
|
||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||
|
||||
Refresh.Refresh_QueuePresent(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref refreshTextureSlice,
|
||||
textureSlice.ToRefreshTextureSlice(),
|
||||
IntPtr.Zero,
|
||||
(Refresh.Filter) filter
|
||||
);
|
||||
|
@ -411,7 +409,7 @@ namespace MoonWorks.Graphics
|
|||
Refresh.Refresh_QueuePresent(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref refreshTextureSlice,
|
||||
refreshTextureSlice,
|
||||
IntPtr.Zero,
|
||||
(Refresh.Filter) filter
|
||||
);
|
||||
|
@ -428,8 +426,8 @@ namespace MoonWorks.Graphics
|
|||
Refresh.Refresh_CopyTextureToTexture(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref sourceRefreshTextureSlice,
|
||||
ref destRefreshTextureSlice,
|
||||
sourceRefreshTextureSlice,
|
||||
destRefreshTextureSlice,
|
||||
(Refresh.Filter) filter
|
||||
);
|
||||
}
|
||||
|
@ -443,7 +441,7 @@ namespace MoonWorks.Graphics
|
|||
Refresh.Refresh_CopyTextureToBuffer(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
ref refreshTextureSlice,
|
||||
refreshTextureSlice,
|
||||
buffer.Handle
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace MoonWorks.Graphics
|
|||
};
|
||||
|
||||
Handle = Refresh.Refresh_CreateDevice(
|
||||
ref presentationParameters,
|
||||
presentationParameters,
|
||||
Conversions.BoolToByte(debugMode)
|
||||
);
|
||||
|
||||
|
|
|
@ -99,4 +99,31 @@ namespace MoonWorks.Graphics
|
|||
public LoadOp stencilLoadOp;
|
||||
public StoreOp stencilStoreOp;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct StencilOpState
|
||||
{
|
||||
public StencilOp failOp;
|
||||
public StencilOp passOp;
|
||||
public StencilOp depthFailOp;
|
||||
public CompareOp compareOp;
|
||||
public uint compareMask;
|
||||
public uint writeMask;
|
||||
public uint reference;
|
||||
|
||||
// FIXME: can we do an explicit cast here?
|
||||
public Refresh.StencilOpState ToRefresh()
|
||||
{
|
||||
return new Refresh.StencilOpState
|
||||
{
|
||||
failOp = (Refresh.StencilOp)failOp,
|
||||
passOp = (Refresh.StencilOp)passOp,
|
||||
depthFailOp = (Refresh.StencilOp)depthFailOp,
|
||||
compareOp = (Refresh.CompareOp)compareOp,
|
||||
compareMask = compareMask,
|
||||
writeMask = writeMask,
|
||||
reference = reference
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RefreshCS;
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
@ -38,6 +39,22 @@ namespace MoonWorks.Graphics
|
|||
}
|
||||
}
|
||||
|
||||
public unsafe void SetData<T>(
|
||||
T[] data
|
||||
) where T : unmanaged
|
||||
{
|
||||
fixed (T* ptr = &data[0])
|
||||
{
|
||||
Refresh.Refresh_SetBufferData(
|
||||
Device.Handle,
|
||||
Handle,
|
||||
0,
|
||||
(IntPtr)ptr,
|
||||
(uint) (data.Length * Marshal.SizeOf<T>())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SetData<T>(
|
||||
uint offsetInBytes,
|
||||
T* data,
|
||||
|
|
|
@ -40,11 +40,10 @@ namespace MoonWorks.Graphics
|
|||
|
||||
public ColorTarget(GraphicsDevice device, SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
|
||||
{
|
||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||
Handle = Refresh.Refresh_CreateColorTarget(
|
||||
device.Handle,
|
||||
(Refresh.SampleCount) sampleCount,
|
||||
ref refreshTextureSlice
|
||||
textureSlice.ToRefreshTextureSlice()
|
||||
);
|
||||
TextureSlice = textureSlice;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MoonWorks.Graphics
|
|||
|
||||
Handle = Refresh.Refresh_CreateComputePipeline(
|
||||
device.Handle,
|
||||
ref computePipelineCreateInfo
|
||||
computePipelineCreateInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace MoonWorks.Graphics
|
|||
renderPass = renderPass.Handle
|
||||
};
|
||||
|
||||
Handle = Refresh.Refresh_CreateFramebuffer(device.Handle, ref framebufferCreateInfo);
|
||||
Handle = Refresh.Refresh_CreateFramebuffer(device.Handle, framebufferCreateInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ namespace MoonWorks.Graphics
|
|||
graphicsPipelineCreateInfo.colorBlendState.blendConstants[2] = colorBlendState.BlendConstants.B;
|
||||
graphicsPipelineCreateInfo.colorBlendState.blendConstants[3] = colorBlendState.BlendConstants.A;
|
||||
|
||||
graphicsPipelineCreateInfo.depthStencilState.backStencilState = depthStencilState.BackStencilState;
|
||||
graphicsPipelineCreateInfo.depthStencilState.compareOp = depthStencilState.CompareOp;
|
||||
graphicsPipelineCreateInfo.depthStencilState.backStencilState = depthStencilState.BackStencilState.ToRefresh();
|
||||
graphicsPipelineCreateInfo.depthStencilState.compareOp = (Refresh.CompareOp) depthStencilState.CompareOp;
|
||||
graphicsPipelineCreateInfo.depthStencilState.depthBoundsTestEnable = Conversions.BoolToByte(depthStencilState.DepthBoundsTestEnable);
|
||||
graphicsPipelineCreateInfo.depthStencilState.depthTestEnable = Conversions.BoolToByte(depthStencilState.DepthTestEnable);
|
||||
graphicsPipelineCreateInfo.depthStencilState.depthWriteEnable = Conversions.BoolToByte(depthStencilState.DepthWriteEnable);
|
||||
graphicsPipelineCreateInfo.depthStencilState.frontStencilState = depthStencilState.FrontStencilState;
|
||||
graphicsPipelineCreateInfo.depthStencilState.frontStencilState = depthStencilState.FrontStencilState.ToRefresh();
|
||||
graphicsPipelineCreateInfo.depthStencilState.maxDepthBounds = depthStencilState.MaxDepthBounds;
|
||||
graphicsPipelineCreateInfo.depthStencilState.minDepthBounds = depthStencilState.MinDepthBounds;
|
||||
graphicsPipelineCreateInfo.depthStencilState.stencilTestEnable = Conversions.BoolToByte(depthStencilState.StencilTestEnable);
|
||||
|
@ -93,7 +93,7 @@ namespace MoonWorks.Graphics
|
|||
graphicsPipelineCreateInfo.primitiveType = (Refresh.PrimitiveType) primitiveType;
|
||||
graphicsPipelineCreateInfo.renderPass = renderPass.Handle;
|
||||
|
||||
Handle = Refresh.Refresh_CreateGraphicsPipeline(device.Handle, ref graphicsPipelineCreateInfo);
|
||||
Handle = Refresh.Refresh_CreateGraphicsPipeline(device.Handle, graphicsPipelineCreateInfo);
|
||||
|
||||
vertexAttributesHandle.Free();
|
||||
vertexBindingsHandle.Free();
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace MoonWorks.Graphics
|
|||
renderPassCreateInfo.colorTargetDescriptions = (IntPtr) ptr;
|
||||
renderPassCreateInfo.depthStencilTargetDescription = IntPtr.Zero;
|
||||
|
||||
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, ref renderPassCreateInfo);
|
||||
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace MoonWorks.Graphics
|
|||
renderPassCreateInfo.colorTargetDescriptions = (IntPtr)colorPtr;
|
||||
renderPassCreateInfo.depthStencilTargetDescription = (IntPtr) depthStencilPtr;
|
||||
|
||||
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, ref renderPassCreateInfo);
|
||||
Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,9 @@ namespace MoonWorks.Graphics
|
|||
ref SamplerState samplerState
|
||||
) : base(device)
|
||||
{
|
||||
var refreshSamplerStateCreateInfo = samplerState.ToRefreshSamplerStateCreateInfo();
|
||||
|
||||
Handle = Refresh.Refresh_CreateSampler(
|
||||
device.Handle,
|
||||
ref refreshSamplerStateCreateInfo
|
||||
samplerState.ToRefreshSamplerStateCreateInfo()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MoonWorks.Graphics
|
|||
shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length;
|
||||
shaderModuleCreateInfo.byteCode = (IntPtr) ptr;
|
||||
|
||||
Handle = Refresh.Refresh_CreateShaderModule(device.Handle, ref shaderModuleCreateInfo);
|
||||
Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,11 +124,9 @@ namespace MoonWorks.Graphics
|
|||
|
||||
public Texture(GraphicsDevice device, ref TextureCreateInfo textureCreateInfo) : base(device)
|
||||
{
|
||||
var refreshTextureCreateInfo = textureCreateInfo.ToRefreshTextureCreateInfo();
|
||||
|
||||
Handle = Refresh.Refresh_CreateTexture(
|
||||
device.Handle,
|
||||
ref refreshTextureCreateInfo
|
||||
textureCreateInfo.ToRefreshTextureCreateInfo()
|
||||
);
|
||||
|
||||
Format = textureCreateInfo.Format;
|
||||
|
@ -150,7 +148,7 @@ namespace MoonWorks.Graphics
|
|||
|
||||
Refresh.Refresh_SetTextureData(
|
||||
Device.Handle,
|
||||
ref textureSlice,
|
||||
textureSlice,
|
||||
data,
|
||||
dataLengthInBytes
|
||||
);
|
||||
|
@ -162,7 +160,7 @@ namespace MoonWorks.Graphics
|
|||
|
||||
Refresh.Refresh_SetTextureData(
|
||||
Device.Handle,
|
||||
ref refreshTextureSlice,
|
||||
refreshTextureSlice,
|
||||
data,
|
||||
dataLengthInBytes
|
||||
);
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace MoonWorks.Graphics
|
|||
public struct DepthStencilState
|
||||
{
|
||||
public bool DepthTestEnable;
|
||||
public Refresh.StencilOpState BackStencilState;
|
||||
public Refresh.StencilOpState FrontStencilState;
|
||||
public Refresh.CompareOp CompareOp;
|
||||
public StencilOpState BackStencilState;
|
||||
public StencilOpState FrontStencilState;
|
||||
public CompareOp CompareOp;
|
||||
public bool DepthBoundsTestEnable;
|
||||
public bool DepthWriteEnable;
|
||||
public float MinDepthBounds;
|
||||
|
@ -20,7 +20,7 @@ namespace MoonWorks.Graphics
|
|||
DepthWriteEnable = true,
|
||||
DepthBoundsTestEnable = false,
|
||||
StencilTestEnable = false,
|
||||
CompareOp = Refresh.CompareOp.LessOrEqual
|
||||
CompareOp = CompareOp.LessOrEqual
|
||||
};
|
||||
|
||||
public static readonly DepthStencilState DepthRead = new DepthStencilState
|
||||
|
@ -29,7 +29,7 @@ namespace MoonWorks.Graphics
|
|||
DepthWriteEnable = false,
|
||||
DepthBoundsTestEnable = false,
|
||||
StencilTestEnable = false,
|
||||
CompareOp = Refresh.CompareOp.LessOrEqual
|
||||
CompareOp = CompareOp.LessOrEqual
|
||||
};
|
||||
|
||||
public static readonly DepthStencilState Disable = new DepthStencilState
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MoonWorks.Graphics
|
|||
public Refresh.FrontFace FrontFace;
|
||||
public float LineWidth;
|
||||
|
||||
public static readonly RasterizerState CullClockwise = new RasterizerState
|
||||
public static readonly RasterizerState CW_CullFront = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.Front,
|
||||
FrontFace = Refresh.FrontFace.Clockwise,
|
||||
|
@ -23,7 +23,7 @@ namespace MoonWorks.Graphics
|
|||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CullCounterClockwise = new RasterizerState
|
||||
public static readonly RasterizerState CW_CullBack = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.Back,
|
||||
FrontFace = Refresh.FrontFace.Clockwise,
|
||||
|
@ -32,7 +32,7 @@ namespace MoonWorks.Graphics
|
|||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CullNone = new RasterizerState
|
||||
public static readonly RasterizerState CW_CullNone = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.None,
|
||||
FrontFace = Refresh.FrontFace.Clockwise,
|
||||
|
@ -41,7 +41,7 @@ namespace MoonWorks.Graphics
|
|||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState Wireframe = new RasterizerState
|
||||
public static readonly RasterizerState CW_Wireframe = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.None,
|
||||
FrontFace = Refresh.FrontFace.Clockwise,
|
||||
|
@ -49,5 +49,41 @@ namespace MoonWorks.Graphics
|
|||
DepthBiasEnable = false,
|
||||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CCW_CullFront = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.Front,
|
||||
FrontFace = Refresh.FrontFace.CounterClockwise,
|
||||
FillMode = Refresh.FillMode.Fill,
|
||||
DepthBiasEnable = false,
|
||||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CCW_CullBack = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.Back,
|
||||
FrontFace = Refresh.FrontFace.CounterClockwise,
|
||||
FillMode = Refresh.FillMode.Fill,
|
||||
DepthBiasEnable = false,
|
||||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CCW_CullNone = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.None,
|
||||
FrontFace = Refresh.FrontFace.CounterClockwise,
|
||||
FillMode = Refresh.FillMode.Fill,
|
||||
DepthBiasEnable = false,
|
||||
LineWidth = 1f
|
||||
};
|
||||
|
||||
public static readonly RasterizerState CCW_Wireframe = new RasterizerState
|
||||
{
|
||||
CullMode = Refresh.CullMode.None,
|
||||
FrontFace = Refresh.FrontFace.CounterClockwise,
|
||||
FillMode = Refresh.FillMode.Fill,
|
||||
DepthBiasEnable = false,
|
||||
LineWidth = 1f
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue