Merging some Dx10 and Dx11 Effect and GraphicsDevice code into BaseDirectX

This commit is contained in:
SND\AstrorEnales_cp 2012-09-08 10:37:41 +00:00
parent e2f1aa32bd
commit 1bb53ec785
28 changed files with 760 additions and 831 deletions

View File

@ -82,6 +82,10 @@
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project> <Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name> <Name>ANX.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.BaseDirectX\ANX.BaseDirectX.csproj">
<Project>{A4D3AD34-E49C-4142-8620-2AFF44ED6719}</Project>
<Name>ANX.BaseDirectX</Name>
</ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj"> <ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project> <Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name> <Name>ANX.RenderSystem.Windows.DX10</Name>

View File

@ -80,6 +80,10 @@
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project> <Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name> <Name>ANX.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.BaseDirectX\ANX.BaseDirectX_Linux.csproj">
<Project>{A4D3AD34-E49C-4142-8620-2AFF44ED6719}</Project>
<Name>ANX.BaseDirectX</Name>
</ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10_Linux.csproj"> <ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10_Linux.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project> <Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name> <Name>ANX.RenderSystem.Windows.DX10</Name>

View File

@ -83,6 +83,10 @@
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project> <Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name> <Name>ANX.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.BaseDirectX\ANX.BaseDirectX_PSVita.csproj">
<Project>{A4D3AD34-E49C-4142-8620-2AFF44ED6719}</Project>
<Name>ANX.BaseDirectX</Name>
</ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10_PSVita.csproj"> <ProjectReference Include="..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10_PSVita.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project> <Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name> <Name>ANX.RenderSystem.Windows.DX10</Name>

View File

@ -81,6 +81,10 @@
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project> <Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name> <Name>ANX.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\RenderSystems\ANX.BaseDirectX\ANX.BaseDirectX_WindowsMetro.csproj">
<Project>{A4D3AD34-E49C-4142-8620-2AFF44ED6719}</Project>
<Name>ANX.BaseDirectX</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -19,7 +19,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>TRACE;DEBUG;XNAEXT</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE;XNAEXT</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -40,6 +40,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX.D3DCompiler">
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL"> <Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath>
@ -47,12 +50,15 @@
<Reference Include="System" /> <Reference Include="System" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseEffect.cs" />
<Compile Include="BaseFormatConverter.cs" /> <Compile Include="BaseFormatConverter.cs" />
<Compile Include="BaseGraphicsDevice.cs" />
<Compile Include="BaseStateObject.cs" /> <Compile Include="BaseStateObject.cs" />
<Compile Include="BaseTexture2D.cs" /> <Compile Include="BaseTexture2D.cs" />
<Compile Include="BaseVertexBuffer.cs" /> <Compile Include="BaseVertexBuffer.cs" />
<Compile Include="BaseIndexBuffer.cs" /> <Compile Include="BaseIndexBuffer.cs" />
<Compile Include="BaseEffectTechnique.cs" /> <Compile Include="BaseEffectTechnique.cs" />
<Compile Include="IncludeHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowHelper.cs" /> <Compile Include="WindowHelper.cs" />
</ItemGroup> </ItemGroup>

View File

@ -18,7 +18,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;LINUX;</DefineConstants> <DefineConstants>XNAEXT;DEBUG;TRACE;LINUX;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;LINUX;</DefineConstants> <DefineConstants>XNAEXT;TRACE;LINUX;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -39,6 +39,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX.D3DCompiler">
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL"> <Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath>
@ -46,12 +49,15 @@
<Reference Include="System" /> <Reference Include="System" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseEffect.cs" />
<Compile Include="BaseFormatConverter.cs" /> <Compile Include="BaseFormatConverter.cs" />
<Compile Include="BaseGraphicsDevice.cs" />
<Compile Include="BaseStateObject.cs" /> <Compile Include="BaseStateObject.cs" />
<Compile Include="BaseTexture2D.cs" /> <Compile Include="BaseTexture2D.cs" />
<Compile Include="BaseVertexBuffer.cs" /> <Compile Include="BaseVertexBuffer.cs" />
<Compile Include="BaseIndexBuffer.cs" /> <Compile Include="BaseIndexBuffer.cs" />
<Compile Include="BaseEffectTechnique.cs" /> <Compile Include="BaseEffectTechnique.cs" />
<Compile Include="IncludeHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowHelper.cs" /> <Compile Include="WindowHelper.cs" />
</ItemGroup> </ItemGroup>

View File

@ -18,7 +18,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;PSVITA;</DefineConstants> <DefineConstants>XNAEXT;DEBUG;TRACE;PSVITA;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;PSVITA;</DefineConstants> <DefineConstants>XNAEXT;TRACE;PSVITA;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -39,6 +39,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX.D3DCompiler">
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL"> <Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath>
@ -47,12 +50,15 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseEffect.cs" />
<Compile Include="BaseFormatConverter.cs" /> <Compile Include="BaseFormatConverter.cs" />
<Compile Include="BaseGraphicsDevice.cs" />
<Compile Include="BaseStateObject.cs" /> <Compile Include="BaseStateObject.cs" />
<Compile Include="BaseTexture2D.cs" /> <Compile Include="BaseTexture2D.cs" />
<Compile Include="BaseVertexBuffer.cs" /> <Compile Include="BaseVertexBuffer.cs" />
<Compile Include="BaseIndexBuffer.cs" /> <Compile Include="BaseIndexBuffer.cs" />
<Compile Include="BaseEffectTechnique.cs" /> <Compile Include="BaseEffectTechnique.cs" />
<Compile Include="IncludeHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowHelper.cs" /> <Compile Include="WindowHelper.cs" />
</ItemGroup> </ItemGroup>

View File

@ -20,7 +20,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWSMETRO;</DefineConstants> <DefineConstants>XNAEXT;DEBUG;TRACE;WINDOWSMETRO;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -30,7 +30,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWSMETRO;</DefineConstants> <DefineConstants>XNAEXT;TRACE;WINDOWSMETRO;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -41,6 +41,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX.D3DCompiler">
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL"> <Reference Include="SharpDX.DXGI, Version=2.2.0.0, Culture=neutral, PublicKeyToken=6f19e8495e7498cf, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath> <HintPath>..\..\lib\SharpDX\Bin\Standard-net20\SharpDX.DXGI.dll</HintPath>
@ -48,12 +51,15 @@
<Reference Include="System" /> <Reference Include="System" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseEffect.cs" />
<Compile Include="BaseFormatConverter.cs" /> <Compile Include="BaseFormatConverter.cs" />
<Compile Include="BaseGraphicsDevice.cs" />
<Compile Include="BaseStateObject.cs" /> <Compile Include="BaseStateObject.cs" />
<Compile Include="BaseTexture2D.cs" /> <Compile Include="BaseTexture2D.cs" />
<Compile Include="BaseVertexBuffer.cs" /> <Compile Include="BaseVertexBuffer.cs" />
<Compile Include="BaseIndexBuffer.cs" /> <Compile Include="BaseIndexBuffer.cs" />
<Compile Include="BaseEffectTechnique.cs" /> <Compile Include="BaseEffectTechnique.cs" />
<Compile Include="IncludeHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowHelper.cs" /> <Compile Include="WindowHelper.cs" />
</ItemGroup> </ItemGroup>

View File

@ -0,0 +1,68 @@
using System;
using SharpDX.D3DCompiler;
using System.IO;
using ANX.Framework.Graphics;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.BaseDirectX
{
public abstract class BaseEffect
{
protected Effect managedEffect;
#region Constructor
protected BaseEffect(Effect managedEffect)
{
if (managedEffect == null)
throw new ArgumentNullException("managedEffect");
this.managedEffect = managedEffect;
}
#endregion
#region GetByteCode
protected ShaderBytecode GetByteCode(Stream stream)
{
if (stream.CanSeek)
stream.Seek(0, SeekOrigin.Begin);
return ShaderBytecode.FromStream(stream);
}
#endregion
#region CompileVertexShader (TODO)
public static byte[] CompileVertexShader(string effectCode, string directory = "")
{
// TODO: not all entry points are named VS!
ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None,
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[vertexShaderByteCode.BufferSize];
vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
#endregion
#region CompilePixelShader (TODO)
public static byte[] CompilePixelShader(string effectCode, string directory = "")
{
// TODO: not all entry points are named PS!
ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None,
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[pixelShaderByteCode.BufferSize];
pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
#endregion
protected static byte[] CompileShader(string profile, string effectCode, string directory = "")
{
ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, profile, ShaderFlags.None, EffectFlags.None,
null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[effectByteCode.BufferSize];
effectByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
}
}

View File

@ -154,5 +154,31 @@ namespace ANX.BaseDirectX
throw new NotImplementedException("Couldn't calculate vertex count for PrimitiveType '" + type + "'."); throw new NotImplementedException("Couldn't calculate vertex count for PrimitiveType '" + type + "'.");
} }
#endregion #endregion
#region ConvertVertexElementFormat
public static Format ConvertVertexElementFormat(VertexElementFormat format)
{
switch (format)
{
case VertexElementFormat.Vector2:
return Format.R32G32_Float;
case VertexElementFormat.Vector3:
return Format.R32G32B32_Float;
case VertexElementFormat.Vector4:
return Format.R32G32B32A32_Float;
case VertexElementFormat.Color:
return Format.R8G8B8A8_UNorm;
case VertexElementFormat.Single:
return Format.R32_Float;
// TODO: validate
case VertexElementFormat.Short2:
return Format.R16G16_SInt;
case VertexElementFormat.Short4:
return Format.R16G16B16A16_SInt;
}
throw new Exception("Can't map '" + format + "' to DXGI.Format in Dx10 CreateInputElementFromVertexElement.");
}
#endregion
} }
} }

View File

