/// <summary> /// Function to retrieve a render target view. /// </summary> /// <param name="format">Format of the view.</param> /// <param name="mipSlice">Mip level to use in the view.</param> /// <param name="arrayDepthIndex">First array index to use in the view.</param> /// <param name="arrayDepthCount">Number of array indices to use in the view.</param> /// <returns>The cached render target view.</returns> public GorgonRenderTargetView GetRenderTargetView(BufferFormat format, int mipSlice, int arrayDepthIndex, int arrayDepthCount) { var key = new ViewKey(format, mipSlice, arrayDepthIndex, arrayDepthCount, 0); lock (_syncLock) { GorgonRenderTargetView result; if (_targetViews.TryGetValue(key, out result)) { return(result); } switch (_resource.ResourceType) { case ResourceType.Buffer: result = new GorgonRenderTargetBufferView(_resource, format, mipSlice, arrayDepthIndex); break; case ResourceType.Texture1D: case ResourceType.Texture2D: case ResourceType.Texture3D: result = new GorgonRenderTargetTextureView(_resource, format, mipSlice, arrayDepthIndex, arrayDepthCount); break; } // This should never happen. if (result == null) { throw new GorgonException(GorgonResult.CannotCreate, string.Format(Resources.GORGFX_IMAGE_TYPE_INVALID, _resource.ResourceType)); } result.Initialize(); _targetViews.Add(key, result); return(result); } }
/// <summary> /// Function to retrieve the render target buffer associated with this view. /// </summary> /// <param name="view">The view to evaluate.</param> /// <returns>The render target buffer associated with this view.</returns> public static GorgonRenderTargetBuffer ToRenderTargetBuffer(GorgonRenderTargetBufferView view) { return(view == null ? null : (GorgonRenderTargetBuffer)view.Resource); }