Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm writing a Direct3D 11 HLSL shader with SharpDX. What I want to do is write the depth to a texture in one pass and read it in the next one. After declaring the texture, do I have to set the depth texture and the shader resource view per frame, or just once when attaching?

this.depthStencilShaderResourceVariable = this.effect.GetVariableByName("DepthTexture").AsShaderResource();
this.depthStencilShaderResourceVariable.SetResource(this.depthTextureShaderResourceView);
share|improve this question
1  
I'm not certain about DirectX, but in OpenGL you aren't allowed to render to a bound texture - so some rebinding is necessary each frame. –  Polar Nov 26 '13 at 12:45
    
Ok, but what do you mean by bound texture? I thought the bindings I'm doing there were precisely to be able to read the texture. –  c4sh Nov 26 '13 at 16:08
1  
You can't read and write a texture simultaneously in the common case. So you have to bind the depth texture to write it, then unbind it for writing before you bind it for reading. There are ways around this for regular textures using newer hardware features, but not for depth textures to my knowledge. –  Sean Middleditch Nov 26 '13 at 17:26
    
Thanks, so I guess the changes I have to do are per frame? –  c4sh Nov 26 '13 at 17:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.