@ -0,0 +1,160 @@
//#define DIRECTX_DEBUG_LAYER
using System;
using ANX.Framework;
using ANX.Framework.Graphics;
using SharpDX.DXGI;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.BaseDirectX
{
public abstract class BaseGraphicsDevice<S>
{
#region Constants
protected const float ColorMultiplier = 1f / 255f;
protected const bool IsDebugMode =
#if DIRECTX_DEBUG_LAYER
true;
#else
false;
#endif
#endregion
#region Private
protected S nativeDevice;
protected uint lastClearColor;
protected SharpDX.Color4 clearColor;
protected SharpDX.DXGI.SwapChain swapChain;
protected VertexBuffer currentVertexBuffer;
protected IndexBuffer currentIndexBuffer;
#endregion
#region Public
public bool VSync { get; set; }
public S NativeDevice
{
get
{
return nativeDevice;
}
}
#endregion
#region Constructor
protected BaseGraphicsDevice(PresentationParameters presentationParameters)
{
VSync = true;
CreateDevice(presentationParameters);
MakeWindowAssociationAndResize(presentationParameters);
CreateRenderView();
// create the depth stencil buffer
SharpDX.DXGI.Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != SharpDX.DXGI.Format.Unknown)
CreateDepthStencilBuffer(depthFormat);
}
#endregion
#region MakeWindowAssociationAndResize
protected void MakeWindowAssociationAndResize(PresentationParameters presentationParameters)
{
// Ignore all windows events
var factory = swapChain.GetParent<SharpDX.DXGI.Factory>();
factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle,
SharpDX.DXGI.WindowAssociationFlags.IgnoreAll);
WindowHelper.ResizeRenderWindow(presentationParameters);
SetViewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, 0f, 1f);
}
#endregion
#region UpdateClearColorIfNeeded
protected void UpdateClearColorIfNeeded(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;
}
}
#endregion
#region SetViewport
public void SetViewport(Viewport viewport)
{
SetViewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth);
}
protected abstract void SetViewport(int x, int y, int width, int height, float minDepth, float maxDepth);
#endregion
#region ResizeBuffers
public void ResizeBuffers(PresentationParameters presentationParameters)
{
if (swapChain != null)
{
DisposeRenderView();
Format colorFormat = BaseFormatConverter.Translate(presentationParameters.BackBufferFormat);
swapChain.ResizeBuffers(swapChain.Description.BufferCount, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight, colorFormat, swapChain.Description.Flags);
CreateRenderView();
SetViewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, 0f, 1f);
// create the depth stencil buffer
Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != Format.Unknown)
CreateDepthStencilBuffer(depthFormat);
}
WindowHelper.ResizeRenderWindow(presentationParameters);
}
#endregion
#region GetBackBufferData (TODO)
public void GetBackBufferData<T>(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
}
public void GetBackBufferData<T>(T[] data) where T : struct
{
throw new NotImplementedException();
}
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
}
#endregion
#if XNAEXT
#region SetConstantBuffer (TODO)
public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer)
{
if (constantBuffer == null)
throw new ArgumentNullException("constantBuffer");
throw new NotImplementedException();
}
#endregion
#endif
protected abstract void CreateDevice(PresentationParameters presentationParameters);
protected abstract void CreateRenderView();
protected abstract void CreateDepthStencilBuffer(SharpDX.DXGI.Format depthFormat);
protected abstract void DisposeRenderView();
}
}

View File

