Permalink
Browse files

Merge branch 'develop3d' into mgfx3

  • Loading branch information...
tomspilman committed Feb 13, 2013
2 parents 524476d + 62a1522 commit 9897eb0d13aa2b2bda10a7a865b83daf6fc59b29
Showing with 593 additions and 387 deletions.
  1. +54 −3 MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.MacOS.csproj
  2. +20 −2 MonoGame.Framework.Content.Pipeline/Serialization/Compiler/BuiltInContentWriter.cs
  3. +50 −3 MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentCompiler.cs
  4. +5 −0 MonoGame.Framework.Content.Pipeline/Serialization/Compiler/ContentWriter.cs
  5. +19 −10 MonoGame.Framework.Content.Pipeline/TextureImporter.cs
  6. +2 −0 MonoGame.Framework/Audio/SoundEffectInstance.cs
  7. +4 −4 MonoGame.Framework/Content/ContentReaders/SongReader.cs
  8. +16 −3 MonoGame.Framework/Graphics/GraphicsDevice.cs
  9. +9 −9 MonoGame.Framework/Graphics/States/BlendState.cs
  10. +1 −1 MonoGame.Framework/Media/MediaPlayer.cs
  11. +26 −21 MonoGame.Framework/MonoGame.Framework.MacOS.csproj
  12. +4 −0 MonoGame.Framework/Properties/AssemblyInfo.cs
  13. +0 −4 MonoGame.Framework/WindowsPhone/WPGamePlatform.cs
  14. +1 −0 MonoGame.Framework/WindowsPhone/XamlGame.cs
  15. +1 −1 MonoGame.Framework/iOS/Devices/Sensors/Accelerometer.cs
  16. +1 −1 MonoGame.Framework/iOS/Devices/Sensors/Compass.cs
  17. +8 −5 README.md
  18. +1 −1 ThirdParty/Libs
  19. +2 −2 Tools/2MGFX/DXShaderData.mojo.cs
  20. +2 −2 Tools/2MGFX/DXShaderData.sharpdx.cs
  21. +9 −137 Tools/2MGFX/MGFX.tpg
  22. +11 −139 Tools/2MGFX/ParseTree.cs
  23. +297 −6 Tools/2MGFX/ShaderInfo.cs
  24. +14 −2 Tools/MGCB/MGCB.MacOS.csproj
  25. +9 −0 Tools/MGCB/MGCB.MacOS.sln
  26. +4 −0 Tools/MGCB/Nvidia.TextureTools.dll.config
  27. +23 −31 default.build
