   [DX10] Use render target output as shader ressource.
  How do you use the output from a render target as a shader ressource?Say I render a depth map (for shadow mapping) in a render target.How do I use this depth map as a shader ressource?With depthMap being the Texture my render target rendered to:var xVar = effect.GetVariableByName("depthmap").AsResource();xVar.SetResource(new ShaderResourceView(effect.Device, depthMap));This throws the error:E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)When trying to set the shader ressource.I tried using a ShaderResourceViewDescription next.I created one for my depthMap (resViewDesc), and passed it to my shader:var xVar = effect.GetVariableByName("depthmap").AsResource();xVar.SetResource(new ShaderResourceView(effect.Device, depthMap, resViewDesc));Unfortunately this produces the same error.It seems you are not supposed to do it this way.What is the correct way of doing this?Here's some more code:My current very basic shadow map class:public class ShadowMap{    public Texture2D depthMap;    public ShaderResourceViewDescription resViewDesc;    public RenderTargetView renderTarget;    public ShadowMap(Device device, int Width, int Height)    {   Texture2DDescription desc = new Texture2DDescription()   {  ArraySize = 1,  BindFlags = BindFlags.RenderTarget,  CpuAccessFlags = CpuAccessFlags.None,  Format = Format.R32_Float,  Height = Height,  MipLevels = 1,  OptionFlags = ResourceOptionFlags.None,  SampleDescription = new SampleDescription(1, 0),  Usage = ResourceUsage.Default,  Width = Width   };   depthMap = new Texture2D(device, desc);   renderTarget = new RenderTargetView(device, depthMap);   resViewDesc = new ShaderResourceViewDescription()   {  Dimension = ShaderResourceViewDimension.Texture2D,  Format = Format.R32_Float,  MipLevels = 1,  MostDetailedMip = 0   };    }}The drawing code://Use my shadowmap render targetdevice.OutputMerger.SetTargets(shadowMap.renderTarget);//Draw my scene from the point of view of my lightDrawSceneNode(scene.RootNode, true);//Set the Render target to my screendevice.OutputMerger.SetTargets(depthStencilView, renderView);//Draw the depthmap shadow to a fullscreen quadfullScreenQuad.Draw(shadowMap.depthMap, shadowMap.resViewDesc);
  You need to specify all of the locations that you want to be able to bind this resource when it's created.  Right now you are only flagging RenderTarget binding and so you need to OR in ShaderResource binding too.   ;  Oh, I didn't notice you could set multiple binding flags.UsingBindFlags = BindFlags.RenderTarget | BindFlags.ShaderResourcedoes the trick.Thanks for pointing this out :)   