From 0eeccb5c3c68289517ad40a44e6639b6cb71e325 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Mon, 5 Dec 2011 19:31:19 +0000 Subject: [PATCH] added a bunch of source files to Metro RenderSystem --- .../BlendState_Metro.cs | 295 +++++++ .../ANX.RenderSystem.Windows.Metro/Creator.cs | 246 +++++- .../DepthStencilState_Metro.cs | 290 +++++++ .../EffectParameter_Metro.cs | 206 +++++ .../EffectPass_Metro.cs | 84 ++ .../EffectTechnique_Metro.cs | 112 +++ .../Effect_Metro.cs | 255 ++++++ .../FormatConverter.cs | 387 ++++++++++ .../GraphicsDeviceWindowsMetro.cs | 594 ++++++++++++++ .../IndexBuffer_Metro.cs | 153 ++++ .../Metadata.Designer.cs | 72 ++ .../Metadata.resx | 123 +++ .../NativeMethods.cs | 120 +++ .../RasterizerState_Metro.cs | 212 +++++ .../RenderTarget2D_Metro.cs | 103 +++ .../SamplerState_Metro.cs | 216 ++++++ .../ShaderByteCode.cs | 727 ++++++++++++++++++ .../Texture2D_Metro.cs | 316 ++++++++ .../VertexBuffer_Metro.cs | 158 ++++ .../WindowsGameHost.cs | 136 ++++ .../WindowsGameWindow.cs | 162 ++++ 21 files changed, 4963 insertions(+), 4 deletions(-) create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs new file mode 100644 index 00000000..b36dcbc5 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs @@ -0,0 +1,295 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; +using ANX.Framework.NonXNA; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class BlendState_DX10 : INativeBlendState + { + #region Private Members + private BlendStateDescription description; + private SharpDX.Direct3D10.BlendState nativeBlendState; + private bool nativeBlendStateDirty; + private SharpDX.Color4 blendFactor; + private int multiSampleMask; + private bool bound; + + #endregion // Private Members + + public BlendState_DX10() + { + this.description = new BlendStateDescription(); + + for (int i = 0; i < description.IsBlendEnabled.Length; i++) + { + description.IsBlendEnabled[i] = (i < 4); + } + + nativeBlendStateDirty = true; + } + + public void Apply(GraphicsDevice graphics) + { + GraphicsDeviceWindowsDX10 gdx10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = gdx10.NativeDevice; + + UpdateNativeBlendState(device); + this.bound = true; + + device.OutputMerger.SetBlendState(nativeBlendState, this.blendFactor, this.multiSampleMask); + } + + public void Release() + { + this.bound = false; + } + + public void Dispose() + { + if (this.nativeBlendState != null) + { + this.nativeBlendState.Dispose(); + this.nativeBlendState = null; + } + } + + public bool IsBound + { + get + { + return this.bound; + } + } + + public Color BlendFactor + { + set + { + const float colorConvert = 1f / 255f; + + blendFactor.Red = value.R * colorConvert; + blendFactor.Green = value.G * colorConvert; + blendFactor.Blue = value.B * colorConvert; + blendFactor.Alpha = value.A * colorConvert; + } + } + + public int MultiSampleMask + { + set + { + this.multiSampleMask = value; + } + } + + public BlendFunction AlphaBlendFunction + { + set + { + BlendOperation alphaBlendOperation = FormatConverter.Translate(value); + + if (description.AlphaBlendOperation != alphaBlendOperation) + { + nativeBlendStateDirty = true; + description.AlphaBlendOperation = alphaBlendOperation; + } + } + } + + public BlendFunction ColorBlendFunction + { + set + { + BlendOperation blendOperation = FormatConverter.Translate(value); + + if (description.BlendOperation != blendOperation) + { + nativeBlendStateDirty = true; + description.BlendOperation = blendOperation; + } + } + } + + public Blend AlphaDestinationBlend + { + set + { + BlendOption destinationAlphaBlend = FormatConverter.Translate(value); + + if (description.DestinationAlphaBlend != destinationAlphaBlend) + { + nativeBlendStateDirty = true; + description.DestinationAlphaBlend = destinationAlphaBlend; + } + } + } + + public Blend ColorDestinationBlend + { + set + { + BlendOption destinationBlend = FormatConverter.Translate(value); + + if (description.DestinationBlend != destinationBlend) + { + nativeBlendStateDirty = true; + description.DestinationBlend = destinationBlend; + } + } + } + + public ColorWriteChannels ColorWriteChannels + { + set + { + ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); + + if (description.RenderTargetWriteMask[0] != renderTargetWriteMask) + { + nativeBlendStateDirty = true; + description.RenderTargetWriteMask[0] = renderTargetWriteMask; + } + } + } + + public ColorWriteChannels ColorWriteChannels1 + { + set + { + ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); + + if (description.RenderTargetWriteMask[1] != renderTargetWriteMask) + { + nativeBlendStateDirty = true; + description.RenderTargetWriteMask[1] = renderTargetWriteMask; + } + } + } + + public ColorWriteChannels ColorWriteChannels2 + { + set + { + ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); + + if (description.RenderTargetWriteMask[2] != renderTargetWriteMask) + { + nativeBlendStateDirty = true; + description.RenderTargetWriteMask[2] = renderTargetWriteMask; + } + } + } + + public ColorWriteChannels ColorWriteChannels3 + { + set + { + ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); + + if (description.RenderTargetWriteMask[3] != renderTargetWriteMask) + { + nativeBlendStateDirty = true; + description.RenderTargetWriteMask[3] = renderTargetWriteMask; + } + } + } + + public Blend AlphaSourceBlend + { + set + { + BlendOption sourceAlphaBlend = FormatConverter.Translate(value); + + if (description.SourceAlphaBlend != sourceAlphaBlend) + { + nativeBlendStateDirty = true; + description.SourceAlphaBlend = sourceAlphaBlend; + } + } + } + + public Blend ColorSourceBlend + { + set + { + BlendOption sourceBlend = FormatConverter.Translate(value); + + if (description.SourceBlend != sourceBlend) + { + nativeBlendStateDirty = true; + description.SourceBlend = sourceBlend; + } + } + } + + private void UpdateNativeBlendState(SharpDX.Direct3D10.Device device) + { + if (this.nativeBlendStateDirty == true || this.nativeBlendState == null) + { + if (this.nativeBlendState != null) + { + this.nativeBlendState.Dispose(); + this.nativeBlendState = null; + } + + this.nativeBlendState = new SharpDX.Direct3D10.BlendState(device, ref this.description); + + this.nativeBlendStateDirty = false; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs index fba2564c..f5f9fa8a 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs @@ -1,12 +1,250 @@ -using System; +#region Using Statements +using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using ANX.Framework.Graphics; +using System.IO; +using ANX.Framework.NonXNA; +using System.Runtime.InteropServices; +using SharpDX.DXGI; +using ANX.Framework.NonXNA.RenderSystem; -namespace ANX.RenderSystem.Windows.Metro +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 { - public class Creator + public class Creator : IRenderSystemCreator { + public string Name + { + get { return "DirectX10"; } + } + + public int Priority + { + get { return 10; } + } + + public bool IsSupported + { + get + { + //TODO: this is just a very basic version of test for support + return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT; + } + } + + public GameHost CreateGameHost(Game game) + { + return new WindowsGameHost(game); + } + + public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) + { + return new GraphicsDeviceWindowsDX10(presentationParameters); + } + + public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) + { + return new IndexBuffer_DX10(graphics, size, indexCount, usage); + } + + public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage); + } + + public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + { + Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); + + return effect; + } + + public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode) + { + Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, byteCode); + + return effect; + } + + public Texture2D CreateTexture(GraphicsDevice graphics, string fileName) + { + //TODO: implement + throw new NotImplementedException(); + + //GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; + //SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile(graphicsDX10.NativeDevice, fileName); + //Texture2D_DX10 texture = new Texture2D_DX10(graphics, nativeTexture.Description.Width, nativeTexture.Description.Height, FormatConverter.Translate(nativeTexture.Description.Format), nativeTexture.Description.MipLevels); + //texture.NativeTexture = nativeTexture; + + //return texture; + } + + public INativeBlendState CreateBlendState() + { + return new BlendState_DX10(); + } + + public INativeRasterizerState CreateRasterizerState() + { + return new RasterizerState_DX10(); + } + + public INativeDepthStencilState CreateDepthStencilState() + { + return new DepthStencilState_DX10(); + } + + public INativeSamplerState CreateSamplerState() + { + return new SamplerState_DX10(); + } + + public byte[] GetShaderByteCode(PreDefinedShader type) + { + if (type == PreDefinedShader.SpriteBatch) + { + return ShaderByteCode.SpriteBatchByteCode; + } + else if (type == PreDefinedShader.AlphaTestEffect) + { + return ShaderByteCode.AlphaTestEffectByteCode; + } + else if (type == PreDefinedShader.BasicEffect) + { + return ShaderByteCode.BasicEffectByteCode; + } + else if (type == PreDefinedShader.DualTextureEffect) + { + return ShaderByteCode.DualTextureEffectByteCode; + } + else if (type == PreDefinedShader.EnvironmentMapEffect) + { + return ShaderByteCode.EnvironmentMapEffectByteCode; + } + else if (type == PreDefinedShader.SkinnedEffect) + { + return ShaderByteCode.SkinnedEffectByteCode; + } + + throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available"); + } + + public void RegisterCreator(AddInSystemFactory factory) + { + factory.AddCreator(this); + } + + + public System.Collections.ObjectModel.ReadOnlyCollection GetAdapterList() + { + SharpDX.DXGI.Factory factory = new Factory(); + + List adapterList = new List(); + DisplayModeCollection displayModeCollection = new DisplayModeCollection(); + + for (int i = 0; i < factory.GetAdapterCount(); i++) + { + using (Adapter adapter = factory.GetAdapter(i)) + { + GraphicsAdapter ga = new GraphicsAdapter(); + //ga.CurrentDisplayMode = ; + //ga.Description = ; + ga.DeviceId = adapter.Description.DeviceId; + ga.DeviceName = adapter.Description.Description; + ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter? + //ga.IsWideScreen = ; + //ga.MonitorHandle = ; + ga.Revision = adapter.Description.Revision; + ga.SubSystemId = adapter.Description.SubsystemId; + //ga.SupportedDisplayModes = ; + ga.VendorId = adapter.Description.VendorId; + + using (Output adapterOutput = adapter.GetOutput(0)) + { + foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced)) + { + DisplayMode displayMode = new DisplayMode() + { + Format = FormatConverter.Translate(modeDescription.Format), + Width = modeDescription.Width, + Height = modeDescription.Height, + AspectRatio = (float)modeDescription.Width / (float)modeDescription.Height, + TitleSafeArea = new Rectangle(0, 0, modeDescription.Width, modeDescription.Height), //TODO: calculate this for real + }; + + displayModeCollection[displayMode.Format] = new DisplayMode[] { displayMode }; + } + } + + ga.SupportedDisplayModes = displayModeCollection; + + adapterList.Add(ga); + } + } + + factory.Dispose(); + + return new System.Collections.ObjectModel.ReadOnlyCollection(adapterList); + } + + public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount) + { + return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount); + } + + public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) + { + return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage); + } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs new file mode 100644 index 00000000..376d4e9c --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs @@ -0,0 +1,290 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; + +namespace ANX.Framework.Windows.DX10 +{ + public class DepthStencilState_DX10 : INativeDepthStencilState + { + #region Private Members + private DepthStencilStateDescription description; + private SharpDX.Direct3D10.DepthStencilState nativeDepthStencilState; + private bool nativeDepthStencilStateDirty; + private bool bound; + + private int referenceStencil; + + #endregion // Private Members + + public DepthStencilState_DX10() + { + this.description = new DepthStencilStateDescription(); + + this.nativeDepthStencilStateDirty = true; + } + + public void Apply(Graphics.GraphicsDevice graphicsDevice) + { + GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + Device device = gdx10.NativeDevice; + + UpdateNativeDepthStencilState(device); + this.bound = true; + + device.OutputMerger.SetDepthStencilState(nativeDepthStencilState, this.referenceStencil); + } + + public void Release() + { + this.bound = false; + } + + public void Dispose() + { + if (this.nativeDepthStencilState != null) + { + this.nativeDepthStencilState.Dispose(); + this.nativeDepthStencilState = null; + } + } + + public bool IsBound + { + get + { + return this.bound; + } + } + + public Graphics.StencilOperation CounterClockwiseStencilDepthBufferFail + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.BackFace.DepthFailOperation != operation) + { + description.BackFace.DepthFailOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.StencilOperation CounterClockwiseStencilFail + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.BackFace.FailOperation != operation) + { + description.BackFace.FailOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.CompareFunction CounterClockwiseStencilFunction + { + set + { + SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + + if (description.BackFace.Comparison != comparison) + { + description.BackFace.Comparison = comparison; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.StencilOperation CounterClockwiseStencilPass + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.BackFace.PassOperation != operation) + { + description.BackFace.PassOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public bool DepthBufferEnable + { + set + { + if (description.IsDepthEnabled != value) + { + description.IsDepthEnabled = value; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.CompareFunction DepthBufferFunction + { + set + { + SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + + if (description.DepthComparison != comparison) + { + description.DepthComparison = comparison; + nativeDepthStencilStateDirty = true; + } + } + } + + public bool DepthBufferWriteEnable + { + set + { + DepthWriteMask writeMask = value ? DepthWriteMask.All : DepthWriteMask.Zero; + + if (description.DepthWriteMask != writeMask) + { + description.DepthWriteMask = writeMask; + nativeDepthStencilStateDirty = true; + } + } + } + + public int ReferenceStencil + { + set + { + if (this.referenceStencil != value) + { + this.referenceStencil = value; + this.nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.StencilOperation StencilDepthBufferFail + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.FrontFace.DepthFailOperation != operation) + { + description.FrontFace.DepthFailOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public bool StencilEnable + { + set + { + if (description.IsStencilEnabled != value) + { + description.IsStencilEnabled = value; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.StencilOperation StencilFail + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.FrontFace.FailOperation != operation) + { + description.FrontFace.FailOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.CompareFunction StencilFunction + { + set + { + SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + + if (description.FrontFace.Comparison != comparison) + { + description.FrontFace.Comparison = comparison; + nativeDepthStencilStateDirty = true; + } + } + } + + public int StencilMask + { + set + { + byte stencilMask = (byte)value; //TODO: check range + + if (description.StencilReadMask != stencilMask) + { + description.StencilReadMask = stencilMask; + nativeDepthStencilStateDirty = true; + } + } + } + + public Graphics.StencilOperation StencilPass + { + set + { + SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + + if (description.FrontFace.PassOperation != operation) + { + description.FrontFace.PassOperation = operation; + nativeDepthStencilStateDirty = true; + } + } + } + + public int StencilWriteMask + { + set + { + byte stencilWriteMask = (byte)value; //TODO: check range + + if (description.StencilWriteMask != stencilWriteMask) + { + description.StencilWriteMask = stencilWriteMask; + nativeDepthStencilStateDirty = true; + } + } + } + + public bool TwoSidedStencilMode + { + set + { + //TODO: check if we really need this. in xna this enables only counter clockwise stencil operations + } + } + + private void UpdateNativeDepthStencilState(Device device) + { + if (this.nativeDepthStencilStateDirty == true || this.nativeDepthStencilState == null) + { + if (this.nativeDepthStencilState != null) + { + this.nativeDepthStencilState.Dispose(); + this.nativeDepthStencilState = null; + } + + this.nativeDepthStencilState = new SharpDX.Direct3D10.DepthStencilState(device, ref this.description); + + this.nativeDepthStencilStateDirty = false; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs new file mode 100644 index 00000000..66b78ad1 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs @@ -0,0 +1,206 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; +using ANX.Framework.NonXNA.RenderSystem; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class EffectParameter_DX10 : INativeEffectParameter + { + private EffectVariable nativeEffectVariable; + + public EffectVariable NativeParameter + { + get + { + return this.nativeEffectVariable; + } + internal set + { + this.nativeEffectVariable = value; + } + } + + public void SetValue(bool value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(bool[] value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(int value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(int[] value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(Matrix value) + { + SharpDX.Matrix m = new SharpDX.Matrix(value.M11, value.M12, value.M13, value.M14, value.M21, value.M22, value.M23, value.M24, value.M31, value.M32, value.M33, value.M34, value.M41, value.M42, value.M43, value.M44); + nativeEffectVariable.AsMatrix().SetMatrix(m); + } + + public void SetValue(Matrix[] value) + { + int count = value.Length; + SharpDX.Matrix[] m = new SharpDX.Matrix[count]; + Matrix anxMatrix; + for (int i = 0; i < count; i++) + { + anxMatrix = value[i]; + m[i] = new SharpDX.Matrix(anxMatrix.M11, anxMatrix.M12, anxMatrix.M13, anxMatrix.M14, + anxMatrix.M21, anxMatrix.M22, anxMatrix.M23, anxMatrix.M24, + anxMatrix.M31, anxMatrix.M32, anxMatrix.M33, anxMatrix.M34, + anxMatrix.M41, anxMatrix.M42, anxMatrix.M43, anxMatrix.M44); + } + + nativeEffectVariable.AsMatrix().SetMatrix(m); + } + + public void SetValue(Quaternion value) + { + SharpDX.Vector4 q = new SharpDX.Vector4(value.X, value.Y, value.Z, value.W); + nativeEffectVariable.AsVector().Set(q); + } + + public void SetValue(Quaternion[] value) + { + int count = value.Length; + SharpDX.Vector4[] q = new SharpDX.Vector4[count]; + for (int i = 0; i < count; i++) + { + q[i] = new SharpDX.Vector4(value[i].X, value[i].Y, value[i].Z, value[i].W); + } + nativeEffectVariable.AsVector().Set(q); + } + + public void SetValue(float value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(float[] value) + { + nativeEffectVariable.AsScalar().Set(value); + } + + public void SetValue(Vector2 value) + { + SharpDX.Vector2 v = new SharpDX.Vector2(value.X, value.Y); + nativeEffectVariable.AsVector().Set(v); + } + + public void SetValue(Vector2[] value) + { + throw new NotImplementedException(); + } + + public void SetValue(Vector3 value) + { + SharpDX.Vector3 v = new SharpDX.Vector3(value.X, value.Y, value.Z); + nativeEffectVariable.AsVector().Set(v); + } + + public void SetValue(Vector3[] value) + { + throw new NotImplementedException(); + } + + public void SetValue(Vector4 value) + { + SharpDX.Vector4 v = new SharpDX.Vector4(value.X, value.Y, value.Z, value.W); + nativeEffectVariable.AsVector().Set(v); + } + + public void SetValue(Vector4[] value) + { + int count = value.Length; + SharpDX.Vector4[] q = new SharpDX.Vector4[count]; + for (int i = 0; i < count; i++) + { + q[i] = new SharpDX.Vector4(value[i].X, value[i].Y, value[i].Z, value[i].W); + } + nativeEffectVariable.AsVector().Set(q); + } + + public void SetValue(Texture value) + { + Texture2D_DX10 tex = value.NativeTexture as Texture2D_DX10; + GraphicsDeviceWindowsDX10 graphicsDX10 = tex.GraphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + + nativeEffectVariable.AsShaderResource().SetResource(tex.NativeShaderResourceView); + } + + + + public string Name + { + get + { + return nativeEffectVariable.Description.Name; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs new file mode 100644 index 00000000..56743c9d --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs @@ -0,0 +1,84 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class EffectPass_DX10 : INativeEffectPass + { + private EffectPass nativePass; + + public EffectPass NativePass + { + get + { + return this.nativePass; + } + internal set + { + this.nativePass = value; + } + } + + public string Name + { + get + { + return nativePass.Description.Name; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs new file mode 100644 index 00000000..6aae7fd7 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs @@ -0,0 +1,112 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class EffectTechnique_DX10 : INativeEffectTechnique + { + private EffectTechnique nativeTechnique; + private ANX.Framework.Graphics.Effect parentEffect; + + internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect) + { + if (parentEffect == null) + { + throw new ArgumentNullException("parentEffect"); + } + + this.parentEffect = parentEffect; + } + + public EffectTechnique NativeTechnique + { + get + { + return this.nativeTechnique; + } + internal set + { + this.nativeTechnique = value; + } + } + + public string Name + { + get + { + return nativeTechnique.Description.Name; + } + } + + + public IEnumerable Passes + { + get + { + for (int i = 0; i < nativeTechnique.Description.PassCount; i++) + { + EffectPass_DX10 passDx10 = new EffectPass_DX10(); + passDx10.NativePass = nativeTechnique.GetPassByIndex(i); + + Graphics.EffectPass pass = new Graphics.EffectPass(this.parentEffect); + + yield return pass; + } + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs new file mode 100644 index 00000000..55819ba7 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs @@ -0,0 +1,255 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SharpDX.Direct3D10; +using SharpDX.D3DCompiler; +using System.IO; +using ANX.Framework.NonXNA; +using ANX.Framework.Graphics; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class Effect_DX10 : INativeEffect + { + private ShaderBytecode pixelShaderByteCode; + private ShaderBytecode vertexShaderByteCode; + private VertexShader vertexShader; + private PixelShader pixelShader; + private ANX.Framework.Graphics.Effect managedEffect; + private ShaderBytecode effectByteCode; + private SharpDX.Direct3D10.Effect nativeEffect; + + public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + { + if (this.managedEffect == null) + { + throw new ArgumentNullException("managedEffect"); + } + this.managedEffect = managedEffect; + + if (vertexShaderByteCode.CanSeek) + { + vertexShaderByteCode.Seek(0, SeekOrigin.Begin); + } + this.vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderByteCode); + this.vertexShader = new VertexShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.vertexShaderByteCode); + + if (pixelShaderByteCode.CanSeek) + { + pixelShaderByteCode.Seek(0, SeekOrigin.Begin); + } + this.pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderByteCode); + this.pixelShader = new PixelShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.pixelShaderByteCode); + } + + public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream effectByteCode) + { + if (managedEffect == null) + { + throw new ArgumentNullException("managedEffect"); + } + this.managedEffect = managedEffect; + + if (effectByteCode.CanSeek) + { + effectByteCode.Seek(0, SeekOrigin.Begin); + } + this.effectByteCode = ShaderBytecode.FromStream(effectByteCode); + this.nativeEffect = new SharpDX.Direct3D10.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice, this.effectByteCode); + } + + public void Apply(GraphicsDevice graphicsDevice) + { + //TODO: dummy + ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).currentEffect = this; + } + + internal SharpDX.Direct3D10.Effect NativeEffect + { + get + { + return this.nativeEffect; + } + } + + internal ShaderBytecode PixelShaderByteCode + { + get + { + return this.pixelShaderByteCode; + } + } + + internal ShaderBytecode VertexShaderByteCode + { + get + { + return this.vertexShaderByteCode; + } + } + + internal VertexShader VertexShader + { + get + { + return this.vertexShader; + } + } + + internal PixelShader PixelShader + { + get + { + return this.pixelShader; + } + } + + public static byte[] CompileVertexShader(string effectCode) + { + ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None); + byte[] bytecode = new byte[vertexShaderByteCode.BufferSize]; + vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length); + return bytecode; + } + + public static byte[] CompilePixelShader(string effectCode) + { + ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None); + byte[] bytecode = new byte[pixelShaderByteCode.BufferSize]; + pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length); + return bytecode; + } + + public static byte[] CompileFXShader(string effectCode) + { + ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, "fx_4_0", ShaderFlags.None, EffectFlags.None); + byte[] bytecode = new byte[effectByteCode.BufferSize]; + effectByteCode.Data.Read(bytecode, 0, bytecode.Length); + return bytecode; + } + + public void Dispose() + { + if (this.pixelShaderByteCode != null) + { + this.pixelShaderByteCode.Dispose(); + this.pixelShaderByteCode = null; + } + + if (this.pixelShader != null) + { + this.pixelShader.Dispose(); + this.pixelShader = null; + } + + if (this.vertexShaderByteCode != null) + { + this.vertexShaderByteCode.Dispose(); + this.vertexShaderByteCode = null; + } + + if (this.vertexShader != null) + { + this.vertexShader.Dispose(); + this.vertexShader = null; + } + + if (this.effectByteCode != null) + { + this.effectByteCode.Dispose(); + this.effectByteCode = null; + } + + if (this.nativeEffect != null) + { + this.nativeEffect.Dispose(); + this.nativeEffect = null; + } + } + + + public IEnumerable Techniques + { + get + { + for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++) + { + EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(this.managedEffect); + teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i); + + Graphics.EffectTechnique teq = new Graphics.EffectTechnique(this.managedEffect, teqDx10); + + yield return teq; + } + } + } + + public IEnumerable Parameters + { + get + { + for (int i = 0; i < nativeEffect.Description.GlobalVariableCount; i++) + { + EffectParameter_DX10 parDx10 = new EffectParameter_DX10(); + parDx10.NativeParameter = nativeEffect.GetVariableByIndex(i); + + Graphics.EffectParameter par = new Graphics.EffectParameter(); + par.NativeParameter = parDx10; + + yield return par; + } + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs new file mode 100644 index 00000000..d29ee791 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs @@ -0,0 +1,387 @@ +#region Using Statements +using System; +using ANX.Framework.Graphics; +using SharpDX.Direct3D10; +using SharpDX.Direct3D; +using SharpDX.DXGI; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + internal class FormatConverter + { + + public static int FormatSize(SurfaceFormat format) + { + switch (format) + { + case SurfaceFormat.Vector4: + return 16; + //case SurfaceFormat.Vector3: + // return 12; + case SurfaceFormat.Vector2: + return 8; + case SurfaceFormat.Single: + case SurfaceFormat.Color: + //case SurfaceFormat.RGBA1010102: + //case SurfaceFormat.RG32: + return 4; + //case SurfaceFormat.BGR565: + //case SurfaceFormat.BGRA5551: + // return 2; + case SurfaceFormat.Dxt1: + case SurfaceFormat.Dxt3: + case SurfaceFormat.Dxt5: + case SurfaceFormat.Alpha8: + return 1; + default: + throw new ArgumentException("Invalid format"); + } + } + + public static SharpDX.DXGI.Format Translate(SurfaceFormat surfaceFormat) + { + switch (surfaceFormat) + { + case SurfaceFormat.Color: + return SharpDX.DXGI.Format.R8G8B8A8_UNorm; + case SurfaceFormat.Dxt3: + return SharpDX.DXGI.Format.BC2_UNorm; + case SurfaceFormat.Dxt5: + return SharpDX.DXGI.Format.BC3_UNorm; + } + + throw new Exception("can't translate SurfaceFormat: " + surfaceFormat.ToString()); + } + + public static Format Translate(ANX.Framework.Graphics.DepthFormat depthFormat) + { + switch (depthFormat) + { + case DepthFormat.Depth16: + return Format.D16_UNorm; + case DepthFormat.Depth24: + //TODO: no DirectX10 24Bit depth format??? + case DepthFormat.Depth24Stencil8: + return Format.D24_UNorm_S8_UInt; + case DepthFormat.None: + return Format.Unknown; + } + + throw new Exception("can't translate DepthFormat: " + depthFormat.ToString()); + } + + public static SurfaceFormat Translate(SharpDX.DXGI.Format format) + { + switch (format) + { + case SharpDX.DXGI.Format.R8G8B8A8_UNorm: + return SurfaceFormat.Color; + case SharpDX.DXGI.Format.BC2_UNorm: + return SurfaceFormat.Dxt3; + case SharpDX.DXGI.Format.BC3_UNorm: + return SurfaceFormat.Dxt5; + } + + throw new Exception("can't translate Format: " + format.ToString()); + } + + public static Filter Translate(TextureFilter filter) + { + switch (filter) + { + case TextureFilter.Anisotropic: + return Filter.Anisotropic; + case TextureFilter.Linear: + return Filter.MinMagMipLinear; + case TextureFilter.LinearMipPoint: + return Filter.MinMagMipPoint; + case TextureFilter.MinLinearMagPointMipLinear: + return Filter.MinLinearMagPointMipLinear; + case TextureFilter.MinLinearMagPointMipPoint: + return Filter.MinLinearMagMipPoint; + case TextureFilter.MinPointMagLinearMipLinear: + return Filter.MinPointMagMipLinear; + case TextureFilter.MinPointMagLinearMipPoint: + return Filter.MinPointMagLinearMipPoint; + case TextureFilter.Point: + return Filter.MinMagMipPoint; + case TextureFilter.PointMipLinear: + return Filter.MinMagPointMipLinear; + } + + throw new NotImplementedException(); + } + + public static SharpDX.Direct3D10.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode) + { + switch (addressMode) + { + case Graphics.TextureAddressMode.Clamp: + return SharpDX.Direct3D10.TextureAddressMode.Clamp; + case Graphics.TextureAddressMode.Mirror: + return SharpDX.Direct3D10.TextureAddressMode.Mirror; + case Graphics.TextureAddressMode.Wrap: + return SharpDX.Direct3D10.TextureAddressMode.Wrap; + } + + return SharpDX.Direct3D10.TextureAddressMode.Clamp; + } + + public static PrimitiveTopology Translate(PrimitiveType primitiveType) + { + switch (primitiveType) + { + case PrimitiveType.LineList: + return PrimitiveTopology.LineList; + case PrimitiveType.LineStrip: + return PrimitiveTopology.LineStrip; + case PrimitiveType.TriangleList: + return PrimitiveTopology.TriangleList; + case PrimitiveType.TriangleStrip: + return PrimitiveTopology.TriangleStrip; + default: + throw new InvalidOperationException("unknown PrimitiveType: " + primitiveType.ToString()); + } + } + + public static SharpDX.DXGI.Format Translate(IndexElementSize indexElementSize) + { + switch (indexElementSize) + { + case IndexElementSize.SixteenBits: + return Format.R16_UInt; + case IndexElementSize.ThirtyTwoBits: + return Format.R32_UInt; + default: + throw new InvalidOperationException("unknown IndexElementSize: " + indexElementSize.ToString()); + } + } + + public static string Translate(VertexElementUsage usage) + { + //TODO: map the other Usages + if (usage == VertexElementUsage.TextureCoordinate) + { + return "TEXCOORD"; + } + else + { + return usage.ToString().ToUpperInvariant(); + } + } + + public static BlendOperation Translate(BlendFunction blendFunction) + { + switch (blendFunction) + { + case BlendFunction.Add: + return BlendOperation.Add; + case BlendFunction.Max: + return BlendOperation.Maximum; + case BlendFunction.Min: + return BlendOperation.Minimum; + case BlendFunction.ReverseSubtract: + return BlendOperation.ReverseSubtract; + case BlendFunction.Subtract: + return BlendOperation.Subtract; + } + + throw new NotImplementedException(); + } + + public static BlendOption Translate(Blend blend) + { + switch (blend) + { + case Blend.BlendFactor: + return BlendOption.BlendFactor; + case Blend.DestinationAlpha: + return BlendOption.DestinationAlpha; + case Blend.DestinationColor: + return BlendOption.DestinationColor; + case Blend.InverseBlendFactor: + return BlendOption.InverseBlendFactor; + case Blend.InverseDestinationAlpha: + return BlendOption.InverseDestinationAlpha; + case Blend.InverseDestinationColor: + return BlendOption.InverseDestinationColor; + case Blend.InverseSourceAlpha: + return BlendOption.InverseSourceAlpha; + case Blend.InverseSourceColor: + return BlendOption.InverseSourceColor; + case Blend.One: + return BlendOption.One; + case Blend.SourceAlpha: + return BlendOption.SourceAlpha; + case Blend.SourceAlphaSaturation: + return BlendOption.SourceAlphaSaturate; + case Blend.SourceColor: + return BlendOption.SourceColor; + case Blend.Zero: + return BlendOption.Zero; + } + + throw new NotImplementedException(); + } + + public static ColorWriteMaskFlags Translate(ColorWriteChannels colorWriteChannels) + { + ColorWriteMaskFlags mask = 0; + + if ((colorWriteChannels & ColorWriteChannels.All) == ColorWriteChannels.All) + { + mask |= ColorWriteMaskFlags.All; + } + + if ((colorWriteChannels & ColorWriteChannels.Alpha) == ColorWriteChannels.Alpha) + { + mask |= ColorWriteMaskFlags.Alpha; + } + + if ((colorWriteChannels & ColorWriteChannels.Blue) == ColorWriteChannels.Blue) + { + mask |= ColorWriteMaskFlags.Blue; + } + + if ((colorWriteChannels & ColorWriteChannels.Green) == ColorWriteChannels.Green) + { + mask |= ColorWriteMaskFlags.Green; + } + + if ((colorWriteChannels & ColorWriteChannels.Red) == ColorWriteChannels.Red) + { + mask |= ColorWriteMaskFlags.Red; + } + + return mask; + } + + public static SharpDX.Direct3D10.StencilOperation Translate(ANX.Framework.Graphics.StencilOperation stencilOperation) + { + switch (stencilOperation) + { + case Graphics.StencilOperation.Decrement: + return SharpDX.Direct3D10.StencilOperation.Decrement; + case Graphics.StencilOperation.DecrementSaturation: + return SharpDX.Direct3D10.StencilOperation.DecrementAndClamp; + case Graphics.StencilOperation.Increment: + return SharpDX.Direct3D10.StencilOperation.Increment; + case Graphics.StencilOperation.IncrementSaturation: + return SharpDX.Direct3D10.StencilOperation.IncrementAndClamp; + case Graphics.StencilOperation.Invert: + return SharpDX.Direct3D10.StencilOperation.Invert; + case Graphics.StencilOperation.Keep: + return SharpDX.Direct3D10.StencilOperation.Keep; + case Graphics.StencilOperation.Replace: + return SharpDX.Direct3D10.StencilOperation.Replace; + case Graphics.StencilOperation.Zero: + return SharpDX.Direct3D10.StencilOperation.Zero; + } + + throw new NotImplementedException("unknown StencilOperation"); + } + + public static Comparison Translate(ANX.Framework.Graphics.CompareFunction compareFunction) + { + switch (compareFunction) + { + case ANX.Framework.Graphics.CompareFunction.Always: + return Comparison.Always; + case ANX.Framework.Graphics.CompareFunction.Equal: + return Comparison.Equal; + case ANX.Framework.Graphics.CompareFunction.Greater: + return Comparison.Greater; + case ANX.Framework.Graphics.CompareFunction.GreaterEqual: + return Comparison.GreaterEqual; + case ANX.Framework.Graphics.CompareFunction.Less: + return Comparison.Less; + case ANX.Framework.Graphics.CompareFunction.LessEqual: + return Comparison.LessEqual; + case ANX.Framework.Graphics.CompareFunction.Never: + return Comparison.Never; + case ANX.Framework.Graphics.CompareFunction.NotEqual: + return Comparison.NotEqual; + } + + throw new NotImplementedException("unknown CompareFunction"); + } + + public static SharpDX.Direct3D10.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode) + { + if (cullMode == Graphics.CullMode.CullClockwiseFace) + { + return SharpDX.Direct3D10.CullMode.Front; + } + else if (cullMode == Graphics.CullMode.CullCounterClockwiseFace) + { + return SharpDX.Direct3D10.CullMode.Back; + } + else + { + return SharpDX.Direct3D10.CullMode.None; + } + } + + public static SharpDX.Direct3D10.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode) + { + if (fillMode == Graphics.FillMode.WireFrame) + { + return SharpDX.Direct3D10.FillMode.Wireframe; + } + else + { + return SharpDX.Direct3D10.FillMode.Solid; + } + } + + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs new file mode 100644 index 00000000..90319be4 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs @@ -0,0 +1,594 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SharpDX; +using SharpDX.DXGI; +using SharpDX.Direct3D; +using SharpDX.D3DCompiler; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +using Device = SharpDX.Direct3D10.Device; +using Buffer = SharpDX.Direct3D10.Buffer; +using System.Runtime.InteropServices; + +namespace ANX.Framework.Windows.DX10 +{ + public class GraphicsDeviceWindowsDX10 : INativeGraphicsDevice + { + #region Constants + private const float ColorMultiplier = 1f / 255f; + #endregion + + #region Interop + [DllImport("user32.dll")] + private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint uFlags); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int Left; // x position of upper-left corner + public int Top; // y position of upper-left corner + public int Right; // x position of lower-right corner + public int Bottom; // y position of lower-right corner + } + + #endregion + + #region Private Members + private Device device; + private SwapChain swapChain; + private RenderTargetView renderView; + private RenderTargetView renderTargetView; + private DepthStencilView depthStencilView; + private SharpDX.Direct3D10.Texture2D depthStencilBuffer; + private SharpDX.Direct3D10.Texture2D backBuffer; + internal Effect_DX10 currentEffect; + private VertexBuffer currentVertexBuffer; + private IndexBuffer currentIndexBuffer; + private SharpDX.Direct3D10.Viewport currentViewport; + private uint lastClearColor; + private SharpDX.Color4 clearColor; + private bool vSyncEnabled; + + #endregion // Private Members + + public GraphicsDeviceWindowsDX10(PresentationParameters presentationParameters) + { + this.vSyncEnabled = true; + + // SwapChain description + var desc = new SwapChainDescription() + { + BufferCount = 1, + ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, new Rational(60, 1), FormatConverter.Translate(presentationParameters.BackBufferFormat)), + IsWindowed = true, + OutputHandle = presentationParameters.DeviceWindowHandle, + SampleDescription = new SampleDescription(1, 0), + SwapEffect = SwapEffect.Discard, + Usage = Usage.RenderTargetOutput + }; + + // Create Device and SwapChain +#if DIRECTX_DEBUG_LAYER + // http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx + Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain); +#else + Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain); +#endif + + // Ignore all windows events + Factory factory = swapChain.GetParent(); + factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll); + + ResizeRenderWindow(presentationParameters); + + // New RenderTargetView from the backbuffer + backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0); + renderView = new RenderTargetView(device, backBuffer); + + currentViewport = new SharpDX.Direct3D10.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + + // + // create the depth stencil buffer + // + Format depthFormat = FormatConverter.Translate(presentationParameters.DepthStencilFormat); + if (depthFormat != Format.Unknown) + { + DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription() + { + Format = depthFormat, + }; + + Texture2DDescription depthStencilTextureDesc = new Texture2DDescription() + { + Width = presentationParameters.BackBufferWidth, + Height = presentationParameters.BackBufferHeight, + MipLevels = 1, + ArraySize = 1, + Format = depthFormat, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + BindFlags = BindFlags.DepthStencil, + CpuAccessFlags = CpuAccessFlags.None, + OptionFlags = ResourceOptionFlags.None + }; + this.depthStencilBuffer = new SharpDX.Direct3D10.Texture2D(device, depthStencilTextureDesc); + + this.depthStencilView = new DepthStencilView(device, this.depthStencilBuffer); + + Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472 + } + } + + #region Clear + public void Clear(ref Color color) + { + uint newClearColor = color.PackedValue; + if (lastClearColor != newClearColor) + { + lastClearColor = newClearColor; + clearColor.Red = color.R * ColorMultiplier; + clearColor.Green = color.G * ColorMultiplier; + clearColor.Blue = color.B * ColorMultiplier; + clearColor.Alpha = color.A * ColorMultiplier; + } + + this.device.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); + } + + public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) + { + if ((options & ClearOptions.Target) == ClearOptions.Target) + { + // Clear a RenderTarget (or BackBuffer) + + this.clearColor.Red = color.X; + this.clearColor.Green = color.Y; + this.clearColor.Blue = color.Z; + this.clearColor.Alpha = color.W; + this.lastClearColor = 0; + + this.device.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); + } + + if (this.depthStencilView != null) + { + if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options) + { + // Clear the stencil buffer + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil); + } + else if ((options | ClearOptions.Stencil) == options) + { + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil); + } + else + { + device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil); + } + } + } + + #endregion + + #region Present + public void Present() + { + swapChain.Present(this.vSyncEnabled ? 1 : 0, PresentFlags.None); + } + + #endregion // Present + + #region DrawPrimitives & DrawIndexedPrimitives + public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount) + { + SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature; + SetupEffectForDraw(out pass, out technique, out passSignature); + + SetupInputLayout(passSignature); + + // Prepare All the stages + device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); + device.Rasterizer.SetViewports(currentViewport); + + device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + + for (int i = 0; i < technique.Description.PassCount; ++i) + { + pass.Apply(); + device.DrawIndexed(CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex); + } + } + + public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount) + { + SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature; + SetupEffectForDraw(out pass, out technique, out passSignature); + + SetupInputLayout(passSignature); + + // Prepare All the stages + device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); + device.Rasterizer.SetViewports(currentViewport); + + device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + + for (int i = 0; i < technique.Description.PassCount; ++i) + { + pass.Apply(); + device.Draw(primitiveCount, vertexOffset); + } + } + + #endregion // DrawPrimitives & DrawIndexedPrimitives + + #region DrawInstancedPrimitives + public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) + { + throw new NotImplementedException(); + } + + #endregion // DrawInstancedPrimitives + + #region DrawUserIndexedPrimitives + public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration, IndexElementSize indexFormat) where T : struct, IVertexType + { + throw new NotImplementedException(); + } + + #endregion // DrawUserIndexedPrimitives + + #region DrawUserPrimitives + public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType + { + throw new NotImplementedException(); + } + + #endregion // DrawUserPrimitives + + internal Device NativeDevice + { + get + { + return this.device; + } + } + + private void SetupEffectForDraw(out SharpDX.Direct3D10.EffectPass pass, out SharpDX.Direct3D10.EffectTechnique technique, out ShaderBytecode passSignature) + { + // get the current effect + //TODO: check for null and throw exception + Effect_DX10 effect = this.currentEffect; + + // get the input semantic of the current effect / technique that is used + //TODO: check for null's and throw exceptions + technique = effect.NativeEffect.GetTechniqueByIndex(0); + pass = technique.GetPassByIndex(0); + passSignature = pass.Description.Signature; + } + + private void SetupInputLayout(ShaderBytecode passSignature) + { + // get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler + //TODO: check for null and throw exception + VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration; + var layout = CreateInputLayout(device, passSignature, vertexDeclaration); + + device.InputAssembler.InputLayout = layout; + } + + private int CalculateVertexCount(PrimitiveType type, int primitiveCount) + { + if (type == PrimitiveType.TriangleList) + { + return primitiveCount * 3; + } + else if (type == PrimitiveType.LineList) + { + return primitiveCount * 2; + } + else if (type == PrimitiveType.LineStrip) + { + return primitiveCount + 1; + } + else if (type == PrimitiveType.TriangleStrip) + { + return primitiveCount + 2; + } + else + { + throw new NotImplementedException("couldn't calculate vertex count for PrimitiveType '" + type.ToString() + "'"); + } + } + + public void SetIndexBuffer(IndexBuffer indexBuffer) + { + if (indexBuffer == null) + { + throw new ArgumentNullException("indexBuffer"); + } + + this.currentIndexBuffer = indexBuffer; + + IndexBuffer_DX10 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX10; + + if (nativeIndexBuffer != null) + { + device.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, FormatConverter.Translate(indexBuffer.IndexElementSize), 0); + } + else + { + throw new Exception("couldn't fetch native DirectX10 IndexBuffer"); + } + } + + public void SetVertexBuffers(Graphics.VertexBufferBinding[] vertexBuffers) + { + if (vertexBuffers == null) + { + throw new ArgumentNullException("vertexBuffers"); + } + + this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-) + + SharpDX.Direct3D10.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D10.VertexBufferBinding[vertexBuffers.Length]; + for (int i = 0; i < vertexBuffers.Length; i++) + { + ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i]; + VertexBuffer_DX10 nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX10; + + if (nativeVertexBuffer != null) + { + nativeVertexBufferBindings[i] = new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, anxVertexBufferBinding.VertexBuffer.VertexDeclaration.VertexStride, anxVertexBufferBinding.VertexOffset); + } + else + { + throw new Exception("couldn't fetch native DirectX10 VertexBuffer"); + } + } + + device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + } + + public void SetViewport(Graphics.Viewport viewport) + { + this.currentViewport = new SharpDX.Direct3D10.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth); + } + + /// + /// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped + /// to the DirectX 10 types. This is what this method is for. + /// + private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration) + { + VertexElement[] vertexElements = vertexDeclaration.GetVertexElements(); + int elementCount = vertexElements.Length; + InputElement[] inputElements = new InputElement[elementCount]; + + for (int i = 0; i < elementCount; i++) + { + inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]); + } + + // Layout from VertexShader input signature + return new InputLayout(device, passSignature, inputElements); + } + + private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement) + { + string elementName = FormatConverter.Translate(vertexElement.VertexElementUsage); + + Format elementFormat; + switch (vertexElement.VertexElementFormat) + { + case VertexElementFormat.Vector2: + elementFormat = Format.R32G32_Float; + break; + case VertexElementFormat.Vector3: + elementFormat = Format.R32G32B32_Float; + break; + case VertexElementFormat.Vector4: + elementFormat = Format.R32G32B32A32_Float; + break; + case VertexElementFormat.Color: + elementFormat = Format.R8G8B8A8_UNorm; + break; + default: + throw new Exception("can't map '" + vertexElement.VertexElementFormat.ToString() + "' to DXGI.Format in DirectX10 RenderSystem CreateInputElementFromVertexElement"); + } + + return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0); + } + + public void SetRenderTargets(params RenderTargetBinding[] renderTargets) + { + if (renderTargets == null) + { + // reset the RenderTarget to backbuffer + if (renderTargetView != null) + { + renderTargetView.Dispose(); + renderTargetView = null; + } + + device.OutputMerger.SetRenderTargets(1, new RenderTargetView[] { this.renderView }, this.depthStencilView); + device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + } + else + { + if (renderTargets.Length == 1) + { + RenderTarget2D renderTarget = renderTargets[0].RenderTarget as RenderTarget2D; + RenderTarget2D_DX10 nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_DX10; + if (renderTarget != null) + { + if (renderTargetView != null) + { + renderTargetView.Dispose(); + renderTargetView = null; + } + this.renderTargetView = new RenderTargetView(device, ((Texture2D_DX10)nativeRenderTarget).NativeShaderResourceView.Resource); + DepthStencilView depthStencilView = null; + device.OutputMerger.SetRenderTargets(1,new RenderTargetView[] { this.renderTargetView }, depthStencilView); + } + } + else + { + throw new NotImplementedException("handling of multiple RenderTargets are not yet implemented"); + } + } + } + + public void GetBackBufferData(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct + { + throw new NotImplementedException(); + } + + public void GetBackBufferData(T[] data) where T : struct + { + throw new NotImplementedException(); + } + + public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct + { + throw new NotImplementedException(); + } + + public void ResizeBuffers(PresentationParameters presentationParameters) + { + if (swapChain != null) + { + renderView.Dispose(); + backBuffer.Dispose(); + + //TODO: handle format + + swapChain.ResizeBuffers(swapChain.Description.BufferCount, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, Format.R8G8B8A8_UNorm, (int)swapChain.Description.Flags); + + backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0); + renderView = new RenderTargetView(device, backBuffer); + } + + ResizeRenderWindow(presentationParameters); + } + + private void ResizeRenderWindow(PresentationParameters presentationParameters) + { + RECT windowRect; + RECT clientRect; + if (GetWindowRect(presentationParameters.DeviceWindowHandle, out windowRect) && + GetClientRect(presentationParameters.DeviceWindowHandle, out clientRect)) + { + int width = presentationParameters.BackBufferWidth + ((windowRect.Right - windowRect.Left) - clientRect.Right); + int height = presentationParameters.BackBufferHeight + ((windowRect.Bottom - windowRect.Top) - clientRect.Bottom); + + SetWindowPos(presentationParameters.DeviceWindowHandle, IntPtr.Zero, windowRect.Left, windowRect.Top, width, height, 0); + } + } + + public bool VSync + { + get + { + return this.vSyncEnabled; + } + set + { + this.vSyncEnabled = value; + } + } + + public void Dispose() + { + if (renderTargetView != null) + { + renderTargetView.Dispose(); + renderTargetView = null; + } + + if (swapChain != null) + { + renderView.Dispose(); + renderView = null; + + backBuffer.Dispose(); + backBuffer = null; + + swapChain.Dispose(); + swapChain = null; + } + + if (this.depthStencilView != null) + { + this.depthStencilBuffer.Dispose(); + this.depthStencilBuffer = null; + + this.depthStencilView.Dispose(); + this.depthStencilView = null; + } + + //TODO: dispose everything else + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs new file mode 100644 index 00000000..b0982919 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs @@ -0,0 +1,153 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; +using System.Runtime.InteropServices; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class IndexBuffer_DX10 : INativeBuffer, IDisposable + { + private SharpDX.Direct3D10.Buffer buffer; + private IndexElementSize size; + + public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) + { + this.size = size; + + //TODO: translate and use usage + + GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; + + if (device != null) + { + BufferDescription description = new BufferDescription() + { + Usage = ResourceUsage.Dynamic, + SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount, + BindFlags = BindFlags.IndexBuffer, + CpuAccessFlags = CpuAccessFlags.Write, + OptionFlags = ResourceOptionFlags.None + }; + + this.buffer = new SharpDX.Direct3D10.Buffer(device, description); + this.buffer.Unmap(); + } + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct + { + SetData(graphicsDevice, data, 0, data.Length); + } + + public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct + { + if (startIndex > 0 || elementCount < data.Length) + { + throw new NotImplementedException("currently starIndex and elementCount of SetData are not implemented"); + } + + //TODO: check offsetInBytes parameter for bounds etc. + + GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); + IntPtr dataPointer = pinnedArray.AddrOfPinnedObject(); + + int dataLength = Marshal.SizeOf(typeof(T)) * data.Length; + + unsafe + { + using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false)) + { + if (offsetInBytes > 0) + { + vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin); + } + + using (var d = buffer.Map(MapMode.WriteDiscard)) + { + vData.CopyTo(d); + buffer.Unmap(); + } + } + } + + pinnedArray.Free(); + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct + { + SetData(graphicsDevice, 0, data, startIndex, elementCount); + } + + public SharpDX.Direct3D10.Buffer NativeBuffer + { + get + { + return this.buffer; + } + } + + public void Dispose() + { + if (this.buffer != null) + { + buffer.Dispose(); + buffer = null; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs new file mode 100644 index 00000000..7f23c917 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.239 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace ANX.Framework.Windows.DX10 { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Metadata { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Metadata() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ANX.Framework.Windows.DX10.Metadata", typeof(Metadata).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Win32NT ähnelt. + /// + public static string SupportedPlatforms { + get { + return ResourceManager.GetString("SupportedPlatforms", resourceCulture); + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx new file mode 100644 index 00000000..c90f8c84 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Win32NT + + \ No newline at end of file diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs new file mode 100644 index 00000000..3ccb27a8 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs @@ -0,0 +1,120 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Security; +using System.Drawing; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + internal sealed class NativeMethods + { + [SuppressUnmanagedCodeSecurity, DllImport("user32.dll", CharSet = CharSet.Auto)] + internal static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags); + + // Nested Types + [StructLayout(LayoutKind.Sequential)] + public struct Message + { + public IntPtr hWnd; + public NativeMethods.WindowMessage msg; + public IntPtr wParam; + public IntPtr lParam; + public uint time; + public Point p; + } + + internal enum WindowMessage : uint + { + ActivateApplication = 0x1c, + Character = 0x102, + Close = 0x10, + Destroy = 2, + EnterMenuLoop = 0x211, + EnterSizeMove = 0x231, + ExitMenuLoop = 530, + ExitSizeMove = 0x232, + GetMinMax = 0x24, + KeyDown = 0x100, + KeyUp = 0x101, + LeftButtonDoubleClick = 0x203, + LeftButtonDown = 0x201, + LeftButtonUp = 0x202, + MiddleButtonDoubleClick = 0x209, + MiddleButtonDown = 0x207, + MiddleButtonUp = 520, + MouseFirst = 0x201, + MouseLast = 0x20d, + MouseMove = 0x200, + MouseWheel = 0x20a, + NonClientHitTest = 0x84, + Paint = 15, + PowerBroadcast = 0x218, + Quit = 0x12, + RightButtonDoubleClick = 0x206, + RightButtonDown = 0x204, + RightButtonUp = 0x205, + SetCursor = 0x20, + Size = 5, + SystemCharacter = 0x106, + SystemCommand = 0x112, + SystemKeyDown = 260, + SystemKeyUp = 0x105, + XButtonDoubleClick = 0x20d, + XButtonDown = 0x20b, + XButtonUp = 0x20c + } + + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs new file mode 100644 index 00000000..9fc88785 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs @@ -0,0 +1,212 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; +using ANX.Framework.NonXNA; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class RasterizerState_DX10 : INativeRasterizerState + { + #region Private Members + private RasterizerStateDescription description; + private SharpDX.Direct3D10.RasterizerState nativeRasterizerState; + private bool nativeRasterizerStateDirty; + private bool bound; + + private const int intMaxOver16 = int.MaxValue / 16; + + #endregion // Private Members + + public RasterizerState_DX10() + { + this.description = new RasterizerStateDescription(); + + this.description.IsAntialiasedLineEnabled = false; + + this.nativeRasterizerStateDirty = true; + } + + public void Apply(Graphics.GraphicsDevice graphicsDevice) + { + GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + Device device = gdx10.NativeDevice; + + UpdateNativeRasterizerState(device); + this.bound = true; + + device.Rasterizer.State = this.nativeRasterizerState; + } + + public void Release() + { + this.bound = false; + } + + public void Dispose() + { + if (this.nativeRasterizerState != null) + { + this.nativeRasterizerState.Dispose(); + this.nativeRasterizerState = null; + } + } + + public bool IsBound + { + get + { + return this.bound; + } + } + + public Graphics.CullMode CullMode + { + set + { + SharpDX.Direct3D10.CullMode cullMode = FormatConverter.Translate(value); + + if (description.CullMode != cullMode) + { + nativeRasterizerStateDirty = true; + description.CullMode = cullMode; + } + } + } + + public float DepthBias + { + set + { + // XNA uses a float value in the range of 0f..16f as value + // DirectX 10 uses a INT value + + int depthBiasValue = (int)(value * intMaxOver16); + + if (description.DepthBias != depthBiasValue) + { + nativeRasterizerStateDirty = true; + description.DepthBias = depthBiasValue; + } + } + } + + public Graphics.FillMode FillMode + { + set + { + SharpDX.Direct3D10.FillMode fillMode = FormatConverter.Translate(value); + + if (description.FillMode != fillMode) + { + nativeRasterizerStateDirty = true; + description.FillMode = fillMode; + } + } + } + + public bool MultiSampleAntiAlias + { + set + { + if (description.IsMultisampleEnabled != value) + { + nativeRasterizerStateDirty = true; + description.IsMultisampleEnabled = value; + } + } + } + + public bool ScissorTestEnable + { + set + { + if (description.IsScissorEnabled != value) + { + nativeRasterizerStateDirty = true; + description.IsScissorEnabled = value; + } + } + } + + public float SlopeScaleDepthBias + { + set + { + if (description.SlopeScaledDepthBias != value) + { + nativeRasterizerStateDirty = true; + description.SlopeScaledDepthBias = value; + } + } + } + + private void UpdateNativeRasterizerState(Device device) + { + if (this.nativeRasterizerStateDirty == true || this.nativeRasterizerState == null) + { + if (this.nativeRasterizerState != null) + { + this.nativeRasterizerState.Dispose(); + this.nativeRasterizerState = null; + } + + this.nativeRasterizerState = new SharpDX.Direct3D10.RasterizerState(device, ref this.description); + + this.nativeRasterizerStateDirty = false; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs new file mode 100644 index 00000000..b518dd4f --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs @@ -0,0 +1,103 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.Graphics; +using ANX.Framework.NonXNA.RenderSystem; +using SharpDX.Direct3D10; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class RenderTarget2D_DX10 : Texture2D_DX10, INativeRenderTarget2D, INativeTexture2D + { + #region Private Members + + #endregion // Private Members + + public RenderTarget2D_DX10(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) + : base(graphics) + { + if (mipMap) + { + throw new NotImplementedException("creating RenderTargets with mip map not yet implemented"); + } + + this.surfaceFormat = surfaceFormat; + + GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + + SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription() + { + Width = width, + Height = height, + MipLevels = 1, + ArraySize = 1, + Format = FormatConverter.Translate(preferredFormat), + SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), + Usage = SharpDX.Direct3D10.ResourceUsage.Default, + BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource | SharpDX.Direct3D10.BindFlags.RenderTarget, + CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.None, + OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None, + }; + this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description); + this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture); + + // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx + // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx + + this.formatSize = FormatConverter.FormatSize(surfaceFormat); + } + + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs new file mode 100644 index 00000000..eefd5fa0 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs @@ -0,0 +1,216 @@ +#region Using Statements +using System; +using ANX.Framework.Graphics; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class SamplerState_DX10 : INativeSamplerState + { + #region Private Members + private SamplerStateDescription description; + private SharpDX.Direct3D10.SamplerState nativeSamplerState; + private bool nativeSamplerStateDirty; + private bool bound; + + #endregion // Private Members + + public SamplerState_DX10() + { + this.description = new SamplerStateDescription(); + + this.nativeSamplerStateDirty = true; + } + + public void Apply(GraphicsDevice graphicsDevice, int index) + { + GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + Device device = gdx10.NativeDevice; + + UpdateNativeSamplerState(device); + this.bound = true; + + device.PixelShader.SetSampler(index, this.nativeSamplerState); + } + + public void Release() + { + this.bound = false; + } + + public bool IsBound + { + get + { + return this.bound; + } + } + + public ANX.Framework.Graphics.TextureAddressMode AddressU + { + set + { + SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + + if (description.AddressU != mode) + { + description.AddressU = mode; + nativeSamplerStateDirty = true; + } + } + } + + public ANX.Framework.Graphics.TextureAddressMode AddressV + { + set + { + SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + + if (description.AddressV != mode) + { + description.AddressV = mode; + nativeSamplerStateDirty = true; + } + } + } + + public ANX.Framework.Graphics.TextureAddressMode AddressW + { + set + { + SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + + if (description.AddressW != mode) + { + description.AddressW = mode; + nativeSamplerStateDirty = true; + } + } + } + + public TextureFilter Filter + { + set + { + SharpDX.Direct3D10.Filter filter = FormatConverter.Translate(value); + + if (description.Filter != filter) + { + description.Filter = filter; + nativeSamplerStateDirty = true; + } + } + } + + public int MaxAnisotropy + { + set + { + if (description.MaximumAnisotropy != value) + { + description.MaximumAnisotropy = value; + nativeSamplerStateDirty = true; + } + } + } + + public int MaxMipLevel + { + set + { + if (description.MaximumLod != value) + { + description.MaximumLod = value; + nativeSamplerStateDirty = true; + } + } + } + + public float MipMapLevelOfDetailBias + { + set + { + if (description.MipLodBias != value) + { + description.MipLodBias = value; + nativeSamplerStateDirty = true; + } + } + } + + public void Dispose() + { + if (this.nativeSamplerState != null) + { + this.nativeSamplerState.Dispose(); + this.nativeSamplerState = null; + } + } + + private void UpdateNativeSamplerState(Device device) + { + if (this.nativeSamplerStateDirty == true || this.nativeSamplerState == null) + { + if (this.nativeSamplerState != null) + { + this.nativeSamplerState.Dispose(); + this.nativeSamplerState = null; + } + + this.nativeSamplerState = new SharpDX.Direct3D10.SamplerState(device, ref this.description); + + this.nativeSamplerStateDirty = false; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs new file mode 100644 index 00000000..db0e54a2 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs @@ -0,0 +1,727 @@ +#region Using Statements +using System; +#endregion // Using Statements + +#region License +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + internal static class ShaderByteCode + { + #region SpriteBatchShader + internal static byte[] SpriteBatchByteCode = new byte[] + { + 068, + 088, 066, 067, 076, 188, 007, 250, 222, 184, 008, 085, 030, 093, 218, 008, 162, 103, 199, 180, 001, + 000, 000, 000, 044, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 000, + 008, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 012, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, + 117, 101, 000, 083, 112, 114, 105, 116, 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 000, 001, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, + 023, 212, 206, 149, 008, 160, 173, 236, 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, + 003, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, + 001, 000, 000, 004, 003, 000, 000, 082, 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, + 000, 000, 000, 001, 000, 000, 000, 028, 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, + 000, 000, 000, 060, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, + 097, 108, 115, 000, 171, 171, 171, 060, 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, + 000, 000, 000, 002, 000, 000, 000, 136, 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, + 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, + 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, + 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, + 083, 071, 078, 104, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 095, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, + 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, + 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, + 067, 079, 079, 082, 068, 000, 171, 083, 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, + 000, 000, 000, 089, 000, 000, 004, 070, 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, + 000, 000, 003, 242, 016, 016, 000, 000, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 095, 000, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, + 032, 016, 000, 000, 000, 000, 000, 001, 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 050, 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, + 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 017, 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, + 000, 000, 008, 066, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 002, 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 054, 000, 000, 005, 242, 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, + 000, 000, 000, 054, 000, 000, 005, 050, 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, + 000, 000, 000, 062, 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 006, 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 212, 000, 000, 000, 000, 000, 000, 000, 160, + 002, 000, 000, 068, 088, 066, 067, 029, 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, + 029, 105, 032, 001, 000, 000, 000, 160, 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, + 000, 000, 000, 084, 001, 000, 000, 136, 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, + 004, 255, 255, 000, 001, 000, 000, 115, 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, + 000, 000, 000, 107, 000, 000, 000, 002, 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 001, 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, + 114, 101, 083, 097, 109, 112, 108, 101, 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, + 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, + 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, + 050, 046, 051, 049, 049, 049, 000, 073, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, + 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, + 000, 000, 000, 015, 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, + 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, + 068, 000, 171, 079, 083, 071, 078, 044, 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 083, 086, 095, 084, 097, 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, + 000, 000, 000, 064, 000, 000, 000, 037, 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, + 000, 000, 000, 088, 024, 000, 004, 000, 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, + 016, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, + 000, 000, 000, 069, 000, 000, 009, 242, 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, + 000, 000, 000, 070, 126, 016, 000, 000, 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, + 000, 000, 007, 242, 032, 016, 000, 000, 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 001, 000, 000, 000, 062, 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 096, 004, 000, 000, 000, + 000, 000, 000, 004, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 050, 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, + 000, 000, 000, 000, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, + 000, 000, 000, 000, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 184, 000, 000, 000, 003, 000, 000, 000, 000, + 000, 000, 000, 008, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 200, 000, 000, 000, 006, + 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 088, 004, 000, 000, 007, 000, 000, 000, 000, + 000, 000, 000, 007, 000, 000, 000, 004, 007, 000, 000 + }; + #endregion //SpriteBatchShader + + #region AlphaTestEffectShader + internal static byte[] AlphaTestEffectByteCode = new byte[] + { + 068, + 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, + 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, + 007, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 004, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, + 104, 097, 084, 101, 115, 116, 080, 097, 115, 115, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, 023, 212, 206, 149, 008, 160, 173, 236, + 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, 003, 000, 000, 005, 000, 000, 000, 052, + 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, 001, 000, 000, 004, 003, 000, 000, 082, + 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 028, + 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, 000, 000, 000, 060, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 171, 171, 171, 060, + 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 136, + 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, + 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 077, + 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, + 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, 083, 071, 078, 104, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 095, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, + 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, + 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, + 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 083, + 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, 000, 000, 000, 089, 000, 000, 004, 070, + 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 000, + 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 095, 000, 000, 003, 050, + 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, 032, 016, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 050, + 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 000, 000, 000, 000, 017, + 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, 000, 000, 008, 066, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 002, + 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, 000, 000, 000, 054, 000, 000, 005, 242, + 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 054, 000, 000, 005, 050, + 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 062, 000, 000, 001, 083, + 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 006, + 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 204, 000, 000, 000, 000, 000, 000, 000, 160, 002, 000, 000, 068, 088, 066, 067, 029, + 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, 029, 105, 032, 001, 000, 000, 000, 160, + 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, 000, 000, 000, 084, 001, 000, 000, 136, + 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 115, + 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, 000, 000, 000, 107, 000, 000, 000, 002, + 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 001, + 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, + 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, + 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, + 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 073, + 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, + 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 079, 083, 071, 078, 044, + 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 083, 086, 095, 084, 097, + 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, 000, 000, 000, 064, 000, 000, 000, 037, + 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, 000, 000, 000, 088, 024, 000, 004, 000, + 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, 016, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 101, 000, 000, 003, 242, + 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, 000, 000, 000, 069, 000, 000, 009, 242, + 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 070, 126, 016, 000, 000, + 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, 000, 000, 007, 242, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 062, + 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 088, 004, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 050, + 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, + 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, + 006, 000, 000 + }; + #endregion //AlphaTestEffectShader + + #region BasicEffectShader + internal static byte[] BasicEffectByteCode = new byte[] + { + 068, + 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, + 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, + 007, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 004, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, + 104, 097, 084, 101, 115, 116, 080, 097, 115, 115, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, 023, 212, 206, 149, 008, 160, 173, 236, + 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, 003, 000, 000, 005, 000, 000, 000, 052, + 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, 001, 000, 000, 004, 003, 000, 000, 082, + 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 028, + 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, 000, 000, 000, 060, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 171, 171, 171, 060, + 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 136, + 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, + 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 077, + 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, + 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, 083, 071, 078, 104, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 095, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, + 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, + 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, + 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 083, + 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, 000, 000, 000, 089, 000, 000, 004, 070, + 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 000, + 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 095, 000, 000, 003, 050, + 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, 032, 016, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 050, + 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 000, 000, 000, 000, 017, + 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, 000, 000, 008, 066, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 002, + 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, 000, 000, 000, 054, 000, 000, 005, 242, + 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 054, 000, 000, 005, 050, + 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 062, 000, 000, 001, 083, + 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 006, + 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 204, 000, 000, 000, 000, 000, 000, 000, 160, 002, 000, 000, 068, 088, 066, 067, 029, + 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, 029, 105, 032, 001, 000, 000, 000, 160, + 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, 000, 000, 000, 084, 001, 000, 000, 136, + 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 115, + 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, 000, 000, 000, 107, 000, 000, 000, 002, + 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 001, + 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, + 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, + 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, + 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 073, + 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, + 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 079, 083, 071, 078, 044, + 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 083, 086, 095, 084, 097, + 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, 000, 000, 000, 064, 000, 000, 000, 037, + 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, 000, 000, 000, 088, 024, 000, 004, 000, + 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, 016, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 101, 000, 000, 003, 242, + 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, 000, 000, 000, 069, 000, 000, 009, 242, + 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 070, 126, 016, 000, 000, + 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, 000, 000, 007, 242, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 062, + 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 088, 004, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 050, + 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, + 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, + 006, 000, 000 + }; + #endregion //BasicEffectShader + + #region DualTextureEffectShader + internal static byte[] DualTextureEffectByteCode = new byte[] + { + 068, + 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, + 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, + 007, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 004, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, + 104, 097, 084, 101, 115, 116, 080, 097, 115, 115, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, 023, 212, 206, 149, 008, 160, 173, 236, + 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, 003, 000, 000, 005, 000, 000, 000, 052, + 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, 001, 000, 000, 004, 003, 000, 000, 082, + 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 028, + 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, 000, 000, 000, 060, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 171, 171, 171, 060, + 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 136, + 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, + 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 077, + 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, + 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, 083, 071, 078, 104, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 095, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, + 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, + 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, + 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 083, + 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, 000, 000, 000, 089, 000, 000, 004, 070, + 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 000, + 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 095, 000, 000, 003, 050, + 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, 032, 016, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 050, + 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 000, 000, 000, 000, 017, + 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, 000, 000, 008, 066, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 002, + 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, 000, 000, 000, 054, 000, 000, 005, 242, + 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 054, 000, 000, 005, 050, + 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 062, 000, 000, 001, 083, + 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 006, + 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 204, 000, 000, 000, 000, 000, 000, 000, 160, 002, 000, 000, 068, 088, 066, 067, 029, + 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, 029, 105, 032, 001, 000, 000, 000, 160, + 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, 000, 000, 000, 084, 001, 000, 000, 136, + 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 115, + 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, 000, 000, 000, 107, 000, 000, 000, 002, + 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 001, + 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, + 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, + 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, + 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 073, + 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, + 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 079, 083, 071, 078, 044, + 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 083, 086, 095, 084, 097, + 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, 000, 000, 000, 064, 000, 000, 000, 037, + 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, 000, 000, 000, 088, 024, 000, 004, 000, + 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, 016, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 101, 000, 000, 003, 242, + 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, 000, 000, 000, 069, 000, 000, 009, 242, + 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 070, 126, 016, 000, 000, + 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, 000, 000, 007, 242, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 062, + 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 088, 004, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 050, + 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, + 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, + 006, 000, 000 + }; + #endregion //DualTextureEffectShader + + #region EnvironmentMapEffectShader + internal static byte[] EnvironmentMapEffectByteCode = new byte[] + { + 068, + 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, + 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, + 007, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 004, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, + 104, 097, 084, 101, 115, 116, 080, 097, 115, 115, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, 023, 212, 206, 149, 008, 160, 173, 236, + 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, 003, 000, 000, 005, 000, 000, 000, 052, + 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, 001, 000, 000, 004, 003, 000, 000, 082, + 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 028, + 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, 000, 000, 000, 060, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 171, 171, 171, 060, + 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 136, + 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, + 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 077, + 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, + 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, 083, 071, 078, 104, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 095, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, + 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, + 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, + 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 083, + 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, 000, 000, 000, 089, 000, 000, 004, 070, + 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 000, + 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 095, 000, 000, 003, 050, + 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, 032, 016, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 050, + 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 000, 000, 000, 000, 017, + 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, 000, 000, 008, 066, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 002, + 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, 000, 000, 000, 054, 000, 000, 005, 242, + 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 054, 000, 000, 005, 050, + 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 062, 000, 000, 001, 083, + 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 006, + 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 204, 000, 000, 000, 000, 000, 000, 000, 160, 002, 000, 000, 068, 088, 066, 067, 029, + 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, 029, 105, 032, 001, 000, 000, 000, 160, + 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, 000, 000, 000, 084, 001, 000, 000, 136, + 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 115, + 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, 000, 000, 000, 107, 000, 000, 000, 002, + 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 001, + 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, + 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, + 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, + 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 073, + 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, + 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 079, 083, 071, 078, 044, + 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 083, 086, 095, 084, 097, + 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, 000, 000, 000, 064, 000, 000, 000, 037, + 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, 000, 000, 000, 088, 024, 000, 004, 000, + 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, 016, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 101, 000, 000, 003, 242, + 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, 000, 000, 000, 069, 000, 000, 009, 242, + 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 070, 126, 016, 000, 000, + 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, 000, 000, 007, 242, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 062, + 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 088, 004, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 050, + 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, + 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, + 006, 000, 000 + }; + #endregion //EnvironmentMapEffectShader + + #region SkinnedEffectShader + internal static byte[] SkinnedEffectByteCode = new byte[] + { + 068, + 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, + 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, + 007, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 004, 007, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052, + 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, + 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012, + 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116, + 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, + 097, 109, 112, 108, 101, 114, 000, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, + 104, 097, 084, 101, 115, 116, 080, 097, 115, 115, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000, + 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093, 023, 212, 206, 149, 008, 160, 173, 236, + 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128, 003, 000, 000, 005, 000, 000, 000, 052, + 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236, 001, 000, 000, 004, 003, 000, 000, 082, + 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 028, + 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152, 000, 000, 000, 060, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 171, 171, 171, 060, + 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 136, + 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, + 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 077, + 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, + 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073, 083, 071, 078, 104, 000, 000, 000, 003, + 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 095, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, + 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, + 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, + 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, + 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, + 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 083, + 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068, 000, 000, 000, 089, 000, 000, 004, 070, + 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 000, + 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 095, 000, 000, 003, 050, + 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242, 032, 016, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 050, + 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, 000, 000, 000, 070, + 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 000, 000, 000, 000, 017, + 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017, 000, 000, 008, 066, 032, 016, 000, 000, + 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 002, + 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003, 000, 000, 000, 054, 000, 000, 005, 242, + 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 054, 000, 000, 005, 050, + 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 062, 000, 000, 001, 083, + 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 006, + 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 204, 000, 000, 000, 000, 000, 000, 000, 160, 002, 000, 000, 068, 088, 066, 067, 029, + 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096, 029, 105, 032, 001, 000, 000, 000, 160, + 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224, 000, 000, 000, 084, 001, 000, 000, 136, + 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 115, + 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001, 000, 000, 000, 107, 000, 000, 000, 002, + 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 001, + 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, + 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, + 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, + 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 073, + 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, + 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, + 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, + 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 171, 079, 083, 071, 078, 044, + 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 083, 086, 095, 084, 097, + 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148, 000, 000, 000, 064, 000, 000, 000, 037, + 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000, 000, 000, 000, 088, 024, 000, 004, 000, + 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098, 016, 000, 003, 242, 016, 016, 000, 001, + 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 101, 000, 000, 003, 242, + 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001, 000, 000, 000, 069, 000, 000, 009, 242, + 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002, 000, 000, 000, 070, 126, 016, 000, 000, + 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056, 000, 000, 007, 242, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 001, 000, 000, 000, 062, + 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 088, 004, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 050, + 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125, 000, 000, 000, 000, 000, 000, 000, 255, + 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 001, 000, 000, 000, 000, + 000, 000, 000, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, + 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, + 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, + 006, 000, 000 + }; + #endregion //SkinnedEffectShader + + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs new file mode 100644 index 00000000..47dd0824 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs @@ -0,0 +1,316 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.Graphics; +using SharpDX.Direct3D10; +using ANX.Framework.NonXNA.RenderSystem; +using System.IO; +using System.Runtime.InteropServices; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class Texture2D_DX10 : INativeTexture2D + { + #region Private Members + protected internal SharpDX.Direct3D10.Texture2D nativeTexture; + protected internal SharpDX.Direct3D10.ShaderResourceView nativeShaderResourceView; + protected internal int formatSize; + protected internal SurfaceFormat surfaceFormat; + protected internal GraphicsDevice graphicsDevice; + + #endregion // Private Members + + internal Texture2D_DX10(GraphicsDevice graphicsDevice) + { + this.graphicsDevice = graphicsDevice; + } + + public Texture2D_DX10(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount) + { + if (mipCount > 1) + { + throw new Exception("creating textures with mip map not yet implemented"); + } + + this.graphicsDevice = graphicsDevice; + this.surfaceFormat = surfaceFormat; + + GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + + SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription() + { + Width = width, + Height = height, + MipLevels = mipCount, + ArraySize = mipCount, + Format = FormatConverter.Translate(surfaceFormat), + SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), + Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic, + BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource, + CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write, + OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None, + }; + this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description); + this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture); + + // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx + // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx + + this.formatSize = FormatConverter.FormatSize(surfaceFormat); + } + + public override int GetHashCode() + { + return NativeTexture.NativePointer.ToInt32(); + } + + internal SharpDX.Direct3D10.Texture2D NativeTexture + { + get + { + return this.nativeTexture; + } + set + { + if (this.nativeTexture != value) + { + if (this.nativeTexture != null) + { + this.nativeTexture.Dispose(); + } + + this.nativeTexture = value; + } + } + } + + internal SharpDX.Direct3D10.ShaderResourceView NativeShaderResourceView + { + get + { + return this.nativeShaderResourceView; + } + set + { + if (this.nativeShaderResourceView != value) + { + if (this.nativeShaderResourceView != null) + { + this.nativeShaderResourceView.Dispose(); + } + + this.nativeShaderResourceView = value; + } + } + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct + { + SetData(graphicsDevice, 0, data, 0, data.Length); + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct + { + SetData(graphicsDevice, 0, data, startIndex, elementCount); + } + + public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct + { + //TODO: handle offsetInBytes parameter + //TODO: handle startIndex parameter + //TODO: handle elementCount parameter + + if (this.surfaceFormat == SurfaceFormat.Color) + { + int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1); + SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None); + int rowPitch = rectangle.Pitch; + + unsafe + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + byte* colorData = (byte*)handle.AddrOfPinnedObject(); + + byte* pTexels = (byte*)rectangle.DataPointer; + int srcIndex = 0; + + for (int row = 0; row < Height; row++) + { + int rowStart = row * rowPitch; + + for (int col = 0; col < Width; col++) + { + int colStart = col * formatSize; + pTexels[rowStart + colStart + 0] = colorData[srcIndex++]; + pTexels[rowStart + colStart + 1] = colorData[srcIndex++]; + pTexels[rowStart + colStart + 2] = colorData[srcIndex++]; + pTexels[rowStart + colStart + 3] = colorData[srcIndex++]; + } + } + + handle.Free(); + } + + this.nativeTexture.Unmap(subresource); + } + else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1) + { + unsafe + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + byte* colorData = (byte*)handle.AddrOfPinnedObject(); + + int w = (Width + 3) >> 2; + int h = (Height + 3) >> 2; + formatSize = (surfaceFormat == SurfaceFormat.Dxt1) ? 8 : 16; + + int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1); + SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None); + SharpDX.DataStream ds = new SharpDX.DataStream(rectangle.DataPointer, Width * Height * 4 * 2, true, true); + int pitch = rectangle.Pitch; + int col = 0; + int index = 0; // startIndex + int count = data.Length; // elementCount + int actWidth = w * formatSize; + + for (int i = 0; i < h; i++) + { + ds.Position = (i * pitch) + (col * formatSize); + if (count <= 0) + { + break; + } + else if (count < actWidth) + { + for (int idx = index; idx < index + count; idx++) + { + ds.WriteByte(colorData[idx]); + } + //ds.WriteRange(colorDataArray, index, count); + + break; + } + + for (int idx = index; idx < index + actWidth; idx++) + { + ds.WriteByte(colorData[idx]); + } + //ds.WriteRange(colorDataArray, index, actWidth); + + index += actWidth; + count -= actWidth; + } + + handle.Free(); + + this.nativeTexture.Unmap(subresource); + } + } + else + { + throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString())); + } + } + + public int Width + { + get + { + if (this.nativeTexture != null) + { + return this.nativeTexture.Description.Width; + } + + return 0; + } + } + + public int Height + { + get + { + if (this.nativeTexture != null) + { + return this.nativeTexture.Description.Height; + } + + return 0; + } + } + + public GraphicsDevice GraphicsDevice + { + get + { + return this.graphicsDevice; + } + } + + public void Dispose() + { + if (this.nativeShaderResourceView != null) + { + this.nativeShaderResourceView.Dispose(); + this.nativeShaderResourceView = null; + } + + if (this.nativeTexture != null) + { + this.nativeTexture.Dispose(); + this.nativeTexture = null; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs new file mode 100644 index 00000000..257e446a --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs @@ -0,0 +1,158 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using SharpDX.Direct3D10; +using ANX.Framework.Graphics; +using System.Runtime.InteropServices; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework.Windows.DX10 +{ + public class VertexBuffer_DX10 : INativeBuffer, IDisposable + { + SharpDX.Direct3D10.Buffer buffer; + int vertexStride; + + public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + this.vertexStride = vertexDeclaration.VertexStride; + + //TODO: translate and use usage + + GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; + SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; + + if (device != null) + { + BufferDescription description = new BufferDescription() + { + Usage = ResourceUsage.Dynamic, + SizeInBytes = vertexDeclaration.VertexStride * vertexCount, + BindFlags = BindFlags.VertexBuffer, + CpuAccessFlags = CpuAccessFlags.Write, + OptionFlags = ResourceOptionFlags.None + }; + + this.buffer = new SharpDX.Direct3D10.Buffer(device, description); + this.buffer.Unmap(); + } + } + + public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct + { + //TODO: check offsetInBytes parameter for bounds etc. + + GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); + IntPtr dataPointer = pinnedArray.AddrOfPinnedObject(); + + int dataLength = Marshal.SizeOf(typeof(T)) * data.Length; + + unsafe + { + using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false)) + { + if (offsetInBytes > 0) + { + vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin); + } + + using (var d = buffer.Map(MapMode.WriteDiscard)) + { + if (startIndex > 0 || elementCount < data.Length) + { + for (int i = startIndex; i < startIndex + elementCount; i++) + { + d.Write(data[i]); + } + } + else + { + vData.CopyTo(d); + } + buffer.Unmap(); + } + } + } + + pinnedArray.Free(); + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct + { + SetData(graphicsDevice, data, 0, data.Length); + } + + public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct + { + SetData(graphicsDevice, 0, data, startIndex, elementCount); + } + + public SharpDX.Direct3D10.Buffer NativeBuffer + { + get + { + return this.buffer; + } + } + + public void Dispose() + { + if (this.buffer != null) + { + buffer.Dispose(); + buffer = null; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs new file mode 100644 index 00000000..f0712769 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs @@ -0,0 +1,136 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using ANX.Framework.Windows.DX10; +using ANX.Framework.Input; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework +{ + public class WindowsGameHost : GameHost + { + private Game game; + private WindowsGameWindow gameWindow; + private bool exitRequested; + + public WindowsGameHost(Game game) + : base(game) + { + this.game = game; + //this.LockThreadToProcessor(); + this.gameWindow = new WindowsGameWindow(); + Mouse.WindowHandle = this.gameWindow.Handle; //TODO: find a way to initialize all InputSystems with one Handle + Keyboard.WindowHandle = this.gameWindow.Handle; + //TouchPanel.WindowHandle = this.gameWindow.Handle; + //this.gameWindow.IsMouseVisible = game.IsMouseVisible; + this.gameWindow.Activated += new EventHandler(this.GameWindowActivated); + this.gameWindow.Deactivated += new EventHandler(this.GameWindowDeactivated); + //this.gameWindow.Suspend += new EventHandler(this.GameWindowSuspend); + //this.gameWindow.Resume += new EventHandler(this.GameWindowResume); + + } + + public override void Run() + { + Application.Idle += new EventHandler(this.ApplicationIdle); + Application.Run(this.gameWindow.Form); + Application.Idle -= this.ApplicationIdle; + } + + public void RunOneFrame() + { + //this.gameWindow.Tick(); + base.OnIdle(); + } + + public override GameWindow Window + { + get + { + return this.gameWindow; + } + } + + public override void Exit() + { + this.exitRequested = true; + } + + private void GameWindowActivated(object sender, EventArgs e) + { + base.OnActivated(); + } + + private void GameWindowDeactivated(object sender, EventArgs e) + { + base.OnDeactivated(); + } + + private void ApplicationIdle(object sender, EventArgs e) + { + NativeMethods.Message message; + while (!NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 0)) + { + if (this.exitRequested) + { + this.gameWindow.Close(); + } + else + { + this.RunOneFrame(); + } + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs new file mode 100644 index 00000000..7493657f --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs @@ -0,0 +1,162 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using SharpDX.Windows; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.Framework +{ + internal class WindowsGameWindow : GameWindow + { + #region Private Members + private RenderForm gameWindow; + + #endregion // Private Members + + internal WindowsGameWindow() + { + this.gameWindow = new RenderForm("ANX.Framework"); + + this.gameWindow.Width = 800; + this.gameWindow.Height = 480; + + this.gameWindow.MaximizeBox = false; + this.gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D; + } + + public void Close() + { + if (gameWindow != null) + { + gameWindow.Close(); + } + } + + public Form Form + { + get + { + return gameWindow; + } + } + + public override IntPtr Handle + { + get + { + return gameWindow.Handle; + } + } + + public override bool IsMinimized + { + get + { + return gameWindow.WindowState == FormWindowState.Minimized; + } + } + + public override void BeginScreenDeviceChange(bool willBeFullScreen) + { + throw new NotImplementedException(); + } + + public override void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight) + { + throw new NotImplementedException(); + } + + protected override void SetTitle(string title) + { + this.gameWindow.Text = title; + } + + public override bool AllowUserResizing + { + get + { + return gameWindow.FormBorderStyle == FormBorderStyle.Sizable; + } + set + { + if (value) + { + gameWindow.FormBorderStyle = FormBorderStyle.Sizable; + } + else + { + gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D; + } + } + } + + public override Rectangle ClientBounds + { + get + { + return new Rectangle(this.gameWindow.ClientRectangle.Left, this.gameWindow.ClientRectangle.Top, this.gameWindow.ClientRectangle.Width, this.gameWindow.ClientRectangle.Height); + } + } + + public override string ScreenDeviceName + { + get { throw new NotImplementedException(); } + } + + public override DisplayOrientation CurrentOrientation + { + get { throw new NotImplementedException(); } + } + } +}