Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ImageDescription.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 //
4 // Copyright (c) 2010-2012 SharpDX - Alexandre Mutel
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 
24 using System;
25 using System.Runtime.InteropServices;
26 using SiliconStudio.Core;
27 using SiliconStudio.Core.Serialization;
28 
29 namespace SiliconStudio.Paradox.Graphics
30 {
31  /// <summary>
32  /// A description for <see cref="Image"/>.
33  /// </summary>
34  [DataContract]
35  [StructLayout(LayoutKind.Sequential)]
36  public struct ImageDescription : IEquatable<ImageDescription>
37  {
38  /// <summary>
39  /// The dimension of a texture.
40  /// </summary>
42 
43  /// <summary>
44  /// <dd> <p>Texture width (in texels). The range is from 1 to <see cref="SharpDX.Direct3D11.Resource.MaximumTexture1DSize"/> (16384). However, the range is actually constrained by the feature level at which you create the rendering device. For more information about restrictions, see Remarks.</p> </dd>
45  /// </summary>
46  /// <remarks>
47  /// This field is valid for all textures: <see cref="Texture1D"/>, <see cref="Texture2D"/>, <see cref="Texture3D"/> and <see cref="TextureCube"/>.
48  /// </remarks>
49  public int Width;
50 
51  /// <summary>
52  /// <dd> <p>Texture height (in texels). The range is from 1 to <see cref="SharpDX.Direct3D11.Resource.MaximumTexture3DSize"/> (2048). However, the range is actually constrained by the feature level at which you create the rendering device. For more information about restrictions, see Remarks.</p> </dd>
53  /// </summary>
54  /// <remarks>
55  /// This field is only valid for <see cref="Texture2D"/>, <see cref="Texture3D"/> and <see cref="TextureCube"/>.
56  /// </remarks>
57  public int Height;
58 
59  /// <summary>
60  /// <dd> <p>Texture depth (in texels). The range is from 1 to <see cref="SharpDX.Direct3D11.Resource.MaximumTexture3DSize"/> (2048). However, the range is actually constrained by the feature level at which you create the rendering device. For more information about restrictions, see Remarks.</p> </dd>
61  /// </summary>
62  /// <remarks>
63  /// This field is only valid for <see cref="Texture3D"/>.
64  /// </remarks>
65  public int Depth;
66 
67  /// <summary>
68  /// <dd> <p>Number of textures in the array. The range is from 1 to <see cref="SharpDX.Direct3D11.Resource.MaximumTexture1DArraySize"/> (2048). However, the range is actually constrained by the feature level at which you create the rendering device. For more information about restrictions, see Remarks.</p> </dd>
69  /// </summary>
70  /// <remarks>
71  /// This field is only valid for <see cref="Texture1D"/>, <see cref="Texture2D"/> and <see cref="TextureCube"/>
72  /// </remarks>
73  /// <remarks>
74  /// This field is only valid for textures: <see cref="Texture1D"/>, <see cref="Texture2D"/> and <see cref="TextureCube"/>.
75  /// </remarks>
76  public int ArraySize;
77 
78  /// <summary>
79  /// <dd> <p>The maximum number of mipmap levels in the texture. See the remarks in <strong><see cref="SharpDX.Direct3D11.ShaderResourceViewDescription.Texture1DResource"/></strong>. Use 1 for a multisampled texture; or 0 to generate a full set of subtextures.</p> </dd>
80  /// </summary>
81  public int MipLevels;
82 
83  /// <summary>
84  /// <dd> <p>Texture format (see <strong><see cref="SharpDX.DXGI.Format"/></strong>).</p> </dd>
85  /// </summary>
87 
88  public bool Equals(ImageDescription other)
89  {
90  return Dimension.Equals(other.Dimension) && Width == other.Width && Height == other.Height && Depth == other.Depth && ArraySize == other.ArraySize && MipLevels == other.MipLevels && Format.Equals(other.Format);
91  }
92 
93  public override bool Equals(object obj)
94  {
95  if (ReferenceEquals(null, obj)) return false;
96  return obj is ImageDescription && Equals((ImageDescription) obj);
97  }
98 
99  public override int GetHashCode()
100  {
101  unchecked
102  {
103  int hashCode = Dimension.GetHashCode();
104  hashCode = (hashCode * 397) ^ Width;
105  hashCode = (hashCode * 397) ^ Height;
106  hashCode = (hashCode * 397) ^ Depth;
107  hashCode = (hashCode * 397) ^ ArraySize;
108  hashCode = (hashCode * 397) ^ MipLevels;
109  hashCode = (hashCode * 397) ^ Format.GetHashCode();
110  return hashCode;
111  }
112  }
113 
114  public static bool operator ==(ImageDescription left, ImageDescription right)
115  {
116  return left.Equals(right);
117  }
118 
119  public static bool operator !=(ImageDescription left, ImageDescription right)
120  {
121  return !left.Equals(right);
122  }
123 
124  public override string ToString()
125  {
126  return string.Format("Dimension: {0}, Width: {1}, Height: {2}, Depth: {3}, Format: {4}, ArraySize: {5}, MipLevels: {6}", Dimension, Width, Height, Depth, Format, ArraySize, MipLevels);
127  }
128  }
129 }
TextureDimension
Defines the dimension of a texture.
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32
TextureDimension Dimension
The dimension of a texture.