diff --git a/src/Audio/StreamingSound.cs b/src/Audio/StreamingSound.cs index 4fa1cf9..df2c765 100644 --- a/src/Audio/StreamingSound.cs +++ b/src/Audio/StreamingSound.cs @@ -5,7 +5,8 @@ using System.Runtime.InteropServices; namespace MoonWorks.Audio { /// - /// For streaming long playback. Reads an OGG file. + /// For streaming long playback. + /// Can be extended to support custom decoders. /// public abstract class StreamingSound : SoundInstance { diff --git a/src/Graphics/BufferBinding.cs b/src/Graphics/Bindings/BufferBinding.cs similarity index 100% rename from src/Graphics/BufferBinding.cs rename to src/Graphics/Bindings/BufferBinding.cs diff --git a/src/Graphics/TextureSamplerBinding.cs b/src/Graphics/Bindings/TextureSamplerBinding.cs similarity index 100% rename from src/Graphics/TextureSamplerBinding.cs rename to src/Graphics/Bindings/TextureSamplerBinding.cs diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 7448380..316b762 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -19,21 +19,24 @@ namespace MoonWorks.Graphics public unsafe void BeginRenderPass( RenderPass renderPass, Framebuffer framebuffer, - ref Refresh.Rect renderArea, - ref Refresh.DepthStencilValue depthStencilClearValue, - params Refresh.Color[] clearColors + ref Rect renderArea, + ref DepthStencilValue depthStencilClearValue, + params Color[] clearColors ) { - fixed (Refresh.Color* clearColorPtr = &clearColors[0]) + var refreshRenderArea = renderArea.ToRefresh(); + var refreshDepthStencilClearValue = depthStencilClearValue.ToRefresh(); + + fixed (Color* clearColorPtr = &clearColors[0]) { Refresh.Refresh_BeginRenderPass( Device.Handle, Handle, renderPass.Handle, framebuffer.Handle, - ref renderArea, + ref refreshRenderArea, (IntPtr) clearColorPtr, (uint)clearColors.Length, - ref depthStencilClearValue + ref refreshDepthStencilClearValue ); } } @@ -41,17 +44,19 @@ namespace MoonWorks.Graphics public unsafe void BeginRenderPass( RenderPass renderPass, Framebuffer framebuffer, - ref Refresh.Rect renderArea, - params Refresh.Color[] clearColors + ref Rect renderArea, + params Color[] clearColors ) { - fixed (Refresh.Color* clearColorPtr = &clearColors[0]) + var refreshRenderArea = renderArea.ToRefresh(); + + fixed (Color* clearColorPtr = &clearColors[0]) { Refresh.Refresh_BeginRenderPass( Device.Handle, Handle, renderPass.Handle, framebuffer.Handle, - ref renderArea, + ref refreshRenderArea, (IntPtr) clearColorPtr, (uint) clearColors.Length, IntPtr.Zero @@ -323,23 +328,24 @@ namespace MoonWorks.Graphics public void QueuePresent( ref TextureSlice textureSlice, - ref Refresh.Rect destinationRectangle, - Refresh.Filter filter + ref Rect destinationRectangle, + Filter filter ) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); + var refreshRect = destinationRectangle.ToRefresh(); Refresh.Refresh_QueuePresent( Device.Handle, Handle, ref refreshTextureSlice, - ref destinationRectangle, - filter + ref refreshRect, + (Refresh.Filter) filter ); } public void QueuePresent( ref TextureSlice textureSlice, - Refresh.Filter filter + Filter filter ) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); @@ -348,13 +354,13 @@ namespace MoonWorks.Graphics Handle, ref refreshTextureSlice, IntPtr.Zero, - filter + (Refresh.Filter) filter ); } public void QueuePresent( Texture texture, - Refresh.Filter filter + Filter filter ) { var refreshTextureSlice = new Refresh.TextureSlice { @@ -376,14 +382,14 @@ namespace MoonWorks.Graphics Handle, ref refreshTextureSlice, IntPtr.Zero, - filter + (Refresh.Filter) filter ); } public void CopyTextureToTexture( ref TextureSlice sourceTextureSlice, ref TextureSlice destinationTextureSlice, - Refresh.Filter filter + Filter filter ) { var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice(); var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice(); @@ -393,7 +399,7 @@ namespace MoonWorks.Graphics Handle, ref sourceRefreshTextureSlice, ref destRefreshTextureSlice, - filter + (Refresh.Filter) filter ); } diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs new file mode 100644 index 0000000..9a0da9b --- /dev/null +++ b/src/Graphics/RefreshEnums.cs @@ -0,0 +1,298 @@ +using System; + +/* Recreate all the enums in here so we don't need to explicitly + * reference the RefreshCS namespace when using MoonWorks.Graphics + */ +namespace MoonWorks.Graphics +{ + public enum PresentMode + { + Immediate, + Mailbox, + FIFO, + FIFORelaxed + } + + public enum PrimitiveType + { + PointList, + LineList, + LineStrip, + TriangleList, + TriangleStrip + } + + public enum LoadOp + { + Load, + Clear, + DontCare + } + + public enum StoreOp + { + Store, + DontCare + } + + [Flags] + public enum ClearOptionsFlags : uint + { + Color = 1, + Depth = 2, + Stencil = 4, + DepthStencil = Depth | Stencil, + All = Color | Depth | Stencil + } + + public enum IndexElementSize + { + Sixteen, + ThirtyTwo + } + + public enum ColorFormat + { + R8G8B8A8, + R5G6B5, + A1R5G5B5, + B4G4R4A4, + BC1, + BC2, + BC3, + R8G8_SNORM, + R8G8B8A8_SNORM, + A2R10G10B10, + R16G16, + R16G16B16A16, + R8, + R32_SFLOAT, + R32G32_SFLOAT, + R32G32B32A32_SFLOAT, + R16_SFLOAT, + R16G16_SFLOAT, + R16G16B16A16_SFLOAT + } + + public enum DepthFormat + { + Depth16, + Depth32, + Depth16Stencil8, + Depth32Stencil8 + } + + [Flags] + public enum TextureUsageFlags : uint + { + SamplerBit = 1, + ColorTargetBit = 2 + } + + public enum SampleCount + { + One, + Two, + Four, + Eight, + Sixteen, + ThirtyTwo, + SixtyFour + } + + public enum CubeMapFace + { + PositiveX, + NegativeX, + PositiveY, + NegativeY, + PositiveZ, + NegativeZ + } + + [Flags] + public enum BufferUsageFlags : uint + { + Vertex = 1, + Index = 2, + Compute = 4 + } + + public enum VertexElementFormat + { + Single, + Vector2, + Vector3, + Vector4, + Color, + Byte4, + Short2, + Short4, + NormalizedShort2, + NormalizedShort4, + HalfVector2, + HalfVector4 + } + + public enum VertexInputRate + { + Vertex, + Instance + } + + public enum FillMode + { + Fill, + Line, + Point + } + + public enum CullMode + { + None, + Front, + Back, + FrontAndBack + } + + public enum FrontFace + { + CounterClockwise, + Clockwise + } + + public enum CompareOp + { + Never, + Less, + Equal, + LessOrEqual, + Greater, + NotEqual, + GreaterOrEqual, + Always + } + + public enum StencilOp + { + Keep, + Zero, + Replace, + IncrementAndClamp, + DecrementAndClamp, + Invert, + IncrementAndWrap, + DecrementAndWrap + } + + public enum BlendOp + { + Add, + Subtract, + ReverseSubtract, + Min, + Max + } + + public enum LogicOp + { + Clear, + And, + AndReverse, + Copy, + AndInverted, + NoOp, + Xor, + Or, + Nor, + Equivalent, + Invert, + OrReverse, + CopyInverted, + OrInverted, + Nand, + Set + } + + public enum BlendFactor + { + Zero, + One, + SourceColor, + OneMinusSourceColor, + DestinationColor, + OneMinusDestinationColor, + SourceAlpha, + OneMinusSourceAlpha, + DestinationAlpha, + OneMinusDestinationAlpha, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha, + SourceAlphaSaturate, + SourceOneColor, + OneMinusSourceOneColor, + SourceOneAlpha, + OneMinusSourceOneAlpha + } + + [Flags] + public enum ColorComponentFlags : uint + { + R = 1, + G = 2, + B = 4, + A = 8, + + RG = R | G, + RB = R | B, + RA = R | A, + GB = G | B, + GA = G | A, + BA = B | A, + + RGB = R | G | B, + RGA = R | G | A, + GBA = G | B | A, + + RGBA = R | G | B | A + } + + public enum ShaderStageType + { + Vertex, + Fragment + } + + public enum Filter + { + Nearest, + Linear, + Cubic + } + + public enum SamplerMipmapMode + { + Nearest, + Linear + } + + public enum SamplerAddressMode + { + Repeat, + MirroredRepeat, + ClampToEdge, + ClampToBorder + } + + public enum BorderColor + { + FloatTransparentBlack, + IntTransparentBlack, + FloatOpaqueBlack, + IntOpaqueBlack, + FloatOpaqueWhite, + IntOpaqueWhite + } +} diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs new file mode 100644 index 0000000..355d71b --- /dev/null +++ b/src/Graphics/RefreshStructs.cs @@ -0,0 +1,111 @@ +using RefreshCS; +using System.Runtime.InteropServices; + +/* Recreate some structs in here so we don't need to explicitly + * reference the RefreshCS namespace when using MoonWorks.Graphics + */ +namespace MoonWorks.Graphics +{ + [StructLayout(LayoutKind.Sequential)] + public struct Color + { + public byte r; + public byte g; + public byte b; + public byte a; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DepthStencilValue + { + public float depth; + public uint stencil; + + // FIXME: can we do an unsafe cast somehow? + public Refresh.DepthStencilValue ToRefresh() + { + return new Refresh.DepthStencilValue + { + depth = depth, + stencil = stencil + }; + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct Rect + { + public int x; + public int y; + public int w; + public int h; + + // FIXME: can we do an unsafe cast somehow? + public Refresh.Rect ToRefresh() + { + return new Refresh.Rect + { + x = x, + y = y, + w = w, + h = h + }; + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct Vec4 + { + public float x; + public float y; + public float z; + public float w; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Viewport + { + public float x; + public float y; + public float w; + public float h; + public float minDepth; + public float maxDepth; + } + + [StructLayout(LayoutKind.Sequential)] + public struct VertexBinding + { + public uint binding; + public uint stride; + public VertexInputRate inputRate; + } + + [StructLayout(LayoutKind.Sequential)] + public struct VertexAttribute + { + public uint location; + public uint binding; + public VertexElementFormat format; + public uint offset; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ColorTargetDescription + { + public ColorFormat format; + public SampleCount multisampleCount; + public LoadOp loadOp; + public StoreOp storeOp; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DepthStencilTargetDescription + { + public DepthFormat depthFormat; + public LoadOp loadOp; + public StoreOp storeOp; + public LoadOp stencilLoadOp; + public StoreOp stencilStoreOp; + } +} diff --git a/src/Graphics/Buffer.cs b/src/Graphics/Resources/Buffer.cs similarity index 95% rename from src/Graphics/Buffer.cs rename to src/Graphics/Resources/Buffer.cs index a53a850..0ab08de 100644 --- a/src/Graphics/Buffer.cs +++ b/src/Graphics/Resources/Buffer.cs @@ -9,13 +9,13 @@ namespace MoonWorks.Graphics public Buffer( GraphicsDevice device, - Refresh.BufferUsageFlags usageFlags, + BufferUsageFlags usageFlags, uint sizeInBytes ) : base(device) { Handle = Refresh.Refresh_CreateBuffer( device.Handle, - usageFlags, + (Refresh.BufferUsageFlags) usageFlags, sizeInBytes ); } diff --git a/src/Graphics/ColorTarget.cs b/src/Graphics/Resources/ColorTarget.cs similarity index 64% rename from src/Graphics/ColorTarget.cs rename to src/Graphics/Resources/ColorTarget.cs index 25fd22a..84fd208 100644 --- a/src/Graphics/ColorTarget.cs +++ b/src/Graphics/Resources/ColorTarget.cs @@ -9,7 +9,7 @@ namespace MoonWorks.Graphics public uint Height { get; } public Texture Texture { get; } - public Refresh.ColorFormat Format => Texture.Format; + public ColorFormat Format => Texture.Format; protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget; @@ -17,14 +17,14 @@ namespace MoonWorks.Graphics GraphicsDevice device, uint width, uint height, - Refresh.ColorFormat format, + ColorFormat format, bool canBeSampled, - Refresh.SampleCount sampleCount = Refresh.SampleCount.One, + SampleCount sampleCount = SampleCount.One, uint levelCount = 1 ) { - var flags = Refresh.TextureUsageFlags.ColorTargetBit; - if (canBeSampled) { flags |= Refresh.TextureUsageFlags.SamplerBit; } + var flags = TextureUsageFlags.ColorTargetBit; + if (canBeSampled) { flags |= TextureUsageFlags.SamplerBit; } var texture = Texture.CreateTexture2D( device, @@ -41,10 +41,14 @@ namespace MoonWorks.Graphics return new ColorTarget(device, sampleCount, ref textureSlice); } - public ColorTarget(GraphicsDevice device, Refresh.SampleCount sampleCount, ref TextureSlice textureSlice) : base(device) + public ColorTarget(GraphicsDevice device, SampleCount sampleCount, ref TextureSlice textureSlice) : base(device) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); - Handle = Refresh.Refresh_CreateColorTarget(device.Handle, sampleCount, ref refreshTextureSlice); + Handle = Refresh.Refresh_CreateColorTarget( + device.Handle, + (Refresh.SampleCount) sampleCount, + ref refreshTextureSlice + ); } } } diff --git a/src/Graphics/ComputePipeline.cs b/src/Graphics/Resources/ComputePipeline.cs similarity index 100% rename from src/Graphics/ComputePipeline.cs rename to src/Graphics/Resources/ComputePipeline.cs diff --git a/src/Graphics/DepthStencilTarget.cs b/src/Graphics/Resources/DepthStencilTarget.cs similarity index 63% rename from src/Graphics/DepthStencilTarget.cs rename to src/Graphics/Resources/DepthStencilTarget.cs index e123680..5d093e0 100644 --- a/src/Graphics/DepthStencilTarget.cs +++ b/src/Graphics/Resources/DepthStencilTarget.cs @@ -7,7 +7,7 @@ namespace MoonWorks.Graphics { public uint Width { get; } public uint Height { get; } - public Refresh.DepthFormat Format { get; } + public DepthFormat Format { get; } protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget; @@ -15,12 +15,18 @@ namespace MoonWorks.Graphics GraphicsDevice device, uint width, uint height, - Refresh.DepthFormat depthFormat + DepthFormat depthFormat ) : base(device) { - Handle = Refresh.Refresh_CreateDepthStencilTarget(device.Handle, width, height, depthFormat); + Handle = Refresh.Refresh_CreateDepthStencilTarget( + device.Handle, + width, + height, + (Refresh.DepthFormat) depthFormat + ); Width = width; Height = height; + Format = depthFormat; } } } diff --git a/src/Graphics/Framebuffer.cs b/src/Graphics/Resources/Framebuffer.cs similarity index 100% rename from src/Graphics/Framebuffer.cs rename to src/Graphics/Resources/Framebuffer.cs diff --git a/src/Graphics/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs similarity index 97% rename from src/Graphics/GraphicsPipeline.cs rename to src/Graphics/Resources/GraphicsPipeline.cs index d83c0b3..087c726 100644 --- a/src/Graphics/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -17,7 +17,7 @@ namespace MoonWorks.Graphics MultisampleState multisampleState, GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo, RasterizerState rasterizerState, - Refresh.PrimitiveType primitiveType, + PrimitiveType primitiveType, VertexInputState vertexInputState, ViewportState viewportState, RenderPass renderPass @@ -38,7 +38,7 @@ namespace MoonWorks.Graphics Refresh.GraphicsPipelineCreateInfo graphicsPipelineCreateInfo; graphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable); - graphicsPipelineCreateInfo.colorBlendState.logicOp = colorBlendState.LogicOp; + graphicsPipelineCreateInfo.colorBlendState.logicOp = (Refresh.LogicOp) colorBlendState.LogicOp; graphicsPipelineCreateInfo.colorBlendState.blendStates = (IntPtr) colorTargetBlendStates; graphicsPipelineCreateInfo.colorBlendState.blendStateCount = (uint) colorBlendState.ColorTargetBlendStates.Length; graphicsPipelineCreateInfo.colorBlendState.blendConstants[0] = colorBlendState.BlendConstants.R; @@ -90,7 +90,7 @@ namespace MoonWorks.Graphics graphicsPipelineCreateInfo.viewportState.scissors = scissorHandle.AddrOfPinnedObject(); graphicsPipelineCreateInfo.viewportState.scissorCount = (uint) viewportState.Scissors.Length; - graphicsPipelineCreateInfo.primitiveType = primitiveType; + graphicsPipelineCreateInfo.primitiveType = (Refresh.PrimitiveType) primitiveType; graphicsPipelineCreateInfo.renderPass = renderPass.Handle; Handle = Refresh.Refresh_CreateGraphicsPipeline(device.Handle, ref graphicsPipelineCreateInfo); diff --git a/src/Graphics/RenderPass.cs b/src/Graphics/Resources/RenderPass.cs similarity index 73% rename from src/Graphics/RenderPass.cs rename to src/Graphics/Resources/RenderPass.cs index c8c123b..512a117 100644 --- a/src/Graphics/RenderPass.cs +++ b/src/Graphics/Resources/RenderPass.cs @@ -9,10 +9,10 @@ namespace MoonWorks.Graphics public unsafe RenderPass( GraphicsDevice device, - params Refresh.ColorTargetDescription[] colorTargetDescriptions + params ColorTargetDescription[] colorTargetDescriptions ) : base(device) { - fixed (Refresh.ColorTargetDescription* ptr = colorTargetDescriptions) + fixed (ColorTargetDescription* ptr = colorTargetDescriptions) { Refresh.RenderPassCreateInfo renderPassCreateInfo; renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length; @@ -25,13 +25,13 @@ namespace MoonWorks.Graphics public unsafe RenderPass( GraphicsDevice device, - Refresh.DepthStencilTargetDescription depthStencilTargetDescription, - params Refresh.ColorTargetDescription[] colorTargetDescriptions + DepthStencilTargetDescription depthStencilTargetDescription, + params ColorTargetDescription[] colorTargetDescriptions ) : base(device) { - Refresh.DepthStencilTargetDescription* depthStencilPtr = &depthStencilTargetDescription; + DepthStencilTargetDescription* depthStencilPtr = &depthStencilTargetDescription; - fixed (Refresh.ColorTargetDescription* colorPtr = colorTargetDescriptions) + fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions) { Refresh.RenderPassCreateInfo renderPassCreateInfo; renderPassCreateInfo.colorTargetCount = (uint)colorTargetDescriptions.Length; diff --git a/src/Graphics/Sampler.cs b/src/Graphics/Resources/Sampler.cs similarity index 100% rename from src/Graphics/Sampler.cs rename to src/Graphics/Resources/Sampler.cs diff --git a/src/Graphics/ShaderModule.cs b/src/Graphics/Resources/ShaderModule.cs similarity index 90% rename from src/Graphics/ShaderModule.cs rename to src/Graphics/Resources/ShaderModule.cs index 2892bd0..308c51e 100644 --- a/src/Graphics/ShaderModule.cs +++ b/src/Graphics/Resources/ShaderModule.cs @@ -10,7 +10,7 @@ namespace MoonWorks.Graphics public unsafe ShaderModule(GraphicsDevice device, FileInfo fileInfo) : base(device) { - fixed (uint* ptr = Bytecode.ReadBytecode(fileInfo)) + fixed (uint* ptr = Bytecode.ReadBytecodeAsUInt32(fileInfo)) { Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo; shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length; diff --git a/src/Graphics/Texture.cs b/src/Graphics/Resources/Texture.cs similarity index 79% rename from src/Graphics/Texture.cs rename to src/Graphics/Resources/Texture.cs index 573a84c..616eb62 100644 --- a/src/Graphics/Texture.cs +++ b/src/Graphics/Resources/Texture.cs @@ -8,7 +8,7 @@ namespace MoonWorks.Graphics { public uint Width { get; } public uint Height { get; } - public Refresh.ColorFormat Format { get; } + public ColorFormat Format { get; } protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture; @@ -21,15 +21,15 @@ namespace MoonWorks.Graphics out var channels ); - MoonWorks.Graphics.TextureCreateInfo textureCreateInfo; + TextureCreateInfo textureCreateInfo; textureCreateInfo.Width = (uint)width; textureCreateInfo.Height = (uint)height; textureCreateInfo.Depth = 1; - textureCreateInfo.Format = Refresh.ColorFormat.R8G8B8A8; + textureCreateInfo.Format = ColorFormat.R8G8B8A8; textureCreateInfo.IsCube = false; textureCreateInfo.LevelCount = 1; - textureCreateInfo.SampleCount = Refresh.SampleCount.One; - textureCreateInfo.UsageFlags = Refresh.TextureUsageFlags.SamplerBit; + textureCreateInfo.SampleCount = SampleCount.One; + textureCreateInfo.UsageFlags = TextureUsageFlags.SamplerBit; var texture = new Texture(device, ref textureCreateInfo); @@ -51,13 +51,13 @@ namespace MoonWorks.Graphics GraphicsDevice device, uint width, uint height, - Refresh.ColorFormat format, - Refresh.TextureUsageFlags usageFlags, - Refresh.SampleCount sampleCount = Refresh.SampleCount.One, + ColorFormat format, + TextureUsageFlags usageFlags, + SampleCount sampleCount = SampleCount.One, uint levelCount = 1 ) { - var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo + var textureCreateInfo = new TextureCreateInfo { Width = width, Height = height, @@ -77,13 +77,13 @@ namespace MoonWorks.Graphics uint width, uint height, uint depth, - Refresh.ColorFormat format, - Refresh.TextureUsageFlags usageFlags, - Refresh.SampleCount sampleCount = Refresh.SampleCount.One, + ColorFormat format, + TextureUsageFlags usageFlags, + SampleCount sampleCount = SampleCount.One, uint levelCount = 1 ) { - var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo + var textureCreateInfo = new TextureCreateInfo { Width = width, Height = height, @@ -101,13 +101,13 @@ namespace MoonWorks.Graphics public static Texture CreateTextureCube( GraphicsDevice device, uint size, - Refresh.ColorFormat format, - Refresh.TextureUsageFlags usageFlags, - Refresh.SampleCount sampleCount = Refresh.SampleCount.One, + ColorFormat format, + TextureUsageFlags usageFlags, + SampleCount sampleCount = SampleCount.One, uint levelCount = 1 ) { - var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo + var textureCreateInfo = new TextureCreateInfo { Width = size, Height = size, @@ -122,7 +122,7 @@ namespace MoonWorks.Graphics return new Texture(device, ref textureCreateInfo); } - public Texture(GraphicsDevice device, ref MoonWorks.Graphics.TextureCreateInfo textureCreateInfo) : base(device) + public Texture(GraphicsDevice device, ref TextureCreateInfo textureCreateInfo) : base(device) { var refreshTextureCreateInfo = textureCreateInfo.ToRefreshTextureCreateInfo(); diff --git a/src/Graphics/State/ColorBlendState.cs b/src/Graphics/State/ColorBlendState.cs index c0b54b1..fd785db 100644 --- a/src/Graphics/State/ColorBlendState.cs +++ b/src/Graphics/State/ColorBlendState.cs @@ -5,7 +5,7 @@ namespace MoonWorks.Graphics public unsafe struct ColorBlendState { public bool LogicOpEnable; - public Refresh.LogicOp LogicOp; + public LogicOp LogicOp; public BlendConstants BlendConstants; public ColorTargetBlendState[] ColorTargetBlendStates; } diff --git a/src/Graphics/State/TextureCreateInfo.cs b/src/Graphics/State/TextureCreateInfo.cs index 4e8512a..3cf93da 100644 --- a/src/Graphics/State/TextureCreateInfo.cs +++ b/src/Graphics/State/TextureCreateInfo.cs @@ -8,10 +8,10 @@ namespace MoonWorks.Graphics public uint Height; public uint Depth; public bool IsCube; - public Refresh.SampleCount SampleCount; + public SampleCount SampleCount; public uint LevelCount; - public Refresh.ColorFormat Format; - public Refresh.TextureUsageFlags UsageFlags; + public ColorFormat Format; + public TextureUsageFlags UsageFlags; public Refresh.TextureCreateInfo ToRefreshTextureCreateInfo() { @@ -21,10 +21,10 @@ namespace MoonWorks.Graphics height = Height, depth = Depth, isCube = Conversions.BoolToByte(IsCube), - sampleCount = SampleCount, + sampleCount = (Refresh.SampleCount) SampleCount, levelCount = LevelCount, - format = Format, - usageFlags = UsageFlags + format = (Refresh.ColorFormat) Format, + usageFlags = (Refresh.TextureUsageFlags) UsageFlags }; } } diff --git a/src/Graphics/State/VertexInputState.cs b/src/Graphics/State/VertexInputState.cs index 070a3bc..f106c1d 100644 --- a/src/Graphics/State/VertexInputState.cs +++ b/src/Graphics/State/VertexInputState.cs @@ -4,7 +4,7 @@ namespace MoonWorks.Graphics { public struct VertexInputState { - public Refresh.VertexBinding[] VertexBindings; - public Refresh.VertexAttribute[] VertexAttributes; + public VertexBinding[] VertexBindings; + public VertexAttribute[] VertexAttributes; } } diff --git a/src/Graphics/State/ViewportState.cs b/src/Graphics/State/ViewportState.cs index 8ba36fb..bc84a59 100644 --- a/src/Graphics/State/ViewportState.cs +++ b/src/Graphics/State/ViewportState.cs @@ -4,7 +4,7 @@ namespace MoonWorks.Graphics { public struct ViewportState { - public Refresh.Viewport[] Viewports; - public Refresh.Rect[] Scissors; + public Viewport[] Viewports; + public Rect[] Scissors; } } diff --git a/src/Graphics/BlendConstants.cs b/src/Graphics/Structs/BlendConstants.cs similarity index 100% rename from src/Graphics/BlendConstants.cs rename to src/Graphics/Structs/BlendConstants.cs diff --git a/src/Graphics/TextureSlice.cs b/src/Graphics/TextureSlice.cs index 9b0fb7b..843a26f 100644 --- a/src/Graphics/TextureSlice.cs +++ b/src/Graphics/TextureSlice.cs @@ -34,9 +34,9 @@ namespace MoonWorks.Graphics Level = level; } - public RefreshCS.Refresh.TextureSlice ToRefreshTextureSlice() + public Refresh.TextureSlice ToRefreshTextureSlice() { - RefreshCS.Refresh.TextureSlice textureSlice = new RefreshCS.Refresh.TextureSlice + Refresh.TextureSlice textureSlice = new Refresh.TextureSlice { texture = Texture.Handle, rectangle = Rectangle, diff --git a/src/Graphics/Bytecode.cs b/src/Graphics/Utility/Bytecode.cs similarity index 92% rename from src/Graphics/Bytecode.cs rename to src/Graphics/Utility/Bytecode.cs index f9a2982..30d2a3b 100644 --- a/src/Graphics/Bytecode.cs +++ b/src/Graphics/Utility/Bytecode.cs @@ -4,7 +4,7 @@ namespace MoonWorks.Graphics { public static class Bytecode { - public static uint[] ReadBytecode(FileInfo fileInfo) + public static uint[] ReadBytecodeAsUInt32(FileInfo fileInfo) { byte[] data; int size; diff --git a/src/Graphics/Conversions.cs b/src/Graphics/Utility/Conversions.cs similarity index 100% rename from src/Graphics/Conversions.cs rename to src/Graphics/Utility/Conversions.cs diff --git a/src/PresentMode.cs b/src/PresentMode.cs deleted file mode 100644 index 2abed9b..0000000 --- a/src/PresentMode.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MoonWorks -{ - public enum PresentMode - { - Immediate, - Mailbox, - FIFO, - FIFORelaxed - } -}