Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
[Direct3D11] Improve support Direct3D 11.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSt committed Jun 2, 2016
1 parent 7f61b6b commit 4a066d7
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Source/SharpDX.Direct3D11/DeviceContext3.cs
@@ -0,0 +1,36 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;

namespace SharpDX.Direct3D11
{
public partial class DeviceContext3
{
/// <summary>
/// Initializes a new deferred context instance of <see cref="SharpDX.Direct3D11.DeviceContext3"/> class.
/// </summary>
/// <param name="device"></param>
public DeviceContext3(Device3 device)
: base(IntPtr.Zero)
{
device.CreateDeferredContext3(0, this);
}
}
}
38 changes: 38 additions & 0 deletions Source/SharpDX.Direct3D11/Query1.cs
@@ -0,0 +1,38 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;

namespace SharpDX.Direct3D11
{
public partial class Query1
{
/// <summary>
/// Constructs a new <see cref = "T:SharpDX.Direct3D11.Query1" /> based on the specified description.
/// </summary>
/// <param name = "device">The device with which to associate the state object.</param>
/// <param name = "description">The query description.</param>
/// <returns>The newly created object.</returns>
public Query1(Device3 device, QueryDescription1 description)
: base(IntPtr.Zero)
{
device.CreateQuery1(description, this);
}
}
}
51 changes: 51 additions & 0 deletions Source/SharpDX.Direct3D11/RenderTargetView1.cs
@@ -0,0 +1,51 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;

namespace SharpDX.Direct3D11
{
public partial class RenderTargetView1
{
/// <summary>
/// Creates a <see cref = "T:SharpDX.Direct3D11.RenderTargetView1" /> for accessing resource data.
/// </summary>
/// <param name = "device">The device to use when creating this <see cref = "T:SharpDX.Direct3D11.RenderTargetView1" />.</param>
/// <param name = "resource">The resource that represents the render-target surface. This surface must have been created with the <see cref = "T:SharpDX.Direct3D11.BindFlags">RenderTarget</see> flag.</param>
/// <unmanaged>ID3D11Device3::CreateRenderTargetView1</unmanaged>
public RenderTargetView1(Device3 device, Resource resource)
: base(IntPtr.Zero)
{
device.CreateRenderTargetView1(resource, null, this);
}

/// <summary>
/// Creates a <see cref = "T:SharpDX.Direct3D11.RenderTargetView" /> for accessing resource data.
/// </summary>
/// <param name = "device">The device to use when creating this <see cref = "T:SharpDX.Direct3D11.RenderTargetView1" />.</param>
/// <param name = "resource">The resource that represents the render-target surface. This surface must have been created with the <see cref = "T:SharpDX.Direct3D11.BindFlags">RenderTarget</see> flag.</param>
/// <param name = "description">A structure describing the <see cref = "T:SharpDX.Direct3D11.RenderTargetView1" /> to be created.</param>
/// <unmanaged>ID3D11Device3::CreateRenderTargetView1</unmanaged>
public RenderTargetView1(Device3 device, Resource resource, RenderTargetViewDescription1 description)
: base(IntPtr.Zero)
{
device.CreateRenderTargetView1(resource, description, this);
}
}
}
56 changes: 56 additions & 0 deletions Source/SharpDX.Direct3D11/ShaderResourceView1.cs
@@ -0,0 +1,56 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;

