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;
		}
			public static InnerResourceView Create(Resource resource, RenderTargetViewDescription description)
			{
				switch (description.Dimension)
				{
					case RenderTargetViewDimension.Texture1D:
						return new Texture1DView((Texture1D) resource, description.Texture1D);
					case RenderTargetViewDimension.Texture1DArray:
						return new Texture1DArrayView((Texture1D) resource, description.Texture1DArray);
					case RenderTargetViewDimension.Texture2D:
						return new Texture2DView((Texture2D) resource, description.Texture2D);
					case RenderTargetViewDimension.Texture2DArray:
						return new Texture2DArrayView((Texture2D) resource, description.Texture2DArray);
					case RenderTargetViewDimension.Texture2DMultisampled:
						throw new NotImplementedException();
					case RenderTargetViewDimension.Texture2DMultisampledArray:
						throw new NotImplementedException();
					case RenderTargetViewDimension.Texture3D:
						return new Texture3DView((Texture3D) resource, description.Texture3D);
					default:
						throw new ArgumentOutOfRangeException();
				}
			}
			public Texture2DArrayView(Texture2D resource, RenderTargetViewDescription.Texture2DArrayResource description)
			{
				_subresources = new Texture2D.Texture2DSubresource[description.ArraySize];
				for (int i = description.FirstArraySlice; i < description.FirstArraySlice + description.ArraySize; i++)
					_subresources[i] = resource.GetSubresource(i, description.MipSlice);
			}
Ejemplo n.º 4
0
		internal RenderTargetView(Device device, Resource resource, RenderTargetViewDescription? description)
			: base(device, resource)
		{
			_description = description.GetValueOrDefault(RenderTargetViewDescription.CreateDefault(resource));
			_innerView = InnerResourceView.Create(resource, _description);
		}
Ejemplo n.º 5
0
 internal RenderTargetView(Device device, Resource resource, RenderTargetViewDescription?description)
     : base(device, resource)
 {
     _description = description.GetValueOrDefault(RenderTargetViewDescription.CreateDefault(resource));
     _innerView   = InnerResourceView.Create(resource, _description);
 }
			public Texture2DView(Texture2D resource, RenderTargetViewDescription.Texture2DResource description)
			{
				_subresource = resource.GetSubresource(0, description.MipSlice);
			}
			public Texture3DView(Texture3D resource, RenderTargetViewDescription.Texture3DResource description)
			{
				_subresource = resource.GetSubresource(description.MipSlice);
				_firstDepthSlice = description.FirstDepthSlice;
				_depthSliceCount = description.DepthSliceCount;
			}