Fix AssimpImporter and that Rendersystems can be loaded when creating content files, also allows Reference and Null Device for DX

If a model was imported with TargetRealTimeMaximumQuality and then
drawn, it causes a blue screen on my system (Nvidia Geforce GTC 650,
Driver version 353.62)
Also disabled Content recreation if a content project is launched with
the visual studio debugger.
This commit is contained in:
Konstantin Koch 2015-11-22 14:12:43 +01:00
parent b7223ccd92
commit d9e752b3b1
7 changed files with 58 additions and 16 deletions

View File

@ -48,11 +48,14 @@ namespace ANX.Framework.Content.Pipeline
AssimpDeploy.DeployLibraries();
Assimp.AssimpContext assimpContext = new AssimpContext();
Scene scene = assimpContext.ImportFile(filename, PostProcessPreset.TargetRealTimeMaximumQuality | PostProcessSteps.MakeLeftHanded);
return ConvertScene(scene);
using (Assimp.AssimpContext assimpContext = new AssimpContext())
{
//Don't use the preset for maximumQuality, on some sytems it causes the graphics driver to break down, which creates a blue screen when we try to draw it :(
//Everything works fine with reference device. The blue screen was experienced on a system with a Nvidia GeForce GTX 650.
Scene scene = assimpContext.ImportFile(filename, PostProcessPreset.ConvertToLeftHanded | PostProcessSteps.Triangulate | PostProcessSteps.ValidateDataStructure | PostProcessSteps.ImproveCacheLocality | PostProcessSteps.FixInFacingNormals);
return ConvertScene(scene);
}
}
private NodeContent ConvertScene(Scene scene)

View File

@ -79,6 +79,7 @@ namespace ANX.Framework.NonXNA.Reflection
#region LoadAllAssemblies
private void LoadAllAssemblies()
{
LoadAssembliesFromMemory();
LoadAssembliesFromFile();
LoadAssembliesFromNames();
@ -159,6 +160,17 @@ namespace ANX.Framework.NonXNA.Reflection
}
#endregion
#region LoadAssembliesFromMemory
private void LoadAssembliesFromMemory()
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!IgnoreAssemblies.Contains(assembly.GetName().Name) && !allAssemblies.Contains(assembly))
allAssemblies.Add(assembly);
}
}
#endregion
#region LoadAssemblyByName
private Assembly LoadAssemblyByName(string assemblyName)
{

View File

@ -57,9 +57,6 @@ namespace ANX.RenderSystem.Windows.DX11
public void SetData<T>(int level, Framework.Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{
int formatSize = DxFormatConverter.FormatSize(this.surfaceFormat);
int elementSize = Marshal.SizeOf(typeof(T));
Framework.Rectangle realRect;
if (rect.HasValue)
realRect = rect.Value;
@ -71,6 +68,10 @@ namespace ANX.RenderSystem.Windows.DX11
realRect.Height = this.Height;
}
//If we write too much, the graphics driver may break down and we cause a blue screen :(
if (SizeInBytes(level, realRect) != data.Length)
throw new ArgumentException("Not the correct amount of data to fill the region.");
UpdateSubresource(data, _nativeTexture, level, realRect);
}
@ -165,10 +166,18 @@ namespace ANX.RenderSystem.Windows.DX11
}
}
protected int SizeInBytes(int level)
protected int SizeInBytes(int level, Framework.Rectangle? rect = null)
{
int mipmapWidth = Math.Max(Width >> level, 1);
int mipmapHeight = Math.Max(Height >> level, 1);
int width = this.Width;
int height = this.Height;
if (rect.HasValue)
{
width = rect.Value.Width;
height = rect.Value.Height;
}
int mipmapWidth = Math.Max(width >> level, 1);
int mipmapHeight = Math.Max(height >> level, 1);
if (this.IsDxt)
{

View File

@ -61,7 +61,13 @@ namespace ANX.RenderSystem.Windows.DX10
#else
var flags = Dx10.DeviceCreationFlags.None;
#endif
Dx10.Device.CreateWithSwapChain(Dx10.DriverType.Hardware, flags, desc, out nativeDevice, out swapChain);
var driverType = Dx10.DriverType.Hardware;
if (GraphicsAdapter.UseReferenceDevice)
driverType = DriverType.Reference;
else if (GraphicsAdapter.UseNullDevice)
driverType = DriverType.Null;
Dx10.Device.CreateWithSwapChain(driverType, flags, desc, out nativeDevice, out swapChain);
#if DEBUG
nativeDevice.DebugName = "GraphicsDevice_" + graphicsDeviceCount++;
swapChain.DebugName = "SwapChain_" + swapChainCount++;
@ -138,7 +144,7 @@ namespace ANX.RenderSystem.Windows.DX10
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
if (currentInputLayout != inputLayout)
{
nativeDevice.InputAssembler.InputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice, currentPass.Signature, this.currentVertexBuffer);
nativeDevice.InputAssembler.InputLayout = inputLayout;
currentInputLayout = inputLayout;
}
}

View File

@ -59,8 +59,14 @@ namespace ANX.RenderSystem.Windows.DX11
#else
var flags = DeviceCreationFlags.None;
#endif
var driverType = DriverType.Hardware;
if (GraphicsAdapter.UseReferenceDevice)
driverType = DriverType.Reference;
else if (GraphicsAdapter.UseNullDevice)
driverType = DriverType.Null;
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
Device.CreateWithSwapChain(DriverType.Hardware, flags, desc, out dxDevice, out swapChain);
Device.CreateWithSwapChain(driverType, flags, desc, out dxDevice, out swapChain);
nativeDevice = dxDevice.ImmediateContext;
#if DEBUG
@ -133,7 +139,7 @@ namespace ANX.RenderSystem.Windows.DX11
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
if (currentInputLayout != inputLayout)
{
nativeDevice.InputAssembler.InputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice.Device, currentPass.Signature, this.currentVertexBuffer);
nativeDevice.InputAssembler.InputLayout = inputLayout;
currentInputLayout = inputLayout;
}
}

View File

@ -92,6 +92,11 @@
<OutputPath>bin\Xbox 360\Release</OutputPath>
<CompressContent>false</CompressContent>
</Configuration>
<Configuration Name="Debug" Platform="0">
<Profile>Reach</Profile>
<OutputPath>bin\Debug</OutputPath>
<CompressContent>false</CompressContent>
</Configuration>
</Configurations>
<References>
<AssemblyReference Name="ANX.Framework.Content.Pipeline.Assimp">..\..\bin\Debug\ANX.Framework.Content.Pipeline.Assimp.dll</AssemblyReference>

View File

@ -32,7 +32,8 @@ namespace ANX.Framework.VisualStudio
config.PrepareBuild(options, false);
string target = MsBuildTarget.Build;
if ((options & (uint)VSConstants.VSStd2KCmdID.Debug) != 0 || (options & 1) != 0)
//if ((options & (uint)VSConstants.VSStd2KCmdID.Debug) != 0 || (options & 1) != 0)
if ((options & 1) != 0)
target = MsBuildTarget.Rebuild;
((ContentBuildableProjectConfig)buildableConfig).Build(options, pane, target, null);