namespace SharpDX.Direct3D11
{
public partial class ShaderResourceView1
{
/// <summary>
/// Creates a <see cref = "T:SharpDX.Direct3D11.ShaderResourceView1" /> for accessing resource data.
/// </summary>
/// <param name = "device">The device to use when creating this <see cref = "T:SharpDX.Direct3D11.ShaderResourceView1" />.</param>
/// <param name = "resource">The resource that represents the render-target surface. This surface must have been created with the <see cref = "T:SharpDX.Direct3D11.BindFlags">ShaderResource</see> flag.</param>
/// <msdn-id>ff476519</msdn-id>
/// <unmanaged>HRESULT ID3D11Device3::CreateShaderResourceView1([In] ID3D11Resource* pResource,[In, Optional] const D3D11_SHADER_RESOURCE_VIEW_DESC1* pDesc,[Out, Fast] ID3D11ShaderResourceView1** ppSRView)</unmanaged>
/// <unmanaged-short>ID3D11Device3::CreateShaderResourceView1</unmanaged-short>
public ShaderResourceView1(Device3 device, Resource resource)
: base(IntPtr.Zero)
{
device.CreateShaderResourceView1(resource, null, this);
}

/// <summary>
/// Creates a <see cref = "T:SharpDX.Direct3D11.ShaderResourceView" /> for accessing resource data.
/// </summary>
/// <param name = "device">The device to use when creating this <see cref = "T:SharpDX.Direct3D11.ShaderResourceView" />.</param>
/// <param name = "resource">The resource that represents the render-target surface. This surface must have been created with the <see cref = "T:SharpDX.Direct3D11.BindFlags">ShaderResource</see> flag.</param>
/// <param name = "description">A structure describing the <see cref = "T:SharpDX.Direct3D11.ShaderResourceView" /> to be created.</param>
/// <msdn-id>ff476519</msdn-id>
/// <unmanaged>HRESULT ID3D11Device3::CreateShaderResourceView1([In] ID3D11Resource* pResource,[In, Optional] const D3D11_SHADER_RESOURCE_VIEW_DESC1* pDesc,[Out, Fast] ID3D11ShaderResourceView1** ppSRView)</unmanaged>
/// <unmanaged-short>ID3D11Device3::CreateShaderResourceView1</unmanaged-short>
public ShaderResourceView1(Device3 device, Resource resource, ShaderResourceViewDescription1 description)
: base(IntPtr.Zero)
{
device.CreateShaderResourceView1(resource, description, this);
}
}
}
7 changes: 7 additions & 0 deletions Source/SharpDX.Direct3D11/SharpDX.Direct3D11.csproj
Expand Up @@ -24,7 +24,9 @@
<Compile Include="BlendStateDescription1.cs" />
<Compile Include="Device2.cs" />
<Compile Include="Device3.cs" />
<Compile Include="DeviceContext3.cs" />
<Compile Include="DeviceContext2.cs" />
<Compile Include="Query1.cs" />
<Compile Include="RasterizerState2.cs" />
<Compile Include="RasterizerStateDescription1.cs" />
<Compile Include="DepthStencilStateDescription.cs" />
Expand Down Expand Up @@ -67,18 +69,23 @@
<Compile Include="Query.cs" />
<Compile Include="RasterizerState.cs" />
<Compile Include="RenderTargetBlendDescription.cs" />
<Compile Include="RenderTargetView1.cs" />
<Compile Include="RenderTargetView.cs" />
<Compile Include="Resource.cs" />
<Compile Include="ResourceRegion.cs" />
<Compile Include="ResourceView.cs" />
<Compile Include="SamplerState.cs" />
<Compile Include="SamplerStateDescription.cs" />
<Compile Include="ShaderResourceView1.cs" />
<Compile Include="ShaderResourceView.cs" />
<Compile Include="StreamOutputBufferBinding.cs" />
<Compile Include="StreamOutputElement.cs" />
<Compile Include="Texture1D.cs" />
<Compile Include="Texture2D1.cs" />
<Compile Include="Texture2D.cs" />
<Compile Include="Texture3D1.cs" />
<Compile Include="Texture3D.cs" />
<Compile Include="UnorderedAccessView1.cs" />
<Compile Include="UnorderedAccessView.cs" />
<Compile Include="VertexBufferBinding.cs" />
<Compile Include="VertexShader.cs" />
Expand Down
90 changes: 90 additions & 0 deletions Source/SharpDX.Direct3D11/Texture2D1.cs
@@ -0,0 +1,90 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;

namespace SharpDX.Direct3D11
{
public partial class Texture2D1
{
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture2D1" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <msdn-id>ff476521</msdn-id>
/// <unmanaged>HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D1** ppTexture2D)</unmanaged>
/// <unmanaged-short>ID3D11Device3::CreateTexture2D1</unmanaged-short>
public Texture2D1(Device3 device, Texture2DDescription1 description)
: base(IntPtr.Zero)
{
device.CreateTexture2D1(ref description, null, this);
}

/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture2D1" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
/// <msdn-id>ff476521</msdn-id>
/// <unmanaged>HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D1** ppTexture2D)</unmanaged>
/// <unmanaged-short>ID3D11Device3::CreateTexture2D1</unmanaged-short>
public Texture2D1(Device3 device, Texture2DDescription1 description, params DataRectangle[] data)
: base(IntPtr.Zero)
{
DataBox[] subResourceDatas = null;

if (data != null && data.Length > 0)
{
subResourceDatas = new DataBox[data.Length];
for (int i = 0; i < subResourceDatas.Length; i++)
{
subResourceDatas[i].DataPointer = data[i].DataPointer;
subResourceDatas[i].RowPitch = data[i].Pitch;
}
}

device.CreateTexture2D1(ref description, subResourceDatas, this);
}

/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture2D1" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
/// <msdn-id>ff476521</msdn-id>
/// <unmanaged>HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D** ppTexture2D)</unmanaged>
/// <unmanaged-short>ID3D11Device3::CreateTexture2D1</unmanaged-short>
public Texture2D1(Device3 device, Texture2DDescription1 description, DataBox[] data)
: base(IntPtr.Zero)
{
device.CreateTexture2D1(ref description, data, this);
}

/// <inheritdoc/>
public override int CalculateSubResourceIndex(int mipSlice, int arraySlice, out int mipSize)
{
var desc = Description;
mipSize = CalculateMipSize(mipSlice, desc.Height);
return CalculateSubResourceIndex(mipSlice, arraySlice, desc.MipLevels);
}
}
}
56 changes: 56 additions & 0 deletions Source/SharpDX.Direct3D11/Texture3D1.cs
@@ -0,0 +1,56 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;

namespace SharpDX.Direct3D11
{
public partial class Texture3D1
{
/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture3D1" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
public Texture3D1(Device3 device, Texture3DDescription1 description)
: base(IntPtr.Zero)
{
device.CreateTexture3D1(ref description, null, this);
}

/// <summary>
/// Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.Texture3D1" /> class.
/// </summary>
/// <param name = "device">The device with which to associate the texture.</param>
/// <param name = "description">The description of the texture.</param>
/// <param name = "data">An array of initial texture data for each subresource.</param>
public Texture3D1(Device3 device, Texture3DDescription1 description, DataBox[] data) : base(IntPtr.Zero)
{
device.CreateTexture3D1(ref description, data, this);
}

/// <inheritdoc/>
public override int CalculateSubResourceIndex(int mipSlice, int arraySlice, out int mipSize)
{
var desc = Description;
mipSize = CalculateMipSize(mipSlice, desc.Depth);
return CalculateSubResourceIndex(mipSlice, arraySlice, desc.MipLevels);
}
}
}

0 comments on commit 4a066d7

Please sign in to comment.