@@ -13,17 +13,17 @@
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
+ <DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
- <Optimize>false</Optimize>
+ <Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MACOS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
+ <Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MACOS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
@@ -41,6 +41,12 @@
<Reference Include="NAudio">
<HintPath>..\ThirdParty\Libs\NAudio\NAudio.dll</HintPath>
</Reference>
+ <Reference Include="Nvidia.TextureTools">
+ <HintPath>..\ThirdParty\Libs\NVTT\Windows\Nvidia.TextureTools.dll</HintPath>
+ </Reference>
+ <Reference Include="MonoMac, Version=0.0.0.0, Culture=neutral">
+ <Private>False</Private>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Audio\AudioContent.cs" />
@@ -146,6 +152,45 @@
<Compile Include="WmvImporter.cs" />
<Compile Include="XImporter.cs" />
<Compile Include="XmlImporter.cs" />
+ <Compile Include="Serialization\Compiler\ArrayWriter.cs" />
+ <Compile Include="Serialization\Compiler\BooleanWriter.cs" />
+ <Compile Include="Serialization\Compiler\BoundingBoxWriter.cs" />
+ <Compile Include="Serialization\Compiler\BoundingFrustumWriter.cs" />
+ <Compile Include="Serialization\Compiler\BoundingSphereWriter.cs" />
+ <Compile Include="Serialization\Compiler\BuiltInContentWriter.cs" />
+ <Compile Include="Serialization\Compiler\ByteWriter.cs" />
+ <Compile Include="Serialization\Compiler\CharWriter.cs" />
+ <Compile Include="Serialization\Compiler\ColorWriter.cs" />
+ <Compile Include="Serialization\Compiler\CurveWriter.cs" />
+ <Compile Include="Serialization\Compiler\DateTimeWriter.cs" />
+ <Compile Include="Serialization\Compiler\DecimalWriter.cs" />
+ <Compile Include="Serialization\Compiler\DictionaryWriter.cs" />
+ <Compile Include="Serialization\Compiler\DoubleWriter.cs" />
+ <Compile Include="Serialization\Compiler\EnumWriter.cs" />
+ <Compile Include="Serialization\Compiler\ExternalReferenceWriter.cs" />
+ <Compile Include="Serialization\Compiler\Int16Writer.cs" />
+ <Compile Include="Serialization\Compiler\Int32Writer.cs" />
+ <Compile Include="Serialization\Compiler\Int64Writer.cs" />
+ <Compile Include="Serialization\Compiler\ListWriter.cs" />
+ <Compile Include="Serialization\Compiler\MatrixWriter.cs" />
+ <Compile Include="Serialization\Compiler\NullableWriter.cs" />
+ <Compile Include="Serialization\Compiler\PlaneWriter.cs" />
+ <Compile Include="Serialization\Compiler\PointWriter.cs" />
+ <Compile Include="Serialization\Compiler\QuaternionWriter.cs" />
+ <Compile Include="Serialization\Compiler\RayWriter.cs" />
+ <Compile Include="Serialization\Compiler\RectangleWriter.cs" />
+ <Compile Include="Serialization\Compiler\SByteWriter.cs" />
+ <Compile Include="Serialization\Compiler\SingleWriter.cs" />
+ <Compile Include="Serialization\Compiler\StringWriter.cs" />
+ <Compile Include="Serialization\Compiler\TimeSpanWriter.cs" />
+ <Compile Include="Serialization\Compiler\UInt16Writer.cs" />
+ <Compile Include="Serialization\Compiler\UInt32Writer.cs" />
+ <Compile Include="Serialization\Compiler\UInt64Writer.cs" />
+ <Compile Include="Serialization\Compiler\Vector2Writer.cs" />
+ <Compile Include="Serialization\Compiler\Vector3Writer.cs" />
+ <Compile Include="Serialization\Compiler\Vector4Writer.cs" />
+ <Compile Include="Graphics\DXTBitmapContent.cs" />
+ <Compile Include="Graphics\PVRTCBitmapContent.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -155,4 +200,10 @@
<Target Name="AfterBuild">
</Target>
-->
+ <ItemGroup>
+ <ProjectReference Include="..\MonoGame.Framework\MonoGame.Framework.MacOS.csproj">
+ <Project>{36C538E6-C32A-4A8D-A39C-566173D7118E}</Project>
+ <Name>MonoGame.Framework.MacOS</Name>
+ </ProjectReference>
+ </ItemGroup>
</Project>
@@ -30,9 +30,27 @@ public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
// Change "Writer" in this class name to "Reader" and use the runtime type namespace and assembly
string readerClassName = this.GetType().Name.Replace("Writer", "Reader");
+
+ // Add generic arguments if they exist
+ var args = this.GetType().GetGenericArguments();
+ if (args.Length > 0)
+ {
+ readerClassName += "[";
+ for (int i = 0; i < args.Length; ++i)
+ {
+ var arg = args[i];
+ readerClassName += "[";
+ readerClassName += arg.AssemblyQualifiedName;
+ readerClassName += "]";
+ if (i < args.Length - 1)
+ readerClassName += ", ";
+ }
+ readerClassName += "]";
+ }
+
string readerNamespace = typeof(ContentTypeReader).Namespace;
- string assemblyName = typeof(ContentTypeReader).Assembly.FullName;
- return readerNamespace + "." + readerClassName + ", " + assemblyName;
+ // From looking at XNA-produced XNBs, it appears built-in type readers don't need assembly qualification
+ return readerNamespace + "." + readerClassName;
}
}
}
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
+using System.Reflection;
namespace Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler
{
@@ -51,7 +52,7 @@ void GetTypeWriters()
{
// Find the content type this writer implements
Type baseType = type.BaseType;
- while ((baseType != null) && (baseType.Name != contentTypeWriterType.Name))
+ while ((baseType != null) && (baseType.GetGenericTypeDefinition() != contentTypeWriterType))
baseType = baseType.BaseType;
if (baseType != null)
typeWriterMap.Add(baseType, type);
@@ -68,11 +69,57 @@ void GetTypeWriters()
/// <remarks>This should be called from the ContentTypeWriter.Initialize method.</remarks>
public ContentTypeWriter GetTypeWriter(Type type)
{
+ ContentTypeWriter result = null;
var contentTypeWriterType = typeof(ContentTypeWriter<>).MakeGenericType(type);
Type typeWriterType;
if (!typeWriterMap.TryGetValue(contentTypeWriterType, out typeWriterType))
- throw new InvalidContentException(String.Format("Could not find ContentTypeWriter for type '{0}'", type.Name));
- var result = (ContentTypeWriter)Activator.CreateInstance(typeWriterType);
+ {
+ var inputTypeDef = type.GetGenericTypeDefinition();
+
+ Type chosen = null;
+ foreach (var kvp in typeWriterMap)
+ {
+ var args = kvp.Key.GetGenericArguments();
+
+ if (args.Length == 0)
+ continue;
+
+ if (!args[0].IsGenericType)
+ continue;
+
+ // Compare generic type definition
+ var keyTypeDef = args[0].GetGenericTypeDefinition();
+ if (inputTypeDef.Equals(keyTypeDef))
+ {
+ chosen = kvp.Value;
+ break;
+ }
+ }
+
+ try
+ {
+ var concreteType = type.GetGenericArguments();
+ result = (ContentTypeWriter)Activator.CreateInstance(chosen.MakeGenericType(concreteType));
+
+ // save it for next time.
+ typeWriterMap.Add(contentTypeWriterType, result.GetType());
+ }
+ catch (Exception)
+ {
+ throw new InvalidContentException(String.Format("Could not find ContentTypeWriter for type '{0}'", type.Name));
+ }
+ }
+ else
+ {
+ result = (ContentTypeWriter)Activator.CreateInstance(typeWriterType);
+ }
+
+ if (result != null)
+ {
+ MethodInfo dynMethod = result.GetType().GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance);
+ dynMethod.Invoke(result, new object[] { this });
+ }
+
return result;
}
@@ -242,6 +242,10 @@ internal ContentTypeWriter GetTypeWriter(Type type)
typeWriters.Add(typeWriter);
typeWriterMap.Add(typeWriter, index);
typeMap.Add(type, typeWriter);
+
+ var args = type.GetGenericArguments();
+ foreach (var arg in args)
+ GetTypeWriter(arg);
}
return typeWriter;
}
@@ -289,6 +293,7 @@ public void WriteExternalReference<T>(ExternalReference<T> reference)
/// <remarks>This method can be called recursively with a null value.</remarks>
public void WriteObject<T>(T value)
{
+ GetTypeWriter(typeof(Dictionary<int, List<string>>));
WriteObject<T>(value, GetTypeWriter(value.GetType()));
}
@@ -27,19 +27,28 @@ public TextureImporter()
/// <param name="filename">Name of a game asset file.</param>
/// <param name="context">Contains information for importing a game asset, such as a logger interface.</param>
/// <returns>Resulting game asset.</returns>
- public override TextureContent Import(string filename, ContentImporterContext context)
- {
- var output = new Texture2DContent();
- output._bitmap = new Bitmap(filename);
+ public override TextureContent Import (string filename, ContentImporterContext context)
+ {
+ var output = new Texture2DContent ();
+ output._bitmap = new Bitmap (filename);
+
+ var width = output._bitmap.Width;
+ var height = output._bitmap.Height;
+
+ // Force the input's pixelformat to ARGB32, so we can have a common pixel format to deal with.
+ if (output._bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb) {
+
+ var bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ using ( var graphics = System.Drawing.Graphics.FromImage(bitmap)) {
+ graphics.DrawImage(output._bitmap, 0,0, width, height);
+ }
- // Force the input's pixelformat to ARGB32, so we can have a common pixel format to deal with.
- if (output._bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb)
- output._bitmap = output._bitmap.Clone(new System.Drawing.Rectangle(System.Drawing.Point.Empty, output._bitmap.Size),
- System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ output._bitmap = bitmap;
+ }
- var imageData = output._bitmap.GetData();
+ var imageData = output._bitmap.GetData();
- var bitmapContent = new PixelBitmapContent<Color>(output._bitmap.Width, output._bitmap.Height);
+ var bitmapContent = new PixelBitmapContent<Color>(width, height);
bitmapContent.SetPixelData(imageData);
output.Faces.Add(new MipmapChain(bitmapContent));
@@ -171,6 +171,8 @@ public void Pause ()
public void Play ()
{
+ if (State == SoundState.Playing)
+ return;
#if DIRECTX
if (_voice != null)
{
@@ -61,7 +61,7 @@ internal static string Normalize(string fileName)
protected internal override Song Read(ContentReader input, Song existingInstance)
{
- string path = input.ReadString();
+ var path = input.ReadString();
if (!String.IsNullOrEmpty(path))
{
@@ -85,12 +85,12 @@ protected internal override Song Read(ContentReader input, Song existingInstance
path = dst.LocalPath.Substring(1);
// Adds the ContentManager's RootDirectory
- path = input.ContentManager.RootDirectoryFullPath + separator + path;
+ path = Path.Combine(input.ContentManager.RootDirectoryFullPath, path);
}
- int durationMS = input.ReadObject<int>();
+ var durationMs = input.ReadObject<int>();
- return new Song(path, durationMS);
+ return new Song(path, durationMs);
}
}
}
@@ -2078,13 +2078,26 @@ private int SetUserIndexBuffer<T>(T[] indexData, int indexOffset, int indexCount
}
#endif
- public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numbVertices, int startIndex, int primitiveCount)
+ /// <summary>
+ /// Draw geometry by indexing into the vertex buffer.
+ /// </summary>
+ /// <param name="primitiveType">The type of primitives in the index buffer.</param>
+ /// <param name="baseVertex">Used to offset the vertex range indexed from the vertex buffer.</param>
+ /// <param name="minVertexIndex">A hint of the lowest vertex indexed relative to baseVertex.</param>
+ /// <param name="numVertices">An hint of the maximum vertex indexed.</param>
+ /// <param name="startIndex">The index within the index buffer to start drawing from.</param>
+ /// <param name="primitiveCount">The number of primitives to render from the index buffer.</param>
+ /// <remarks>Note that minVertexIndex and numVertices are unused in MonoGame and will be ignored.</remarks>
+ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
{
Debug.Assert(_vertexBuffer != null, "The vertex buffer is null!");
Debug.Assert(_indexBuffer != null, "The index buffer is null!");
- if (minVertexIndex > 0)
- throw new NotImplementedException ("minVertexIndex > 0 is supported");
+ // NOTE: minVertexIndex and numVertices are only hints of the
+ // range of vertex data which will be indexed.
+ //
+ // They will only be used if the graphics API can use
+ // this range hint to optimize rendering.
#if DIRECTX
@@ -199,12 +199,12 @@ internal void ApplyState(GraphicsDevice device)
AlphaDestinationBlend == Opaque.AlphaDestinationBlend);
targetDesc.BlendOperation = GetBlendOperation(ColorBlendFunction);
- targetDesc.SourceBlend = GetBlendOption(ColorSourceBlend);
- targetDesc.DestinationBlend = GetBlendOption(ColorDestinationBlend);
+ targetDesc.SourceBlend = GetBlendOption(ColorSourceBlend, false);
+ targetDesc.DestinationBlend = GetBlendOption(ColorDestinationBlend, false);
targetDesc.AlphaBlendOperation = GetBlendOperation(AlphaBlendFunction);
- targetDesc.SourceAlphaBlend = GetBlendOption(AlphaSourceBlend);
- targetDesc.DestinationAlphaBlend = GetBlendOption(AlphaDestinationBlend);
+ targetDesc.SourceAlphaBlend = GetBlendOption(AlphaSourceBlend, true);
+ targetDesc.DestinationAlphaBlend = GetBlendOption(AlphaDestinationBlend, true);
// Set the first 4 targets to the same settings.
desc.RenderTarget[0] = targetDesc;
@@ -263,7 +263,7 @@ static private SharpDX.Direct3D11.BlendOperation GetBlendOperation(BlendFunction
}
}
- static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend)
+ static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend, bool alpha)
{
switch (blend)
{
@@ -274,7 +274,7 @@ static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend)
return SharpDX.Direct3D11.BlendOption.DestinationAlpha;
case Blend.DestinationColor:
- return SharpDX.Direct3D11.BlendOption.DestinationColor;
+ return alpha ? SharpDX.Direct3D11.BlendOption.DestinationAlpha : SharpDX.Direct3D11.BlendOption.DestinationColor;
case Blend.InverseBlendFactor:
return SharpDX.Direct3D11.BlendOption.InverseBlendFactor;
@@ -283,13 +283,13 @@ static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend)
return SharpDX.Direct3D11.BlendOption.InverseDestinationAlpha;
case Blend.InverseDestinationColor:
- return SharpDX.Direct3D11.BlendOption.InverseDestinationColor;
+ return alpha ? SharpDX.Direct3D11.BlendOption.InverseDestinationAlpha : SharpDX.Direct3D11.BlendOption.InverseDestinationColor;
case Blend.InverseSourceAlpha:
return SharpDX.Direct3D11.BlendOption.InverseSourceAlpha;
case Blend.InverseSourceColor:
- return SharpDX.Direct3D11.BlendOption.InverseSourceColor;
+ return alpha ? SharpDX.Direct3D11.BlendOption.InverseSourceAlpha : SharpDX.Direct3D11.BlendOption.InverseSourceColor;
case Blend.One:
return SharpDX.Direct3D11.BlendOption.One;
@@ -301,7 +301,7 @@ static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend)
return SharpDX.Direct3D11.BlendOption.SourceAlphaSaturate;
case Blend.SourceColor:
- return SharpDX.Direct3D11.BlendOption.SourceColor;
+ return alpha ? SharpDX.Direct3D11.BlendOption.SourceAlpha : SharpDX.Direct3D11.BlendOption.SourceColor;
case Blend.Zero:
return SharpDX.Direct3D11.BlendOption.Zero;
@@ -173,7 +173,7 @@ public static TimeSpan PlayPosition
get
{
#if WINDOWS_MEDIA_ENGINE
- return TimeSpan.Zero;
+ return TimeSpan.FromSeconds(_mediaEngineEx.CurrentTime);
#elif WINDOWS_MEDIA_SESSION
return _clock != null ? TimeSpan.FromTicks(_clock.Time) : TimeSpan.Zero;
#else
Oops, something went wrong.

0 comments on commit 9897eb0

Please sign in to comment.