public static InnerResourceView Create(Resource resource, ShaderResourceViewDescription description)
			{
				switch (description.Dimension)
				{
					case ShaderResourceViewDimension.Texture1D:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.Texture1DArray:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.Texture2D:
						return new Texture2DView((Texture2D) resource, description.Texture2D);
					case ShaderResourceViewDimension.Texture2DArray:
                        return new Texture2DArrayView((Texture2D) resource, description.Texture2DArray);
					case ShaderResourceViewDimension.Texture2DMultisampled:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.Texture2DMultisampledArray:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.Texture3D:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.TextureCube:
						throw new NotImplementedException();
					case ShaderResourceViewDimension.TextureCubeArray:
						throw new NotImplementedException();
					default:
						throw new ArgumentOutOfRangeException();
				}
			}
		internal DepthStencilView(Device device, Resource resource, DepthStencilViewDescription? description)
			: base(device, resource)
		{
			switch (resource.ResourceType)
			{
				case ResourceType.Buffer:
					throw new ArgumentException("Invalid resource type for depth stencil view: " + resource.ResourceType);
			}

			_description = description.GetValueOrDefault(DepthStencilViewDescription.CreateDefault(resource));
			_innerView = InnerResourceView.Create(resource, _description);
		}
		internal static RenderTargetViewDescription CreateDefault(Resource resource)
		{
			var result = new RenderTargetViewDescription();
			switch (resource.ResourceType)
			{
				case ResourceType.Texture1D:
			    {
                    var texture = (Texture1D) resource;
                    if (texture.Description.ArraySize > 1)
                    {
                        result.Dimension = RenderTargetViewDimension.Texture1DArray;
                        result.Texture1DArray.ArraySize = texture.Description.ArraySize;
                        result.Texture1DArray.FirstArraySlice = 0;
                        result.Texture1DArray.MipSlice = 0;
                    }
                    else
                    {
                        result.Dimension = RenderTargetViewDimension.Texture1D;
                        result.Texture1D.MipSlice = 0;
                    }
                    break;
			    }
				case ResourceType.Texture2D:
			    {
                    var texture = (Texture2D) resource;
                    if (texture.Description.ArraySize > 1)
                    {
                        result.Dimension = RenderTargetViewDimension.Texture2DArray;
                        result.Texture2DArray.ArraySize = texture.Description.ArraySize;
                        result.Texture2DArray.FirstArraySlice = 0;
                        result.Texture2DArray.MipSlice = 0;
                    }
                    else
                    {
                        result.Dimension = RenderTargetViewDimension.Texture2D;
                        result.Texture2D.MipSlice = 0;
                    }
			        break;
			    }
			    case ResourceType.Texture3D:
			    {
                    var texture = (Texture3D) resource;
			        result.Dimension = RenderTargetViewDimension.Texture3D;
			        result.Texture3D.DepthSliceCount = texture.Description.Depth;
			        result.Texture3D.FirstDepthSlice = 0;
			        result.Texture3D.MipSlice = 0;
			        break;
			    }
			    default:
					throw new ArgumentOutOfRangeException();
			}
			return result;
		}
		internal static ShaderResourceViewDescription CreateDefault(Resource resource)
		{
			var result = new ShaderResourceViewDescription();
			switch (resource.ResourceType)
			{
				case ResourceType.Texture1D:
			    {
                    var texture = (Texture1D) resource;
                    if (texture.Description.ArraySize > 1)
                    {
                        result.Dimension = ShaderResourceViewDimension.Texture1DArray;
                        result.Texture1DArray.ArraySize = texture.Description.ArraySize;
                        result.Texture1DArray.FirstArraySlice = 0;
                        result.Texture1DArray.MostDetailedMip = 0;
                        result.Texture1DArray.MipLevels = texture.Description.MipLevels;
                    }
                    else
                    {
                        result.Dimension = ShaderResourceViewDimension.Texture1D;
                        result.Texture1D.MostDetailedMip = 0;
                        result.Texture1D.MipLevels = texture.Description.MipLevels;
                    }
                    break;
			    }
				case ResourceType.Texture2D:
			    {
			        var texture = (Texture2D) resource;
			        if (texture.Description.ArraySize > 1)
			        {
			            result.Dimension = ShaderResourceViewDimension.Texture2DArray;
			            result.Texture2DArray.ArraySize = texture.Description.ArraySize;
			            result.Texture2DArray.FirstArraySlice = 0;
			            result.Texture2DArray.MostDetailedMip = 0;
			            result.Texture2DArray.MipLevels = texture.Description.MipLevels;
			        }
			        else
			        {
			            result.Dimension = ShaderResourceViewDimension.Texture2D;
			            result.Texture2D.MostDetailedMip = 0;
			            result.Texture2D.MipLevels = texture.Description.MipLevels;
			        }
			        break;
			    }
			    case ResourceType.Texture3D:
					result.Dimension = ShaderResourceViewDimension.Texture3D;
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
			return result;
		}
		internal static DepthStencilViewDescription CreateDefault(Resource resource)
		{
			var result = new DepthStencilViewDescription();
			switch (resource.ResourceType)
			{
				case ResourceType.Texture1D:
					result.Dimension = DepthStencilViewDimension.Texture1D;
					break;
				case ResourceType.Texture2D:
					result.Dimension = DepthStencilViewDimension.Texture2D;
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
			return result;
		}
		internal ShaderResourceView(Device device, Resource resource, ShaderResourceViewDescription? description)
			: base(device, resource)
		{
			_description = description.GetValueOrDefault(ShaderResourceViewDescription.CreateDefault(resource));
			_innerView = InnerResourceView.Create(resource, _description);
		}
		public UnorderedAccessView(Device device, Resource resource)
			: base(device, resource)
		{
		}
Example #8
0
		internal ResourceView(Device device, Resource resource)
			: base(device)
		{
			_resource = resource;
		}