2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../ComObject.h"
\r
26 #include "../dxgi/Enums.h"
\r
28 #include "DeviceChild10.h"
\r
30 #include "../dxgi/SwapChainDxgi.h"
\r
31 #include "../dxgi/SurfaceDxgi.h"
\r
33 #include "TextureLoadInformation10.h"
\r
37 namespace Direct3D10
\r
40 /// A resource object.
\r
42 /// <unmanaged>ID3D10Resource</unmanaged>
\r
43 public ref class Resource abstract : public DeviceChild
\r
45 COMOBJECT_BASE(ID3D10Resource);
\r
48 static int GetMipSize( int mipSlice, int baseSliceSize );
\r
50 static ID3D10Resource* ConstructFromFile( SlimDX::Direct3D10::Device^ device, System::String^ fileName, D3DX10_IMAGE_LOAD_INFO* info );
\r
51 static ID3D10Resource* ConstructFromMemory( SlimDX::Direct3D10::Device^ device, array<System::Byte>^ memory, D3DX10_IMAGE_LOAD_INFO* info );
\r
52 static ID3D10Resource* ConstructFromStream( SlimDX::Direct3D10::Device^ device, System::IO::Stream^ stream, int sizeInBytes, D3DX10_IMAGE_LOAD_INFO* info );
\r
54 static Resource^ FromPointer( ID3D10Resource* pointer );
\r
61 /// Returns a DXGI Surface for this resource.
\r
63 /// <returns>The buffer interface, or <c>null</c> on failure.</returns>
\r
64 SlimDX::DXGI::Surface^ AsSurface();
\r
67 /// Gets a swap chain back buffer.
\r
69 /// <typeparam name="T">The type of the buffer.</typeparam>
\r
70 /// <param name="swapChain">The swap chain to get the buffer from.</param>
\r
71 /// <param name="index">The index of the desired buffer.</param>
\r
72 /// <returns>The buffer interface, or <c>null</c> on failure.</returns>
\r
73 generic< class T > where T : Resource, ref class
\r
74 static T FromSwapChain( SlimDX::DXGI::SwapChain^ swapChain, int index );
\r
76 static Resource^ FromPointer( System::IntPtr pointer );
\r
79 /// Gets or sets the resource's eviction priority.
\r
81 property DXGI::ResourcePriority EvictionPriority
\r
83 DXGI::ResourcePriority get();
\r
84 void set(DXGI::ResourcePriority value);
\r
88 /// Gets the resource's dimension (type).
\r
90 property ResourceDimension Dimension
\r
92 ResourceDimension get();
\r
95 static Result LoadTextureFromTexture(Resource^ source, Resource^ destination, TextureLoadInformation loadInformation);
\r
96 static Result FilterTexture(Resource^ texture, int sourceLevel, FilterFlags mipFilter);
\r
99 /// Calculates a subresource index.
\r
101 /// <param name="mipSlice">The index of the desired mip slice.</param>
\r
102 /// <param name="arraySlice">The index of the desired array slice.</param>
\r
103 /// <param name="mipLevels">The total number of mip levels.</param>
\r
104 /// <returns>The subresource index (equivalent to mipSlice + (arraySlice * mipLevels)).</returns>
\r
105 static int CalculateSubresourceIndex( int mipSlice, int arraySlice, int mipLevels );
\r
107 literal int MaximumMipLevels = D3D10_REQ_MIP_LEVELS;
\r
108 literal int ResourceSizeInMegabytes = D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES;
\r
109 literal int MaximumTexture1DArraySize = D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
\r
110 literal int MaximumTexture2DArraySize = D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
\r
111 literal int MaximumTexture1DSize = D3D10_REQ_TEXTURE1D_U_DIMENSION;
\r
112 literal int MaximumTexture2DSize = D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
\r
113 literal int MaximumTexture3DSize = D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
\r
114 literal int MaximumTextureCubeSize = D3D10_REQ_TEXTURECUBE_DIMENSION;
\r