/// <summary>Initializes the specified view.</summary> /// <param name="view">The view.</param> /// <exception cref="System.ArgumentException">Expecting argument to be a ShaderResourceView or RenderTargetView;view</exception> protected override void Initialize(DeviceChild view) { // The initialize method will override the view.Tag, so we are setting it back base.Initialize(view); IsRenderView = view is RenderTargetView; var shaderResourceView = view as ShaderResourceView; int mipLevel = 0; if (shaderResourceView != null) { var description = shaderResourceView.Description; mipLevel = description.Texture1D.MostDetailedMip; } else { var renderTargetView = view as RenderTargetView; if (renderTargetView == null) { throw new ArgumentException("Expecting argument to be a ShaderResourceView or RenderTargetView", "view"); } mipLevel = renderTargetView.Description.Texture1D.MipSlice; } Size = new Size2(Math.Max(1, Texture.Width >> mipLevel), Math.Max(1, Texture.Height >> mipLevel)); TexelSize = new Size2F { Width = 1.0f / Size.Width, Height = 1.0f / Size.Height }; }
/// <summary> /// Initializes the specified device local. /// </summary> /// <param name="resource">The resource.</param> protected virtual void Initialize(DeviceChild resource) { Resource = ToDispose(resource); if (resource != null) { resource.Tag = this; } }
internal TextureView(Texture texture, DeviceChild view) : base(texture.GraphicsDevice) { if (view == null) throw new ArgumentNullException("view"); Texture = texture; Description = texture.Description; Initialize(view); }
protected override void Initialize(DeviceChild view) { // The initialize method will override the view.Tag, so we are setting it back base.Initialize(view); var shaderResourceView = view as ShaderResourceView; int mipLevel = 0; bool isMultisampled = Texture.Description.SampleDescription.Count > 1; if (shaderResourceView != null) { mipLevel = isMultisampled ? 0 : shaderResourceView.Description.Texture1D.MostDetailedMip; } else { var renderTargetView = view as RenderTargetView; if (renderTargetView != null) { IsRenderView = true; mipLevel = isMultisampled ? 0 : renderTargetView.Description.Texture1D.MipSlice; } else { var depthStencilView = view as DepthStencilView; if (depthStencilView != null) { IsDepthStencilView = true; mipLevel = isMultisampled ? 0 : depthStencilView.Description.Texture1D.MipSlice; } else { throw new ArgumentException("Expecting argument to be a ShaderResourceView, RenderTargetView or DepthStencilView", "view"); } } } Size = new Size2(Math.Max(1, Texture.Width >> mipLevel), Math.Max(1, Texture.Height >> mipLevel)); TexelSize = new Size2F { Width = 1.0f / Size.Width, Height = 1.0f / Size.Height }; }
protected override void Dispose(bool disposeManagedResources) { base.Dispose(disposeManagedResources); if (disposeManagedResources) Resource = null; }
internal abstract void SetShader(DeviceChild shader, SharpDX.Direct3D11.ClassInstance[] classInstancesOut, int numClassInstances);
/// <summary> /// Initializes the specified device local. /// </summary> /// <param name="resource">The resource.</param> protected virtual void Initialize(DeviceChild resource) { Resource = ToDispose(resource); }