   Non Power of Two Texture Rendertarget
  I'm having som troubles using non power of two textures. But when I try to create a texture using new Texture i get a D3DERR_INVALIDCALL. The caps says that NPOT-textures are supported. This is how I create the texture://Checks if NPOT-textures are supportedCaps caps = device.DeviceCaps;bool nonPower2Supported = caps.TextureCaps.SupportsNonPower2Conditional;   if(nonPower2Supported){    renderTargetTexture = new Texture(device, 640, 480, 0, Usage.RenderTarget,   Format.X8R8G8B8, Pool.Default);    renderTargetSurface = renderTargetTexture.GetSurfaceLevel(0);}The texture is supposed to be used as a rendertarget.All help appreciated... =)[Edited by - Bucky32 on December 3, 2005 3:35:17 PM]
  Support for non-pow2 TEXTURES isn't the same as support for non-pow2 offscreen render-targets. In general, using pow2 RT's is the only sane thing to do.Allan   ;  Okey, so if I have a 640x480 window I need to render to a 1024x1024 rendertarget texture? And then somehow access parts of that texture that contains my pixelvalues?The thing is that I have done an application in OpenGL using framebuffer objects and rectangular textures with several shader passes that I now want to convert to C# and DirectX. ;  Try specifying 1 mip level instead of the full chain, as it's only "conditional" non-pow2 support, which means no mips are allowed, among other limitations.   ;  Aha, it worked a bit better... It doesnt crash at the texture creation. But it seems like i only get one correct frame each time I reset the device. All frames thereafter are black. This is how i create the rendertarget now:renderTargetTexture = new Texture(device, device.Viewport.Width, device.Viewport.Height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);renderTargetSurface = renderTargetTexture.GetSurfaceLevel(0);And here i render to the texture:renderTargetSurface = renderTargetTexture.GetSurfaceLevel(0);Surface oldRenderTarget = device.GetRenderTarget(0); device.SetRenderTarget(0, renderTargetSurface);device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);  device.BeginScene();//Begin HLSL shadereffect.Technique = "simple";effect.Begin(0);effect.BeginPass(0);    //Draw cubedevice.VertexFormat = CustomVertex.PositionOnly.Format;device.SetStreamSource(0, vertexBuffer, 0);device.Indices = indexBuffer;device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);//End HLSL shadereffect.EndPass();effect.End();device.EndScene();//Reset the render target. device.SetRenderTarget(0, oldRenderTarget);oldRenderTarget.Dispose();Then i render the resulting rendertarget a full screen quad:device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.WhiteSmoke, 1.0f, 0);//Reset world, view and projection matrixdevice.Transform.World = device.Transform.View = device.Transform.Projection = Matrix.Identity;device.BeginScene();device.SetTexture(0, renderTargetTexture);device.VertexFormat = CustomVertex.TransformedTextured.Format;device.SetStreamSource(0, quadVertexBuffer, 0);device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);device.EndScene(); [Edited by - Bucky32 on December 3, 2005 3:05:21 PM];  Try SetTexture(0, 0) after the quad render.  When you make the rendertarget active on the next frame, it's still bound to texture stage 0, and D3D might be blocking the SetRenderTarget since a texture cannot be both a texture and a rendertarget at the same time.  This would cause it to work for 1 frame.Try the debug runtimes (ControlPanel/DirectX then Direct3D then the debug runtime radio button) to see if D3D is trying to tell you what it doesn't like.Another thing you may need to do is SetPixelShader(0), and SetVertexShader(0) to undo what your effect file has set up.  I'm not sure if you need this, as you say it works for 1 frame, and if this was a problem it would cause problems even on frame 0.   ;  Use source tags.   ;Quote:Original post by NamethatnobodyelsetookTry SetTexture(0, 0) after the quad render.  When you make the rendertarget active on the next frame, it's still bound to texture stage 0, and D3D might be blocking the SetRenderTarget since a texture cannot be both a texture and a rendertarget at the same time.  This would cause it to work for 1 frame.Thanks Namethatnobodyelsetook! That was exactly the problem... now its working perfectly. Don't know thou if this is the fastest way to do this. Will have to check out those debug runtimes also...   