From 4a066d75d9c421283bf99976883e8bca817728da Mon Sep 17 00:00:00 2001 From: AndrewSt Date: Thu, 2 Jun 2016 10:44:51 +0300 Subject: [PATCH] [Direct3D11] Improve support Direct3D 11.3 --- Source/SharpDX.Direct3D11/DeviceContext3.cs | 36 ++++++++ Source/SharpDX.Direct3D11/Query1.cs | 38 ++++++++ .../SharpDX.Direct3D11/RenderTargetView1.cs | 51 +++++++++++ .../SharpDX.Direct3D11/ShaderResourceView1.cs | 56 ++++++++++++ .../SharpDX.Direct3D11.csproj | 7 ++ Source/SharpDX.Direct3D11/Texture2D1.cs | 90 +++++++++++++++++++ Source/SharpDX.Direct3D11/Texture3D1.cs | 56 ++++++++++++ .../UnorderedAccessView1.cs | 51 +++++++++++ 8 files changed, 385 insertions(+) create mode 100644 Source/SharpDX.Direct3D11/DeviceContext3.cs create mode 100644 Source/SharpDX.Direct3D11/Query1.cs create mode 100644 Source/SharpDX.Direct3D11/RenderTargetView1.cs create mode 100644 Source/SharpDX.Direct3D11/ShaderResourceView1.cs create mode 100644 Source/SharpDX.Direct3D11/Texture2D1.cs create mode 100644 Source/SharpDX.Direct3D11/Texture3D1.cs create mode 100644 Source/SharpDX.Direct3D11/UnorderedAccessView1.cs diff --git a/Source/SharpDX.Direct3D11/DeviceContext3.cs b/Source/SharpDX.Direct3D11/DeviceContext3.cs new file mode 100644 index 000000000..58f911d75 --- /dev/null +++ b/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 + { + /// + /// Initializes a new deferred context instance of class. + /// + /// + public DeviceContext3(Device3 device) + : base(IntPtr.Zero) + { + device.CreateDeferredContext3(0, this); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/Query1.cs b/Source/SharpDX.Direct3D11/Query1.cs new file mode 100644 index 000000000..851077304 --- /dev/null +++ b/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 + { + /// + /// Constructs a new based on the specified description. + /// + /// The device with which to associate the state object. + /// The query description. + /// The newly created object. + public Query1(Device3 device, QueryDescription1 description) + : base(IntPtr.Zero) + { + device.CreateQuery1(description, this); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/RenderTargetView1.cs b/Source/SharpDX.Direct3D11/RenderTargetView1.cs new file mode 100644 index 000000000..bb372428d --- /dev/null +++ b/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 + { + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the RenderTarget flag. + /// ID3D11Device3::CreateRenderTargetView1 + public RenderTargetView1(Device3 device, Resource resource) + : base(IntPtr.Zero) + { + device.CreateRenderTargetView1(resource, null, this); + } + + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the RenderTarget flag. + /// A structure describing the to be created. + /// ID3D11Device3::CreateRenderTargetView1 + public RenderTargetView1(Device3 device, Resource resource, RenderTargetViewDescription1 description) + : base(IntPtr.Zero) + { + device.CreateRenderTargetView1(resource, description, this); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/ShaderResourceView1.cs b/Source/SharpDX.Direct3D11/ShaderResourceView1.cs new file mode 100644 index 000000000..8e8e352e3 --- /dev/null +++ b/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 + { + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the ShaderResource flag. + /// ff476519 + /// HRESULT ID3D11Device3::CreateShaderResourceView1([In] ID3D11Resource* pResource,[In, Optional] const D3D11_SHADER_RESOURCE_VIEW_DESC1* pDesc,[Out, Fast] ID3D11ShaderResourceView1** ppSRView) + /// ID3D11Device3::CreateShaderResourceView1 + public ShaderResourceView1(Device3 device, Resource resource) + : base(IntPtr.Zero) + { + device.CreateShaderResourceView1(resource, null, this); + } + + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the ShaderResource flag. + /// A structure describing the to be created. + /// ff476519 + /// HRESULT ID3D11Device3::CreateShaderResourceView1([In] ID3D11Resource* pResource,[In, Optional] const D3D11_SHADER_RESOURCE_VIEW_DESC1* pDesc,[Out, Fast] ID3D11ShaderResourceView1** ppSRView) + /// ID3D11Device3::CreateShaderResourceView1 + public ShaderResourceView1(Device3 device, Resource resource, ShaderResourceViewDescription1 description) + : base(IntPtr.Zero) + { + device.CreateShaderResourceView1(resource, description, this); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/SharpDX.Direct3D11.csproj b/Source/SharpDX.Direct3D11/SharpDX.Direct3D11.csproj index 271323f7c..c314c82a5 100644 --- a/Source/SharpDX.Direct3D11/SharpDX.Direct3D11.csproj +++ b/Source/SharpDX.Direct3D11/SharpDX.Direct3D11.csproj @@ -24,7 +24,9 @@ + + @@ -67,18 +69,23 @@ + + + + + diff --git a/Source/SharpDX.Direct3D11/Texture2D1.cs b/Source/SharpDX.Direct3D11/Texture2D1.cs new file mode 100644 index 000000000..c37c159b4 --- /dev/null +++ b/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 + { + /// + /// Initializes a new instance of the class. + /// + /// The device with which to associate the texture. + /// The description of the texture. + /// ff476521 + /// HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D1** ppTexture2D) + /// ID3D11Device3::CreateTexture2D1 + public Texture2D1(Device3 device, Texture2DDescription1 description) + : base(IntPtr.Zero) + { + device.CreateTexture2D1(ref description, null, this); + } + + /// + /// Initializes a new instance of the class. + /// + /// The device with which to associate the texture. + /// The description of the texture. + /// An array of initial texture data for each subresource. + /// ff476521 + /// HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D1** ppTexture2D) + /// ID3D11Device3::CreateTexture2D1 + 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); + } + + /// + /// Initializes a new instance of the class. + /// + /// The device with which to associate the texture. + /// The description of the texture. + /// An array of initial texture data for each subresource. + /// ff476521 + /// HRESULT ID3D11Device3::CreateTexture2D1([In] const D3D11_TEXTURE2D_DESC1* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D** ppTexture2D) + /// ID3D11Device3::CreateTexture2D1 + public Texture2D1(Device3 device, Texture2DDescription1 description, DataBox[] data) + : base(IntPtr.Zero) + { + device.CreateTexture2D1(ref description, data, this); + } + + /// + 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); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/Texture3D1.cs b/Source/SharpDX.Direct3D11/Texture3D1.cs new file mode 100644 index 000000000..035090d76 --- /dev/null +++ b/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 + { + /// + /// Initializes a new instance of the class. + /// + /// The device with which to associate the texture. + /// The description of the texture. + public Texture3D1(Device3 device, Texture3DDescription1 description) + : base(IntPtr.Zero) + { + device.CreateTexture3D1(ref description, null, this); + } + + /// + /// Initializes a new instance of the class. + /// + /// The device with which to associate the texture. + /// The description of the texture. + /// An array of initial texture data for each subresource. + public Texture3D1(Device3 device, Texture3DDescription1 description, DataBox[] data) : base(IntPtr.Zero) + { + device.CreateTexture3D1(ref description, data, this); + } + + /// + 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); + } + } +} \ No newline at end of file diff --git a/Source/SharpDX.Direct3D11/UnorderedAccessView1.cs b/Source/SharpDX.Direct3D11/UnorderedAccessView1.cs new file mode 100644 index 000000000..63847e036 --- /dev/null +++ b/Source/SharpDX.Direct3D11/UnorderedAccessView1.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 UnorderedAccessView1 + { + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the UnorderedAccess flag. + /// ID3D11Device3::CreateUnorderedAccessView1 + public UnorderedAccessView1(Device3 device, Resource resource) + : base(IntPtr.Zero) + { + device.CreateUnorderedAccessView1(resource, null, this); + } + + /// + /// Creates a for accessing resource data. + /// + /// The device to use when creating this . + /// The resource that represents the render-target surface. This surface must have been created with the UnorderedAccess flag. + /// A structure describing the to be created. + /// ID3D11Device3::CreateUnorderedAccessView1 + public UnorderedAccessView1(Device3 device, Resource resource, UnorderedAccessViewDescription1 description) + : base(IntPtr.Zero) + { + device.CreateUnorderedAccessView1(resource, description, this); + } + } +} \ No newline at end of file