@ -6,9 +6,9 @@ using SharpDX.D3DCompiler;
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
namespace ANX.RenderSystem.Windows.DX11.Helpers namespace ANX.BaseDirectX
{ {
internal class IncludeHandler : Include public class IncludeHandler : Include
{ {
private string directory; private string directory;

View File

@ -84,7 +84,6 @@
<Compile Include="Effect_DX10.cs" /> <Compile Include="Effect_DX10.cs" />
<Compile Include="Helpers\FormatConverter.cs" /> <Compile Include="Helpers\FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX10.cs" /> <Compile Include="GraphicsDeviceWindowsDX10.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -84,7 +84,6 @@
<Compile Include="Effect_DX10.cs" /> <Compile Include="Effect_DX10.cs" />
<Compile Include="Helpers\FormatConverter.cs" /> <Compile Include="Helpers\FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX10.cs" /> <Compile Include="GraphicsDeviceWindowsDX10.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -85,7 +85,6 @@
<Compile Include="Effect_DX10.cs" /> <Compile Include="Effect_DX10.cs" />
<Compile Include="Helpers\FormatConverter.cs" /> <Compile Include="Helpers\FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX10.cs" /> <Compile Include="GraphicsDeviceWindowsDX10.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -86,7 +86,6 @@
<Compile Include="Effect_DX10.cs" /> <Compile Include="Effect_DX10.cs" />
<Compile Include="Helpers\FormatConverter.cs" /> <Compile Include="Helpers\FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX10.cs" /> <Compile Include="GraphicsDeviceWindowsDX10.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -1,10 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ANX.BaseDirectX;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.RenderSystem.Windows.DX10.Helpers;
using SharpDX.D3DCompiler;
using Dx10 = SharpDX.Direct3D10; using Dx10 = SharpDX.Direct3D10;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
@ -13,20 +12,15 @@ using Dx10 = SharpDX.Direct3D10;
namespace ANX.RenderSystem.Windows.DX10 namespace ANX.RenderSystem.Windows.DX10
{ {
public class Effect_DX10 : INativeEffect public class Effect_DX10 : BaseEffect, INativeEffect
{ {
#region Private #region Private
private Dx10.VertexShader vertexShader; private Dx10.VertexShader vertexShader;
private Dx10.PixelShader pixelShader; private Dx10.PixelShader pixelShader;
private Effect managedEffect;
#endregion #endregion
#region Public #region Public
internal Dx10.Effect NativeEffect internal Dx10.Effect NativeEffect { get; private set; }
{
get;
private set;
}
public IEnumerable<EffectTechnique> Techniques public IEnumerable<EffectTechnique> Techniques
{ {
@ -58,37 +52,20 @@ namespace ANX.RenderSystem.Windows.DX10
#endregion #endregion
#region Constructor #region Constructor
public Effect_DX10(GraphicsDevice device, Effect setManagedEffect, Stream vertexShaderStream, Stream pixelShaderStream) public Effect_DX10(GraphicsDevice graphicsDevice, Effect managedEffect, Stream vertexShaderStream,
{ Stream pixelShaderStream)
if (setManagedEffect == null) : base(managedEffect)
throw new ArgumentNullException("managedEffect"); {
managedEffect = setManagedEffect; var device = ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).NativeDevice;
vertexShader = new Dx10.VertexShader(device, GetByteCode(vertexShaderStream));
if (vertexShaderStream.CanSeek) pixelShader = new Dx10.PixelShader(device, GetByteCode(pixelShaderStream));
vertexShaderStream.Seek(0, SeekOrigin.Begin);
var vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderStream);
vertexShader = new Dx10.VertexShader((SharpDX.Direct3D10.Device)device.NativeDevice, vertexShaderByteCode);
if (pixelShaderStream.CanSeek)
pixelShaderStream.Seek(0, SeekOrigin.Begin);
var pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderStream);
pixelShader = new Dx10.PixelShader((SharpDX.Direct3D10.Device)device.NativeDevice, pixelShaderByteCode);
} }
public Effect_DX10(GraphicsDevice device, Effect setManagedEffect, Stream effectStream) public Effect_DX10(GraphicsDevice graphicsDevice, Effect managedEffect, Stream effectStream)
{ : base(managedEffect)
if (setManagedEffect == null) {
throw new ArgumentNullException("managedEffect"); var device = ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).NativeDevice;
managedEffect = setManagedEffect; NativeEffect = new Dx10.Effect(device, GetByteCode(effectStream));
if (effectStream.CanSeek)
effectStream.Seek(0, SeekOrigin.Begin);
var effectByteCode = ShaderBytecode.FromStream(effectStream);
NativeEffect = new Dx10.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice,
effectByteCode, EffectFlags.None);
} }
#endregion #endregion
@ -106,39 +83,11 @@ namespace ANX.RenderSystem.Windows.DX10
} }
#endregion #endregion
#region CompileVertexShader (TODO)
public static byte[] CompileVertexShader(string effectCode, string directory = "")
{
// TODO: not all entry points are named VS!
ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None,
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[vertexShaderByteCode.BufferSize];
vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
#endregion
#region CompilePixelShader (TODO)
public static byte[] CompilePixelShader(string effectCode, string directory = "")
{
// TODO: not all entry points are named PS!
ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None,
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[pixelShaderByteCode.BufferSize];
pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
#endregion
#region CompileFXShader #region CompileFXShader
public static byte[] CompileFXShader(string effectCode, string directory = "") public static byte[] CompileFXShader(string effectCode, string directory = "")
{ {
ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, "fx_4_0", ShaderFlags.None, EffectFlags.None, return CompileShader("fx_4_0", effectCode, directory);
null, new IncludeHandler(directory), "unknown"); }
byte[] bytecode = new byte[effectByteCode.BufferSize];
effectByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
#endregion #endregion
#region Dispose #region Dispose

View File

@ -1,13 +1,11 @@
//#define DIRECTX_DEBUG_LAYER
using System; using System;
using ANX.BaseDirectX;
using ANX.Framework; using ANX.Framework;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.RenderSystem.Windows.DX10.Helpers;
using SharpDX.D3DCompiler; using SharpDX.D3DCompiler;
using SharpDX.DXGI; using SharpDX.DXGI;
using Dx10 = SharpDX.Direct3D10; using Dx10 = SharpDX.Direct3D10;
using ANX.BaseDirectX;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -15,92 +13,57 @@ using ANX.BaseDirectX;
namespace ANX.RenderSystem.Windows.DX10 namespace ANX.RenderSystem.Windows.DX10
{ {
public class GraphicsDeviceWindowsDX10 : INativeGraphicsDevice public class GraphicsDeviceWindowsDX10 : BaseGraphicsDevice<Dx10.Device>, INativeGraphicsDevice
{ {
#region Constants
private const float ColorMultiplier = 1f / 255f;
#endregion
#region Private #region Private
private Dx10.Device device;
private SwapChain swapChain;
private Dx10.RenderTargetView renderView; private Dx10.RenderTargetView renderView;
private Dx10.RenderTargetView[] renderTargetView = new Dx10.RenderTargetView[1]; private Dx10.RenderTargetView[] renderTargetView = new Dx10.RenderTargetView[1];
private Dx10.DepthStencilView depthStencilView; private Dx10.DepthStencilView depthStencilView;
private Dx10.Texture2D depthStencilBuffer; private Dx10.Texture2D depthStencilBuffer;
private Dx10.Texture2D backBuffer; private Dx10.Texture2D backBuffer;
internal Effect_DX10 currentEffect; internal Effect_DX10 currentEffect;
private VertexBuffer currentVertexBuffer;
private IndexBuffer currentIndexBuffer;
private Dx10.Viewport currentViewport; private Dx10.Viewport currentViewport;
private uint lastClearColor;
private SharpDX.Color4 clearColor;
#endregion
#region Public
internal Dx10.Device NativeDevice
{
get
{
return this.device;
}
}
public bool VSync { get; set; }
#endregion #endregion
#region Constructor #region Constructor
public GraphicsDeviceWindowsDX10(PresentationParameters presentationParameters) public GraphicsDeviceWindowsDX10(PresentationParameters presentationParameters)
: base(presentationParameters)
{ {
VSync = true;
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight, new Rational(60, 1),
BaseFormatConverter.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
Dx10.Device.CreateWithSwapChain(Dx10.DriverType.Hardware, Dx10.DeviceCreationFlags.Debug, desc, out device,
out swapChain);
#else
Dx10.Device.CreateWithSwapChain(Dx10.DriverType.Hardware, Dx10.DeviceCreationFlags.None, desc, out device,
out swapChain);
#endif
// Ignore all windows events
Factory factory = swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll);
WindowHelper.ResizeRenderWindow(presentationParameters);
// New RenderTargetView from the backbuffer
backBuffer = Dx10.Texture2D.FromSwapChain<Dx10.Texture2D>(swapChain, 0);
renderView = new Dx10.RenderTargetView(device, backBuffer);
currentViewport = new Dx10.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
//
// create the depth stencil buffer
//
Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != Format.Unknown)
CreateDepthStencilBuffer(depthFormat);
} }
#endregion #endregion
#region CreateDevice
protected override void CreateDevice(PresentationParameters presentationParameters)
{
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight, new Rational(60, 1),
BaseFormatConverter.Translate(presentationParameters.BackBufferFormat)),
IsWindowed = true,
OutputHandle = presentationParameters.DeviceWindowHandle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
var flags = IsDebugMode ? Dx10.DeviceCreationFlags.Debug : Dx10.DeviceCreationFlags.None;
Dx10.Device.CreateWithSwapChain(Dx10.DriverType.Hardware, flags, desc, out nativeDevice, out swapChain);
}
#endregion
#region CreateRenderView
protected override void CreateRenderView()
{
backBuffer = Dx10.Texture2D.FromSwapChain<Dx10.Texture2D>(swapChain, 0);
renderView = new Dx10.RenderTargetView(nativeDevice, backBuffer);
}
#endregion
#region CreateDepthStencilBuffer #region CreateDepthStencilBuffer
private void CreateDepthStencilBuffer(Format depthFormat) protected override void CreateDepthStencilBuffer(Format depthFormat)
{ {
if (this.depthStencilBuffer != null && if (this.depthStencilBuffer != null &&
this.depthStencilBuffer.Description.Format == depthFormat && this.depthStencilBuffer.Description.Format == depthFormat &&
@ -147,9 +110,9 @@ namespace ANX.RenderSystem.Windows.DX10
CpuAccessFlags = Dx10.CpuAccessFlags.None, CpuAccessFlags = Dx10.CpuAccessFlags.None,
OptionFlags = Dx10.ResourceOptionFlags.None OptionFlags = Dx10.ResourceOptionFlags.None
}; };
this.depthStencilBuffer = new Dx10.Texture2D(device, depthStencilTextureDesc); this.depthStencilBuffer = new Dx10.Texture2D(nativeDevice, depthStencilTextureDesc);
this.depthStencilView = new Dx10.DepthStencilView(device, this.depthStencilBuffer); this.depthStencilView = new Dx10.DepthStencilView(nativeDevice, this.depthStencilBuffer);
// this workaround is working but maybe not the best solution to issue #472 // this workaround is working but maybe not the best solution to issue #472
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0); Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0);
@ -159,20 +122,10 @@ namespace ANX.RenderSystem.Windows.DX10
#region Clear #region Clear
public void Clear(ref Color color) public void Clear(ref Color color)
{ {
uint newClearColor = color.PackedValue; UpdateClearColorIfNeeded(ref color);
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;
}
if (this.renderTargetView[0] == null) if (this.renderTargetView[0] == null)
{ nativeDevice.ClearRenderTargetView(this.renderView, this.clearColor);
this.device.ClearRenderTargetView(this.renderView, this.clearColor);
}
else else
{ {
for (int i = 0; i < this.renderTargetView.Length; i++) for (int i = 0; i < this.renderTargetView.Length; i++)
@ -182,7 +135,7 @@ namespace ANX.RenderSystem.Windows.DX10
break; break;
} }
this.device.ClearRenderTargetView(this.renderTargetView[i], this.clearColor); nativeDevice.ClearRenderTargetView(this.renderTargetView[i], this.clearColor);
} }
} }
} }
@ -201,18 +154,16 @@ namespace ANX.RenderSystem.Windows.DX10
if (this.renderTargetView[0] == null) if (this.renderTargetView[0] == null)
{ {
this.device.ClearRenderTargetView(this.renderView, this.clearColor); nativeDevice.ClearRenderTargetView(this.renderView, this.clearColor);
} }
else else
{ {
for (int i = 0; i < this.renderTargetView.Length; i++) for (int i = 0; i < this.renderTargetView.Length; i++)
{ {
if (this.renderTargetView[i] == null) if (this.renderTargetView[i] == null)
{
break; break;
}
this.device.ClearRenderTargetView(this.renderTargetView[i], this.clearColor); nativeDevice.ClearRenderTargetView(this.renderTargetView[i], this.clearColor);
} }
} }
} }
@ -222,17 +173,18 @@ namespace ANX.RenderSystem.Windows.DX10
if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options) if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options)
{ {
// Clear the stencil buffer // Clear the stencil buffer
device.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Depth | nativeDevice.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Depth |
Dx10.DepthStencilClearFlags.Stencil, depth, (byte)stencil); Dx10.DepthStencilClearFlags.Stencil, depth, (byte)stencil);
} }
else if ((options | ClearOptions.Stencil) == options) else if ((options | ClearOptions.Stencil) == options)
{ {
device.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Stencil, depth, nativeDevice.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Stencil, depth,
(byte)stencil); (byte)stencil);
} }
else else
{ {
device.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Depth, depth, (byte)stencil); nativeDevice.ClearDepthStencilView(this.depthStencilView, Dx10.DepthStencilClearFlags.Depth, depth,
(byte)stencil);
} }
} }
} }
@ -252,18 +204,18 @@ namespace ANX.RenderSystem.Windows.DX10
Dx10.EffectTechnique technique = SetupEffectForDraw(); Dx10.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = BaseFormatConverter.CalculateVertexCount(primitiveType, primitiveCount); int vertexCount = BaseFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
device.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
device.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
technique.GetPassByIndex(i).Apply(); technique.GetPassByIndex(i).Apply();
device.DrawIndexed(vertexCount, startIndex, baseVertex); nativeDevice.DrawIndexed(vertexCount, startIndex, baseVertex);
} }
device.InputAssembler.InputLayout.Dispose(); nativeDevice.InputAssembler.InputLayout.Dispose();
device.InputAssembler.InputLayout = null; nativeDevice.InputAssembler.InputLayout = null;
} }
#endregion #endregion
@ -272,18 +224,18 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
Dx10.EffectTechnique technique = SetupEffectForDraw(); Dx10.EffectTechnique technique = SetupEffectForDraw();
device.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
device.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
technique.GetPassByIndex(i).Apply(); technique.GetPassByIndex(i).Apply();
device.Draw(primitiveCount, vertexOffset); nativeDevice.Draw(primitiveCount, vertexOffset);
} }
device.InputAssembler.InputLayout.Dispose(); nativeDevice.InputAssembler.InputLayout.Dispose();
device.InputAssembler.InputLayout = null; nativeDevice.InputAssembler.InputLayout = null;
} }
#endregion #endregion
@ -291,7 +243,7 @@ namespace ANX.RenderSystem.Windows.DX10
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount) int startIndex, int primitiveCount, int instanceCount)
{ {
device.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0); nativeDevice.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0);
} }
#endregion #endregion
@ -302,15 +254,15 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
int vertexCount = vertexData.Length; int vertexCount = vertexData.Length;
int indexCount = indexData.Length; int indexCount = indexData.Length;
VertexBuffer_DX10 vb10 = new VertexBuffer_DX10(this.device, vertexDeclaration, vertexCount, BufferUsage.None); VertexBuffer_DX10 vb10 = new VertexBuffer_DX10(nativeDevice, vertexDeclaration, vertexCount, BufferUsage.None);
vb10.SetData<T>(null, vertexData); vb10.SetData<T>(null, vertexData);
Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer, Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer,
vertexDeclaration.VertexStride, 0); vertexDeclaration.VertexStride, 0);
device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
IndexBuffer_DX10 idx10 = new IndexBuffer_DX10(this.device, indexFormat, indexCount, BufferUsage.None); IndexBuffer_DX10 idx10 = new IndexBuffer_DX10(nativeDevice, indexFormat, indexCount, BufferUsage.None);
if (indexData.GetType() == typeof(Int16[])) if (indexData.GetType() == typeof(Int16[]))
idx10.SetData<short>(null, (short[])indexData); idx10.SetData<short>(null, (short[])indexData);
else else
@ -325,36 +277,36 @@ namespace ANX.RenderSystem.Windows.DX10
VertexDeclaration vertexDeclaration) where T : struct, IVertexType VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{ {
int vertexCount = vertexData.Length; int vertexCount = vertexData.Length;
VertexBuffer_DX10 vb10 = new VertexBuffer_DX10(this.device, vertexDeclaration, vertexCount, BufferUsage.None); VertexBuffer_DX10 vb10 = new VertexBuffer_DX10(nativeDevice, vertexDeclaration, vertexCount, BufferUsage.None);
vb10.SetData<T>(null, vertexData); vb10.SetData<T>(null, vertexData);
Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer, Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer,
vertexDeclaration.VertexStride, 0); vertexDeclaration.VertexStride, 0);
device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
//TODO: check for currentEffect null and throw exception //TODO: check for currentEffect null and throw exception
// TODO: check for null's and throw exceptions // TODO: check for null's and throw exceptions
// TODO: get the correct pass index! // TODO: get the correct pass index!
var technique = currentEffect.GetCurrentTechnique().NativeTechnique; var technique = currentEffect.GetCurrentTechnique().NativeTechnique;
var pass = technique.GetPassByIndex(0); var pass = technique.GetPassByIndex(0);
var layout = CreateInputLayout(device, pass.Description.Signature, vertexDeclaration); var layout = CreateInputLayout(nativeDevice, pass.Description.Signature, vertexDeclaration);
device.InputAssembler.InputLayout = layout; nativeDevice.InputAssembler.InputLayout = layout;
// Prepare All the stages // Prepare All the stages
device.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
device.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
//device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); //device.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
pass.Apply(); pass.Apply();
device.Draw(primitiveCount, vertexOffset); nativeDevice.Draw(primitiveCount, vertexOffset);
} }
device.InputAssembler.InputLayout.Dispose(); nativeDevice.InputAssembler.InputLayout.Dispose();
device.InputAssembler.InputLayout = null; nativeDevice.InputAssembler.InputLayout = null;
} }
#endregion #endregion
@ -379,9 +331,9 @@ namespace ANX.RenderSystem.Windows.DX10
throw new ArgumentNullException("passSignature"); throw new ArgumentNullException("passSignature");
VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration; VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration;
var layout = CreateInputLayout(device, passSignature, vertexDeclaration); var layout = CreateInputLayout(nativeDevice, passSignature, vertexDeclaration);
device.InputAssembler.InputLayout = layout; nativeDevice.InputAssembler.InputLayout = layout;
} }
#endregion #endregion
@ -389,9 +341,7 @@ namespace ANX.RenderSystem.Windows.DX10
public void SetIndexBuffer(IndexBuffer indexBuffer) public void SetIndexBuffer(IndexBuffer indexBuffer)
{ {
if (indexBuffer == null) if (indexBuffer == null)
{
throw new ArgumentNullException("indexBuffer"); throw new ArgumentNullException("indexBuffer");
}
this.currentIndexBuffer = indexBuffer; this.currentIndexBuffer = indexBuffer;
@ -399,7 +349,7 @@ namespace ANX.RenderSystem.Windows.DX10
if (nativeIndexBuffer != null) if (nativeIndexBuffer != null)
{ {
device.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, nativeDevice.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer,
BaseFormatConverter.Translate(indexBuffer.IndexElementSize), 0); BaseFormatConverter.Translate(indexBuffer.IndexElementSize), 0);
} }
else else
@ -409,18 +359,6 @@ namespace ANX.RenderSystem.Windows.DX10
} }
#endregion #endregion
#if XNAEXT
#region SetConstantBuffer
public void SetConstantBuffer(int slot, ANX.Framework.Graphics.ConstantBuffer constantBuffer)
{
if (constantBuffer == null)
throw new ArgumentNullException("constantBuffer");
throw new NotImplementedException();
}
#endregion
#endif
#region SetVertexBuffers #region SetVertexBuffers
public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers) public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers)
{ {
@ -447,16 +385,15 @@ namespace ANX.RenderSystem.Windows.DX10
} }
} }
device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
} }
#endregion #endregion
#region SetViewport #region SetViewport
public void SetViewport(Viewport viewport) protected override void SetViewport(int x, int y, int width, int height, float minDepth, float maxDepth)
{ {
this.currentViewport = new Dx10.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, currentViewport = new Dx10.Viewport(x, y, width, height, minDepth, maxDepth);
viewport.MinDepth, viewport.MaxDepth); }
}
#endregion #endregion
#region CreateInputLayout #region CreateInputLayout
@ -482,37 +419,11 @@ namespace ANX.RenderSystem.Windows.DX10
private Dx10.InputElement CreateInputElementFromVertexElement(VertexElement vertexElement) private Dx10.InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
{ {
string elementName = BaseFormatConverter.Translate(ref vertexElement); string elementName = BaseFormatConverter.Translate(ref vertexElement);
Format elementFormat = ConvertVertexElementFormat(vertexElement.VertexElementFormat); Format elementFormat = BaseFormatConverter.ConvertVertexElementFormat(vertexElement.VertexElementFormat);
return new Dx10.InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0); return new Dx10.InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
} }
#endregion #endregion
#region ConvertVertexElementFormat
private Format ConvertVertexElementFormat(VertexElementFormat format)
{
switch (format)
{
case VertexElementFormat.Vector2:
return Format.R32G32_Float;
case VertexElementFormat.Vector3:
return Format.R32G32B32_Float;
case VertexElementFormat.Vector4:
return Format.R32G32B32A32_Float;
case VertexElementFormat.Color:
return Format.R8G8B8A8_UNorm;
case VertexElementFormat.Single:
return Format.R32_Float;
// TODO: validate
case VertexElementFormat.Short2:
return Format.R16G16_SInt;
case VertexElementFormat.Short4:
return Format.R16G16B16A16_SInt;
}
throw new Exception("Can't map '" + format + "' to DXGI.Format in Dx10 CreateInputElementFromVertexElement.");
}
#endregion
#region SetRenderTargets #region SetRenderTargets
public void SetRenderTargets(params RenderTargetBinding[] renderTargets) public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{ {
@ -528,8 +439,9 @@ namespace ANX.RenderSystem.Windows.DX10
} }
} }
device.OutputMerger.SetRenderTargets(1, new Dx10.RenderTargetView[] { this.renderView }, this.depthStencilView); nativeDevice.OutputMerger.SetRenderTargets(1, new Dx10.RenderTargetView[] { this.renderView },
device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); this.depthStencilView);
nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
} }
else else
{ {
@ -556,16 +468,15 @@ namespace ANX.RenderSystem.Windows.DX10
RenderTarget2D_DX10 nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_DX10; RenderTarget2D_DX10 nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_DX10;
if (renderTargetView[i] != null) if (renderTargetView[i] != null)
{
renderTargetView[i].Dispose(); renderTargetView[i].Dispose();
}
renderTargetView[i] = new Dx10.RenderTargetView(device, ((Texture2D_DX10)nativeRenderTarget).NativeShaderResourceView.Resource); renderTargetView[i] = new Dx10.RenderTargetView(nativeDevice,
((Texture2D_DX10)nativeRenderTarget).NativeShaderResourceView.Resource);
} }
} }
device.OutputMerger.SetRenderTargets(renderTargetCount, renderTargetView, this.depthStencilView); nativeDevice.OutputMerger.SetRenderTargets(renderTargetCount, renderTargetView, this.depthStencilView);
device.OutputMerger.SetTargets(this.depthStencilView, this.renderTargetView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderTargetView);
//if (renderTargets.Length == 1) //if (renderTargets.Length == 1)
//{ //{
@ -591,50 +502,15 @@ namespace ANX.RenderSystem.Windows.DX10
} }
#endregion #endregion
#region GetBackBufferData (TODO) #region DisposeRenderView
public void GetBackBufferData<T>(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct protected override void DisposeRenderView()
{ {
throw new NotImplementedException(); renderView.Dispose();
} renderView = null;
public void GetBackBufferData<T>(T[] data) where T : struct backBuffer.Dispose();
{ backBuffer = null;
throw new NotImplementedException(); }
}
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
}
#endregion
#region ResizeBuffers
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, swapChain.Description.Flags);
backBuffer = Dx10.Texture2D.FromSwapChain<Dx10.Texture2D>(swapChain, 0);
renderView = new Dx10.RenderTargetView(device, backBuffer);
currentViewport = new Dx10.Viewport(0, 0, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight);
// create the depth stencil buffer
Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != Format.Unknown)
CreateDepthStencilBuffer(depthFormat);
}
WindowHelper.ResizeRenderWindow(presentationParameters);
}
#endregion #endregion
#region Dispose #region Dispose
@ -651,11 +527,7 @@ namespace ANX.RenderSystem.Windows.DX10
if (swapChain != null) if (swapChain != null)
{ {
renderView.Dispose(); DisposeRenderView();
renderView = null;
backBuffer.Dispose();
backBuffer = null;
swapChain.Dispose(); swapChain.Dispose();
swapChain = null; swapChain = null;

View File

@ -1,39 +0,0 @@
using System;
using System.IO;
using SharpDX.D3DCompiler;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.RenderSystem.Windows.DX10.Helpers
{
internal class IncludeHandler : Include
{
private string directory;
public IDisposable Shadow { get; set; }
public IncludeHandler(string directory)
{
this.directory = directory;
}
public void Close(Stream stream)
{
stream.Close();
}
public Stream Open(IncludeType type, string fileName, Stream parentStream)
{
//Console.WriteLine("Including {0} file {1} from directory {2}", type.ToString(), fileName, directory);
return File.OpenRead(Path.Combine(directory, fileName));
}
public void Dispose()
{
throw new NotImplementedException();
}
}
}

View File

@ -97,7 +97,7 @@ namespace ANX.RenderSystem.Windows.DX10
#region UpdateNativeSamplerState #region UpdateNativeSamplerState
private void UpdateNativeSamplerState(Dx10.Device device) private void UpdateNativeSamplerState(Dx10.Device device)
{ {
if (isDirty == true || nativeState == null) if (isDirty || nativeState == null)
{ {
Dispose(); Dispose();
nativeState = new Dx10.SamplerState(device, ref description); nativeState = new Dx10.SamplerState(device, ref description);

View File

@ -102,7 +102,6 @@
<Compile Include="Effect_DX11.cs" /> <Compile Include="Effect_DX11.cs" />
<Compile Include="FormatConverter.cs" /> <Compile Include="FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />

View File

@ -101,7 +101,6 @@
<Compile Include="Effect_DX11.cs" /> <Compile Include="Effect_DX11.cs" />
<Compile Include="FormatConverter.cs" /> <Compile Include="FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />

View File

@ -102,7 +102,6 @@
<Compile Include="Effect_DX11.cs" /> <Compile Include="Effect_DX11.cs" />
<Compile Include="FormatConverter.cs" /> <Compile Include="FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />

View File

@ -99,7 +99,6 @@
<Compile Include="Effect_DX11.cs" /> <Compile Include="Effect_DX11.cs" />
<Compile Include="FormatConverter.cs" /> <Compile Include="FormatConverter.cs" />
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="Helpers\IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />

View File

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ANX.BaseDirectX;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.RenderSystem.Windows.DX11.Helpers;
using SharpDX.D3DCompiler;
using Dx11 = SharpDX.Direct3D11; using Dx11 = SharpDX.Direct3D11;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
@ -13,20 +11,15 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.DX11 namespace ANX.RenderSystem.Windows.DX11
{ {
public class Effect_DX11 : INativeEffect public class Effect_DX11 : BaseEffect, INativeEffect
{ {
#region Private #region Private
private Dx11.VertexShader vertexShader; private Dx11.VertexShader vertexShader;
private Dx11.PixelShader pixelShader; private Dx11.PixelShader pixelShader;
private Effect managedEffect;
#endregion #endregion
#region Public #region Public
internal Dx11.Effect NativeEffect internal Dx11.Effect NativeEffect { get; private set; }
{
get;
private set;
}
public IEnumerable<EffectTechnique> Techniques public IEnumerable<EffectTechnique> Techniques
{ {
@ -58,43 +51,20 @@ namespace ANX.RenderSystem.Windows.DX11
#endregion #endregion
#region Constructor #region Constructor
public Effect_DX11(GraphicsDevice device, Effect setManagedEffect, Stream vertexShaderStream, Stream pixelShaderStream) public Effect_DX11(GraphicsDevice graphicsDevice, Effect managedEffect, Stream vertexShaderStream,
Stream pixelShaderStream)
: base(managedEffect)
{ {
if (setManagedEffect == null) var device = ((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).NativeDevice.Device;
throw new ArgumentNullException("managedEffect"); vertexShader = new Dx11.VertexShader(device, GetByteCode(vertexShaderStream));
managedEffect = setManagedEffect; pixelShader = new Dx11.PixelShader(device, GetByteCode(pixelShaderStream));
if (vertexShaderStream.CanSeek)
vertexShaderStream.Seek(0, SeekOrigin.Begin);
var vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderStream);
vertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexShaderByteCode);
if (pixelShaderStream.CanSeek)
pixelShaderStream.Seek(0, SeekOrigin.Begin);
var pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderStream);
pixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelShaderByteCode);
} }
public Effect_DX11(GraphicsDevice device, Effect setManagedEffect, Stream effectStream) public Effect_DX11(GraphicsDevice graphicsDevice, Effect managedEffect, Stream effectStream)
: base(managedEffect)
{ {
if (setManagedEffect == null) var device = ((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).NativeDevice.Device;
throw new ArgumentNullException("managedEffect"); NativeEffect = new Dx11.Effect(device, GetByteCode(effectStream));
managedEffect = setManagedEffect;
if (effectStream.CanSeek)
effectStream.Seek(0, SeekOrigin.Begin);
var effectByteCode = ShaderBytecode.FromStream(effectStream);
NativeEffect = new Dx11.Effect(((GraphicsDeviceWindowsDX11)device.NativeDevice).NativeDevice.Device, effectByteCode);
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).currentEffect = this;
} }
#endregion #endregion
@ -105,32 +75,19 @@ namespace ANX.RenderSystem.Windows.DX11
} }
#endregion #endregion
public static byte[] CompileVertexShader(string effectCode, string directory = "") #region Apply
public void Apply(GraphicsDevice graphicsDevice)
{ {
ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None, ((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).currentEffect = this;
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[vertexShaderByteCode.BufferSize];
vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
}
public static byte[] CompilePixelShader(string effectCode, string directory = "")
{
ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None,
EffectFlags.None, null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[pixelShaderByteCode.BufferSize];
pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
} }
#endregion
#region CompileFXShader
public static byte[] CompileFXShader(string effectCode, string directory = "") public static byte[] CompileFXShader(string effectCode, string directory = "")
{ {
ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, "fx_5_0", ShaderFlags.None, EffectFlags.None, return CompileShader("fx_5_0", effectCode, directory);
null, new IncludeHandler(directory), "unknown");
byte[] bytecode = new byte[effectByteCode.BufferSize];
effectByteCode.Data.Read(bytecode, 0, bytecode.Length);
return bytecode;
} }
#endregion
#region Dispose #region Dispose
public void Dispose() public void Dispose()

View File

@ -1,11 +1,8 @@
#region Using Statements
using System; using System;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using SharpDX.Direct3D11;
using SharpDX.Direct3D; using SharpDX.Direct3D;
using SharpDX.DXGI; using SharpDX.DXGI;
using Dx11 = SharpDX.Direct3D11;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -13,203 +10,207 @@ using SharpDX.DXGI;
namespace ANX.RenderSystem.Windows.DX11 namespace ANX.RenderSystem.Windows.DX11
{ {
internal class FormatConverter internal class FormatConverter
{ {
public static Filter Translate(TextureFilter filter) #region Translate (TextureFilter)
{ public static Dx11.Filter Translate(TextureFilter filter)
switch (filter) {
{ switch (filter)
case TextureFilter.Anisotropic: {
return Filter.Anisotropic; case TextureFilter.Anisotropic:
case TextureFilter.Linear: return Dx11.Filter.Anisotropic;
return Filter.MinMagMipLinear; case TextureFilter.Linear:
case TextureFilter.LinearMipPoint: return Dx11.Filter.MinMagMipLinear;
return Filter.MinMagMipPoint; case TextureFilter.LinearMipPoint:
case TextureFilter.MinLinearMagPointMipLinear: return Dx11.Filter.MinMagMipPoint;
return Filter.MinLinearMagPointMipLinear; case TextureFilter.MinLinearMagPointMipLinear:
case TextureFilter.MinLinearMagPointMipPoint: return Dx11.Filter.MinLinearMagPointMipLinear;
return Filter.MinLinearMagMipPoint; case TextureFilter.MinLinearMagPointMipPoint:
case TextureFilter.MinPointMagLinearMipLinear: return Dx11.Filter.MinLinearMagMipPoint;
return Filter.MinPointMagMipLinear; case TextureFilter.MinPointMagLinearMipLinear:
case TextureFilter.MinPointMagLinearMipPoint: return Dx11.Filter.MinPointMagMipLinear;
return Filter.MinPointMagLinearMipPoint; case TextureFilter.MinPointMagLinearMipPoint:
case TextureFilter.Point: return Dx11.Filter.MinPointMagLinearMipPoint;
return Filter.MinMagMipPoint; case TextureFilter.Point:
case TextureFilter.PointMipLinear: return Dx11.Filter.MinMagMipPoint;
return Filter.MinMagPointMipLinear; case TextureFilter.PointMipLinear:
} return Dx11.Filter.MinMagPointMipLinear;
}
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
public static SharpDX.Direct3D11.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode) #region Translate (TextureAddressMode)
{ public static Dx11.TextureAddressMode Translate(TextureAddressMode addressMode)
switch (addressMode) {
{ switch (addressMode)
case ANX.Framework.Graphics.TextureAddressMode.Clamp: {
return SharpDX.Direct3D11.TextureAddressMode.Clamp; case TextureAddressMode.Clamp:
case ANX.Framework.Graphics.TextureAddressMode.Mirror: return Dx11.TextureAddressMode.Clamp;
return SharpDX.Direct3D11.TextureAddressMode.Mirror; case TextureAddressMode.Mirror:
case ANX.Framework.Graphics.TextureAddressMode.Wrap: return Dx11.TextureAddressMode.Mirror;
return SharpDX.Direct3D11.TextureAddressMode.Wrap; case TextureAddressMode.Wrap:
} return Dx11.TextureAddressMode.Wrap;
}
return SharpDX.Direct3D11.TextureAddressMode.Clamp; return Dx11.TextureAddressMode.Clamp;
} }
#endregion
public static BlendOperation Translate(BlendFunction blendFunction) #region Translate (BlendFunction)
{ public static Dx11.BlendOperation Translate(BlendFunction blendFunction)
switch (blendFunction) {
{ switch (blendFunction)
case BlendFunction.Add: {
return BlendOperation.Add; case BlendFunction.Add:
case BlendFunction.Max: return Dx11.BlendOperation.Add;
return BlendOperation.Maximum; case BlendFunction.Max:
case BlendFunction.Min: return Dx11.BlendOperation.Maximum;
return BlendOperation.Minimum; case BlendFunction.Min:
case BlendFunction.ReverseSubtract: return Dx11.BlendOperation.Minimum;
return BlendOperation.ReverseSubtract; case BlendFunction.ReverseSubtract:
case BlendFunction.Subtract: return Dx11.BlendOperation.ReverseSubtract;
return BlendOperation.Subtract; case BlendFunction.Subtract:
} return Dx11.BlendOperation.Subtract;
}
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
public static BlendOption Translate(Blend blend) #region Translate (Blend)
{ public static Dx11.BlendOption Translate(Blend blend)
switch (blend) {
{ switch (blend)
case Blend.BlendFactor: {
return BlendOption.BlendFactor; case Blend.BlendFactor:
case Blend.DestinationAlpha: return Dx11.BlendOption.BlendFactor;
return BlendOption.DestinationAlpha; case Blend.DestinationAlpha:
case Blend.DestinationColor: return Dx11.BlendOption.DestinationAlpha;
return BlendOption.DestinationColor; case Blend.DestinationColor:
case Blend.InverseBlendFactor: return Dx11.BlendOption.DestinationColor;
return BlendOption.InverseBlendFactor; case Blend.InverseBlendFactor:
case Blend.InverseDestinationAlpha: return Dx11.BlendOption.InverseBlendFactor;
return BlendOption.InverseDestinationAlpha; case Blend.InverseDestinationAlpha:
case Blend.InverseDestinationColor: return Dx11.BlendOption.InverseDestinationAlpha;
return BlendOption.InverseDestinationColor; case Blend.InverseDestinationColor:
case Blend.InverseSourceAlpha: return Dx11.BlendOption.InverseDestinationColor;
return BlendOption.InverseSourceAlpha; case Blend.InverseSourceAlpha:
case Blend.InverseSourceColor: return Dx11.BlendOption.InverseSourceAlpha;
return BlendOption.InverseSourceColor; case Blend.InverseSourceColor:
case Blend.One: return Dx11.BlendOption.InverseSourceColor;
return BlendOption.One; case Blend.One:
case Blend.SourceAlpha: return Dx11.BlendOption.One;
return BlendOption.SourceAlpha; case Blend.SourceAlpha:
case Blend.SourceAlphaSaturation: return Dx11.BlendOption.SourceAlpha;
return BlendOption.SourceAlphaSaturate; case Blend.SourceAlphaSaturation:
case Blend.SourceColor: return Dx11.BlendOption.SourceAlphaSaturate;
return BlendOption.SourceColor; case Blend.SourceColor:
case Blend.Zero: return Dx11.BlendOption.SourceColor;
return BlendOption.Zero; case Blend.Zero:
} return Dx11.BlendOption.Zero;
}
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
public static ColorWriteMaskFlags Translate(ColorWriteChannels colorWriteChannels) #region Translate (ColorWriteChannels)
{ public static Dx11.ColorWriteMaskFlags Translate(ColorWriteChannels colorWriteChannels)
ColorWriteMaskFlags mask = 0; {
Dx11.ColorWriteMaskFlags mask = 0;
if ((colorWriteChannels & ColorWriteChannels.All) == ColorWriteChannels.All) if ((colorWriteChannels & ColorWriteChannels.All) == ColorWriteChannels.All)
mask |= ColorWriteMaskFlags.All; mask |= Dx11.ColorWriteMaskFlags.All;
if ((colorWriteChannels & ColorWriteChannels.Alpha) == ColorWriteChannels.Alpha) if ((colorWriteChannels & ColorWriteChannels.Alpha) == ColorWriteChannels.Alpha)
mask |= ColorWriteMaskFlags.Alpha; mask |= Dx11.ColorWriteMaskFlags.Alpha;
if ((colorWriteChannels & ColorWriteChannels.Blue) == ColorWriteChannels.Blue) if ((colorWriteChannels & ColorWriteChannels.Blue) == ColorWriteChannels.Blue)
mask |= ColorWriteMaskFlags.Blue; mask |= Dx11.ColorWriteMaskFlags.Blue;
if ((colorWriteChannels & ColorWriteChannels.Green) == ColorWriteChannels.Green) if ((colorWriteChannels & ColorWriteChannels.Green) == ColorWriteChannels.Green)
mask |= ColorWriteMaskFlags.Green; mask |= Dx11.ColorWriteMaskFlags.Green;
if ((colorWriteChannels & ColorWriteChannels.Red) == ColorWriteChannels.Red) if ((colorWriteChannels & ColorWriteChannels.Red) == ColorWriteChannels.Red)
mask |= ColorWriteMaskFlags.Red; mask |= Dx11.ColorWriteMaskFlags.Red;
return mask; return mask;
} }
#endregion
public static SharpDX.Direct3D11.StencilOperation Translate(ANX.Framework.Graphics.StencilOperation stencilOperation) #region Translate (StencilOperation)
{ public static Dx11.StencilOperation Translate(StencilOperation stencilOperation)
switch (stencilOperation) {
{ switch (stencilOperation)
case ANX.Framework.Graphics.StencilOperation.Decrement: {
return SharpDX.Direct3D11.StencilOperation.Decrement; case StencilOperation.Decrement:
case ANX.Framework.Graphics.StencilOperation.DecrementSaturation: return Dx11.StencilOperation.Decrement;
return SharpDX.Direct3D11.StencilOperation.DecrementAndClamp; case StencilOperation.DecrementSaturation:
case ANX.Framework.Graphics.StencilOperation.Increment: return Dx11.StencilOperation.DecrementAndClamp;
return SharpDX.Direct3D11.StencilOperation.Increment; case StencilOperation.Increment:
case ANX.Framework.Graphics.StencilOperation.IncrementSaturation: return Dx11.StencilOperation.Increment;
return SharpDX.Direct3D11.StencilOperation.IncrementAndClamp; case StencilOperation.IncrementSaturation:
case ANX.Framework.Graphics.StencilOperation.Invert: return Dx11.StencilOperation.IncrementAndClamp;
return SharpDX.Direct3D11.StencilOperation.Invert; case StencilOperation.Invert:
case ANX.Framework.Graphics.StencilOperation.Keep: return Dx11.StencilOperation.Invert;
return SharpDX.Direct3D11.StencilOperation.Keep; case StencilOperation.Keep:
case ANX.Framework.Graphics.StencilOperation.Replace: return Dx11.StencilOperation.Keep;
return SharpDX.Direct3D11.StencilOperation.Replace; case StencilOperation.Replace:
case ANX.Framework.Graphics.StencilOperation.Zero: return Dx11.StencilOperation.Replace;
return SharpDX.Direct3D11.StencilOperation.Zero; case StencilOperation.Zero:
} return Dx11.StencilOperation.Zero;
}
throw new NotImplementedException("unknown StencilOperation"); throw new NotImplementedException("unknown StencilOperation");
} }
#endregion
public static Comparison Translate(ANX.Framework.Graphics.CompareFunction compareFunction) #region Translate (CompareFunction)
{ public static Dx11.Comparison Translate(CompareFunction compareFunction)
switch (compareFunction) {
{ switch (compareFunction)
case ANX.Framework.Graphics.CompareFunction.Always: {
return Comparison.Always; case CompareFunction.Always:
case ANX.Framework.Graphics.CompareFunction.Equal: return Dx11.Comparison.Always;
return Comparison.Equal; case CompareFunction.Equal:
case ANX.Framework.Graphics.CompareFunction.Greater: return Dx11.Comparison.Equal;
return Comparison.Greater; case CompareFunction.Greater:
case ANX.Framework.Graphics.CompareFunction.GreaterEqual: return Dx11.Comparison.Greater;
return Comparison.GreaterEqual; case CompareFunction.GreaterEqual:
case ANX.Framework.Graphics.CompareFunction.Less: return Dx11.Comparison.GreaterEqual;
return Comparison.Less; case CompareFunction.Less:
case ANX.Framework.Graphics.CompareFunction.LessEqual: return Dx11.Comparison.Less;
return Comparison.LessEqual; case CompareFunction.LessEqual:
case ANX.Framework.Graphics.CompareFunction.Never: return Dx11.Comparison.LessEqual;
return Comparison.Never; case CompareFunction.Never:
case ANX.Framework.Graphics.CompareFunction.NotEqual: return Dx11.Comparison.Never;
return Comparison.NotEqual; case CompareFunction.NotEqual:
} return Dx11.Comparison.NotEqual;
}
throw new NotImplementedException("unknown CompareFunction"); throw new NotImplementedException("unknown CompareFunction");
} }
#endregion
public static SharpDX.Direct3D11.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode) #region Translate (CullMode)
{ public static Dx11.CullMode Translate(CullMode cullMode)
if (cullMode == ANX.Framework.Graphics.CullMode.CullClockwiseFace) {
{ if (cullMode == CullMode.CullClockwiseFace)
return SharpDX.Direct3D11.CullMode.Front; return Dx11.CullMode.Front;
} else if (cullMode == CullMode.CullCounterClockwiseFace)
else if (cullMode == ANX.Framework.Graphics.CullMode.CullCounterClockwiseFace) return Dx11.CullMode.Back;
{ else
return SharpDX.Direct3D11.CullMode.Back; return Dx11.CullMode.None;
} }
else #endregion
{
return SharpDX.Direct3D11.CullMode.None;
}
}
public static SharpDX.Direct3D11.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode) #region Translate (FillMode)
{ public static Dx11.FillMode Translate(FillMode fillMode)
if (fillMode == ANX.Framework.Graphics.FillMode.WireFrame) {
{ return fillMode == FillMode.WireFrame ? Dx11.FillMode.Wireframe : Dx11.FillMode.Solid;
return SharpDX.Direct3D11.FillMode.Wireframe; }
} #endregion
else }
{
return SharpDX.Direct3D11.FillMode.Solid;
}
}
}
} }

View File

@ -1,15 +1,13 @@
//#define DIRECTX_DEBUG_LAYER
using System; using System;
using ANX.BaseDirectX;
using ANX.Framework; using ANX.Framework;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.RenderSystem.Windows.DX11.Helpers;
using SharpDX.D3DCompiler; using SharpDX.D3DCompiler;
using SharpDX.Direct3D; using SharpDX.Direct3D;
using SharpDX.Direct3D11; using SharpDX.Direct3D11;
using SharpDX.DXGI; using SharpDX.DXGI;
using Device = SharpDX.Direct3D11.Device; using Device = SharpDX.Direct3D11.Device;
using ANX.BaseDirectX;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -17,90 +15,61 @@ using ANX.BaseDirectX;
namespace ANX.RenderSystem.Windows.DX11 namespace ANX.RenderSystem.Windows.DX11
{ {
public class GraphicsDeviceWindowsDX11 : INativeGraphicsDevice public class GraphicsDeviceWindowsDX11 : BaseGraphicsDevice<DeviceContext>, INativeGraphicsDevice
{ {
#region Constants
private const float ColorMultiplier = 1f / 255f;
#endregion
#region Private #region Private
private DeviceContext deviceContext;
private SwapChain swapChain;
private RenderTargetView renderView; private RenderTargetView renderView;
private RenderTargetView[] renderTargetView = new RenderTargetView[1]; private RenderTargetView[] renderTargetView = new RenderTargetView[1];
private DepthStencilView depthStencilView; private DepthStencilView depthStencilView;
private SharpDX.Direct3D11.Texture2D depthStencilBuffer; private SharpDX.Direct3D11.Texture2D depthStencilBuffer;
private SharpDX.Direct3D11.Texture2D backBuffer; private SharpDX.Direct3D11.Texture2D backBuffer;
internal Effect_DX11 currentEffect; internal Effect_DX11 currentEffect;
private VertexBuffer currentVertexBuffer;
private IndexBuffer currentIndexBuffer;
private SharpDX.Direct3D11.Viewport currentViewport; private SharpDX.Direct3D11.Viewport currentViewport;
private uint lastClearColor;
private SharpDX.Color4 clearColor;
#endregion #endregion
internal DeviceContext NativeDevice #region Constructor
{ public GraphicsDeviceWindowsDX11(PresentationParameters presentationParameters)
get : base(presentationParameters)
{
return this.deviceContext;
}
}
public bool VSync { get; set; }
public GraphicsDeviceWindowsDX11(PresentationParameters presentationParameters)
{ {
VSync = true; }
#endregion
// SwapChain description #region CreateDevice
var desc = new SwapChainDescription() protected override void CreateDevice(PresentationParameters presentationParameters)
{ {
BufferCount = 1, var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth, ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight, new Rational(60, 1), presentationParameters.BackBufferHeight, new Rational(60, 1),
BaseFormatConverter.Translate(presentationParameters.BackBufferFormat)), BaseFormatConverter.Translate(presentationParameters.BackBufferFormat)),
IsWindowed = true, IsWindowed = true,
OutputHandle = presentationParameters.DeviceWindowHandle, OutputHandle = presentationParameters.DeviceWindowHandle,
SampleDescription = new SampleDescription(1, 0), SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard, SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput Usage = Usage.RenderTargetOutput
}; };
// Create Device and SwapChain // Create Device and SwapChain
Device dxDevice; Device dxDevice;
#if DIRECTX_DEBUG_LAYER // http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx var flags = IsDebugMode ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out dxDevice, out swapChain); Device.CreateWithSwapChain(DriverType.Hardware, flags, desc, out dxDevice, out swapChain);
#else nativeDevice = dxDevice.ImmediateContext;
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out dxDevice, out swapChain); }
#endif #endregion
this.deviceContext = dxDevice.ImmediateContext;
// Ignore all windows events #region CreateRenderView
Factory factory = swapChain.GetParent<Factory>(); protected override void CreateRenderView()
factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll); {
backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0);
renderView = new RenderTargetView(nativeDevice.Device, backBuffer);
}
#endregion
WindowHelper.ResizeRenderWindow(presentationParameters); #region CreateDepthStencilBuffer
protected override void CreateDepthStencilBuffer(Format depthFormat)
// New RenderTargetView from the backbuffer
backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0);
renderView = new RenderTargetView(deviceContext.Device, backBuffer);
currentViewport = new SharpDX.Direct3D11.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
//
// create the depth stencil buffer
//
Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != Format.Unknown)
{
CreateDepthStencilBuffer(depthFormat);
}
}
private void CreateDepthStencilBuffer(Format depthFormat)
{ {
if (this.depthStencilBuffer != null && if (this.depthStencilBuffer != null &&
this.depthStencilBuffer.Description.Format == depthFormat && this.depthStencilBuffer.Description.Format == depthFormat &&
@ -147,30 +116,21 @@ namespace ANX.RenderSystem.Windows.DX11
CpuAccessFlags = CpuAccessFlags.None, CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None OptionFlags = ResourceOptionFlags.None
}; };
this.depthStencilBuffer = new SharpDX.Direct3D11.Texture2D(deviceContext.Device, depthStencilTextureDesc); this.depthStencilBuffer = new SharpDX.Direct3D11.Texture2D(nativeDevice.Device, depthStencilTextureDesc);
this.depthStencilView = new DepthStencilView(deviceContext.Device, this.depthStencilBuffer); this.depthStencilView = new DepthStencilView(nativeDevice.Device, this.depthStencilBuffer);
Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, ANX.Framework.Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472 Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, ANX.Framework.Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472
} }
#endregion
#region Clear #region Clear
public void Clear(ref Color color) public void Clear(ref Color color)
{ {
uint newClearColor = color.PackedValue; UpdateClearColorIfNeeded(ref color);
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;
}
if (this.renderTargetView[0] == null) if (this.renderTargetView[0] == null)
{ nativeDevice.ClearRenderTargetView(this.renderView, this.clearColor);
this.deviceContext.ClearRenderTargetView(this.renderView, this.clearColor);
}
else else
{ {
for (int i = 0; i < this.renderTargetView.Length; i++) for (int i = 0; i < this.renderTargetView.Length; i++)
@ -180,7 +140,7 @@ namespace ANX.RenderSystem.Windows.DX11
break; break;
} }
this.deviceContext.ClearRenderTargetView(this.renderTargetView[i], this.clearColor); nativeDevice.ClearRenderTargetView(this.renderTargetView[i], this.clearColor);
} }
} }
@ -199,19 +159,15 @@ namespace ANX.RenderSystem.Windows.DX11
this.lastClearColor = 0; this.lastClearColor = 0;
if (this.renderTargetView[0] == null) if (this.renderTargetView[0] == null)
{ nativeDevice.ClearRenderTargetView(this.renderView, this.clearColor);
this.deviceContext.ClearRenderTargetView(this.renderView, this.clearColor);
}
else else
{ {
for (int i = 0; i < this.renderTargetView.Length; i++) for (int i = 0; i < this.renderTargetView.Length; i++)
{ {
if (this.renderTargetView[i] == null) if (this.renderTargetView[i] == null)
{
break; break;
}
this.deviceContext.ClearRenderTargetView(this.renderTargetView[i], this.clearColor); nativeDevice.ClearRenderTargetView(this.renderTargetView[i], this.clearColor);
} }
} }
} }
@ -221,15 +177,17 @@ namespace ANX.RenderSystem.Windows.DX11
if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options) if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options)
{ {
// Clear the stencil buffer // Clear the stencil buffer
deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil); nativeDevice.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth |
DepthStencilClearFlags.Stencil, depth, (byte)stencil);
} }
else if ((options | ClearOptions.Stencil) == options) else if ((options | ClearOptions.Stencil) == options)
{ {
deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil); nativeDevice.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth,
(byte)stencil);
} }
else else
{ {
deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil); nativeDevice.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil);
} }
} }
} }
@ -243,7 +201,7 @@ namespace ANX.RenderSystem.Windows.DX11
} }
#endregion #endregion
#region DrawPrimitives & DrawIndexedPrimitives #region DrawIndexedPrimitives
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex,
int numVertices, int startIndex, int primitiveCount) int numVertices, int startIndex, int primitiveCount)
{ {
@ -255,21 +213,24 @@ namespace ANX.RenderSystem.Windows.DX11
var layout = SetupInputLayout(passSignature); var layout = SetupInputLayout(passSignature);
// Prepare All the stages // Prepare All the stages
deviceContext.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
deviceContext.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
pass.Apply(deviceContext); pass.Apply(nativeDevice);
deviceContext.DrawIndexed(BaseFormatConverter.CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex); nativeDevice.DrawIndexed(BaseFormatConverter.CalculateVertexCount(primitiveType, primitiveCount), startIndex,
baseVertex);
} }
layout.Dispose(); layout.Dispose();
layout = null; layout = null;
} }
#endregion
#region DrawPrimitives
public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount) public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
{ {
SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature; SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature;
@ -278,27 +239,26 @@ namespace ANX.RenderSystem.Windows.DX11
var layout = SetupInputLayout(passSignature); var layout = SetupInputLayout(passSignature);
// Prepare All the stages // Prepare All the stages
deviceContext.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
deviceContext.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
pass.Apply(deviceContext); pass.Apply(nativeDevice);
deviceContext.Draw(primitiveCount, vertexOffset); nativeDevice.Draw(primitiveCount, vertexOffset);
} }
layout.Dispose(); layout.Dispose();
layout = null; layout = null;
} }
#endregion
#endregion // DrawPrimitives & DrawIndexedPrimitives
#region DrawInstancedPrimitives #region DrawInstancedPrimitives
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount)
{ {
deviceContext.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0); nativeDevice.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0);
} }
#endregion // DrawInstancedPrimitives #endregion // DrawInstancedPrimitives
@ -310,15 +270,15 @@ namespace ANX.RenderSystem.Windows.DX11
{ {
int vertexCount = vertexData.Length; int vertexCount = vertexData.Length;
int indexCount = indexData.Length; int indexCount = indexData.Length;
var vb11 = new VertexBuffer_DX11(this.deviceContext.Device, vertexDeclaration, vertexCount, BufferUsage.None); var vb11 = new VertexBuffer_DX11(nativeDevice.Device, vertexDeclaration, vertexCount, BufferUsage.None);
vb11.SetData<T>(null, vertexData); vb11.SetData<T>(null, vertexData);
var nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer, var nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer,
vertexDeclaration.VertexStride, 0); vertexDeclaration.VertexStride, 0);
deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
IndexBuffer_DX11 idx10 = new IndexBuffer_DX11(this.deviceContext.Device, indexFormat, indexCount, BufferUsage.None); IndexBuffer_DX11 idx10 = new IndexBuffer_DX11(nativeDevice.Device, indexFormat, indexCount, BufferUsage.None);
if (indexData.GetType() == typeof(Int16[])) if (indexData.GetType() == typeof(Int16[]))
idx10.SetData<short>(null, (short[])indexData); idx10.SetData<short>(null, (short[])indexData);
else else
@ -333,29 +293,29 @@ namespace ANX.RenderSystem.Windows.DX11
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{ {
int vertexCount = vertexData.Length; int vertexCount = vertexData.Length;
VertexBuffer_DX11 vb11 = new VertexBuffer_DX11(this.deviceContext.Device, vertexDeclaration, vertexCount, BufferUsage.None); VertexBuffer_DX11 vb11 = new VertexBuffer_DX11(nativeDevice.Device, vertexDeclaration, vertexCount, BufferUsage.None);
vb11.SetData<T>(null, vertexData); vb11.SetData<T>(null, vertexData);
SharpDX.Direct3D11.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0); SharpDX.Direct3D11.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0);
deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature; SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature;
SetupEffectForDraw(out pass, out technique, out passSignature); SetupEffectForDraw(out pass, out technique, out passSignature);
var layout = CreateInputLayout(deviceContext.Device, passSignature, vertexDeclaration); var layout = CreateInputLayout(nativeDevice.Device, passSignature, vertexDeclaration);
deviceContext.InputAssembler.InputLayout = layout; nativeDevice.InputAssembler.InputLayout = layout;
// Prepare All the stages // Prepare All the stages
deviceContext.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType); nativeDevice.InputAssembler.PrimitiveTopology = BaseFormatConverter.Translate(primitiveType);
deviceContext.Rasterizer.SetViewports(currentViewport); nativeDevice.Rasterizer.SetViewports(currentViewport);
//device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); //device.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
for (int i = 0; i < technique.Description.PassCount; ++i) for (int i = 0; i < technique.Description.PassCount; ++i)
{ {
pass.Apply(deviceContext); pass.Apply(nativeDevice);
deviceContext.Draw(primitiveCount, vertexOffset); nativeDevice.Draw(primitiveCount, vertexOffset);
} }
layout.Dispose(); layout.Dispose();
@ -364,7 +324,9 @@ namespace ANX.RenderSystem.Windows.DX11
#endregion // DrawUserPrimitives<T> #endregion // DrawUserPrimitives<T>
private void SetupEffectForDraw(out SharpDX.Direct3D11.EffectPass pass, out SharpDX.Direct3D11.EffectTechnique technique, out ShaderBytecode passSignature) #region SetupEffectForDraw
private void SetupEffectForDraw(out SharpDX.Direct3D11.EffectPass pass, out SharpDX.Direct3D11.EffectTechnique technique,
out ShaderBytecode passSignature)
{ {
// get the current effect // get the current effect
//TODO: check for null and throw exception //TODO: check for null and throw exception
@ -377,66 +339,53 @@ namespace ANX.RenderSystem.Windows.DX11
pass = technique.GetPassByIndex(0); pass = technique.GetPassByIndex(0);
passSignature = pass.Description.Signature; passSignature = pass.Description.Signature;
} }
#endregion
private InputLayout SetupInputLayout(ShaderBytecode passSignature) #region SetupInputLayout
private InputLayout SetupInputLayout(ShaderBytecode passSignature)
{ {
// get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler // get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler
//TODO: check for null and throw exception //TODO: check for null and throw exception
VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration; VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration;
var layout = CreateInputLayout(deviceContext.Device, passSignature, vertexDeclaration); var layout = CreateInputLayout(nativeDevice.Device, passSignature, vertexDeclaration);
deviceContext.InputAssembler.InputLayout = layout; nativeDevice.InputAssembler.InputLayout = layout;
return layout; return layout;
} }
#endregion
public void SetIndexBuffer(IndexBuffer indexBuffer) #region SetIndexBuffer
public void SetIndexBuffer(IndexBuffer indexBuffer)
{ {
if (indexBuffer == null) if (indexBuffer == null)
{
throw new ArgumentNullException("indexBuffer"); throw new ArgumentNullException("indexBuffer");
}
this.currentIndexBuffer = indexBuffer; this.currentIndexBuffer = indexBuffer;
IndexBuffer_DX11 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX11; IndexBuffer_DX11 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX11;
if (nativeIndexBuffer != null) if (nativeIndexBuffer != null)
{ {
deviceContext.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, nativeDevice.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer,
BaseFormatConverter.Translate(indexBuffer.IndexElementSize), 0); BaseFormatConverter.Translate(indexBuffer.IndexElementSize), 0);
} }
else else
{
throw new Exception("couldn't fetch native DirectX10 IndexBuffer"); throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
}
} }
#endregion
#if XNAEXT #region SetVertexBuffers
public void SetConstantBuffer(int slot, ANX.Framework.Graphics.ConstantBuffer constantBuffer) public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
{
if (constantBuffer == null)
{
throw new ArgumentNullException("constantBuffer");
}
throw new NotImplementedException();
}
#endif
public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
{ {
if (vertexBuffers == null) if (vertexBuffers == null)
{
throw new ArgumentNullException("vertexBuffers"); throw new ArgumentNullException("vertexBuffers");
}
this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-) this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-)
SharpDX.Direct3D11.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding[vertexBuffers.Length]; var nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding[vertexBuffers.Length];
for (int i = 0; i < vertexBuffers.Length; i++) for (int i = 0; i < vertexBuffers.Length; i++)
{ {
ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i]; ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i];
VertexBuffer_DX11 nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX11; var nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX11;
if (nativeVertexBuffer != null) if (nativeVertexBuffer != null)
{ {
@ -448,60 +397,43 @@ namespace ANX.RenderSystem.Windows.DX11
} }
} }
deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
} }
#endregion
public void SetViewport(ANX.Framework.Graphics.Viewport viewport) #region SetViewport
{ protected override void SetViewport(int x, int y, int width, int height, float minDepth, float maxDepth)
this.currentViewport = new SharpDX.Direct3D11.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth); {
} currentViewport = new SharpDX.Direct3D11.Viewport(x, y, width, height, minDepth, maxDepth);
}
#endregion
/// <summary> #region CreateInputLayout
/// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration)
/// to the DirectX 10 types. This is what this method is for.
/// </summary>
private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration)
{ {
VertexElement[] vertexElements = vertexDeclaration.GetVertexElements(); VertexElement[] vertexElements = vertexDeclaration.GetVertexElements();
int elementCount = vertexElements.Length; int elementCount = vertexElements.Length;
InputElement[] inputElements = new InputElement[elementCount]; InputElement[] inputElements = new InputElement[elementCount];
for (int i = 0; i < elementCount; i++) for (int i = 0; i < elementCount; i++)
{
inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]); inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]);
}
// Layout from VertexShader input signature // Layout from VertexShader input signature
return new InputLayout(device, passSignature, inputElements); return new InputLayout(device, passSignature, inputElements);
} }
#endregion
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement) #region CreateInputElementFromVertexElement
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
{ {
string elementName = BaseFormatConverter.Translate(ref vertexElement); string elementName = BaseFormatConverter.Translate(ref vertexElement);
Format elementFormat = BaseFormatConverter.ConvertVertexElementFormat(vertexElement.VertexElementFormat);
return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
}
#endregion
Format elementFormat; #region SetRenderTargets
switch (vertexElement.VertexElementFormat) public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{
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) if (renderTargets == null)
{ {
@ -516,7 +448,7 @@ namespace ANX.RenderSystem.Windows.DX11
} }
//deviceContext.OutputMerger.SetRenderTargets(1, new RenderTargetView[] { this.renderView }, this.depthStencilView); //deviceContext.OutputMerger.SetRenderTargets(1, new RenderTargetView[] { this.renderView }, this.depthStencilView);
deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
} }
else else
{ {
@ -547,60 +479,30 @@ namespace ANX.RenderSystem.Windows.DX11
renderTargetView[i].Dispose(); renderTargetView[i].Dispose();
} }
renderTargetView[i] = new RenderTargetView(deviceContext.Device, ((Texture2D_DX11)nativeRenderTarget).NativeShaderResourceView.Resource); renderTargetView[i] = new RenderTargetView(nativeDevice.Device,
((Texture2D_DX11)nativeRenderTarget).NativeShaderResourceView.Resource);
} }
} }
//deviceContext.OutputMerger.SetRenderTargets(renderTargetCount, renderTargetView, this.depthStencilView); //deviceContext.OutputMerger.SetRenderTargets(renderTargetCount, renderTargetView, this.depthStencilView);
deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderTargetView); nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderTargetView);
} }
} }
#endregion
public void GetBackBufferData<T>(ANX.Framework.Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct #region DisposeRenderView
{ protected override void DisposeRenderView()
throw new NotImplementedException(); {
} renderView.Dispose();
renderView = null;
public void GetBackBufferData<T>(T[] data) where T : struct backBuffer.Dispose();
{ backBuffer = null;
throw new NotImplementedException(); }
} #endregion
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct #region Dispose
{ public void Dispose()
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, swapChain.Description.Flags);
backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0);
renderView = new RenderTargetView(deviceContext.Device, backBuffer);
currentViewport = new SharpDX.Direct3D11.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
//
// create the depth stencil buffer
//
Format depthFormat = BaseFormatConverter.Translate(presentationParameters.DepthStencilFormat);
if (depthFormat != Format.Unknown)
{
CreateDepthStencilBuffer(depthFormat);
}
}
WindowHelper.ResizeRenderWindow(presentationParameters);
}
public void Dispose()
{ {
for (int i = 0; i < renderTargetView.Length; i++) for (int i = 0; i < renderTargetView.Length; i++)
{ {
@ -613,11 +515,7 @@ namespace ANX.RenderSystem.Windows.DX11
if (swapChain != null) if (swapChain != null)
{ {
renderView.Dispose(); DisposeRenderView();
renderView = null;
backBuffer.Dispose();
backBuffer = null;
swapChain.Dispose(); swapChain.Dispose();
swapChain = null; swapChain = null;
@ -634,5 +532,6 @@ namespace ANX.RenderSystem.Windows.DX11
//TODO: dispose everything else //TODO: dispose everything else
} }
#endregion
} }
} }

View File

@ -72,6 +72,10 @@
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project> <Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name> <Name>ANX.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\RenderSystems\ANX.BaseDirectX\ANX.BaseDirectX.csproj">
<Project>{A4D3AD34-E49C-4142-8620-2AFF44ED6719}</Project>
<Name>ANX.BaseDirectX</Name>
</ProjectReference>
<ProjectReference Include="..\..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj"> <ProjectReference Include="..\..\RenderSystems\ANX.Framework.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project> <Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name> <Name>ANX.RenderSystem.Windows.DX10</Name>