0

I want to use conservative depth in my fluid renderer to use hardware optimizations. I want to change depth value in my pixel shader

here is Pixel output type

struct PShaderOutput
{

   float4 targetRender1 : SV_Target0;
   float depth : SV_DepthLessEqual;

};

and the end of my pixel shader

PShaderOutput pixelOut;
pixelOut.depth      = depthval;
pixelOut.targetRender1  = float4(depthval,depthval,depthval,1.0f);
return pixelOut;

But it's not have any effect to improve perfomance.

Alatriste
  • 527
  • 2
  • 6
  • 21
  • Well then clearly you were not bottlenecked by a lack of support for early Z rejection. If that is not your bottleneck, then fixing it is not going to improve performance. More than likely your real bottleneck here is the pointless duplication of depth - you are writing it to the depth buffer and then again to a color buffer `targetRender1`. That eats at least twice as much bandwidth as necessary per-fragment (possibly much more depending on the depth/color image formats used). – Andon M. Coleman Jun 21 '14 at 20:05
  • if I remove pixelOut.targetRender1 = float4(depthval,depthval,depthval,1.0f); it's i not rendering depth buffer. but perfomance is SAME – Alatriste Jun 21 '14 at 20:14
  • Then there is something wrong with your driver. Depth-only rendering is perfectly valid. – Andon M. Coleman Jun 21 '14 at 20:15
  • I'm writing screen space fluid rendering, I want to change pixel depth values in pixel shader and also get this depth texture , if I remove depth changing code it's works much faster but if I remove pixelOut.targetRender1 = float4(depthval,depthval,depthval,1.0f); it's not rendering anything.. – Alatriste Jun 21 '14 at 20:22
  • I do not know what to tell you then. D3D/HLSL does not require you to write to a color render target. You are probably just confusing nothing written to your color buffer for nothing rendered. I would suggest you look at your depth buffer instead; after all, that is all your shader actually does is write a depth value. Writing the depth to a color buffer in addition to the depth buffer in D3D10+ is just a waste of memory bandwidth, depth textures are a core part of the API. – Andon M. Coleman Jun 21 '14 at 20:33
  • I want to render point sprites as a true spheres and that's why I'm changing depth values in pixel shader. – Alatriste Jun 21 '14 at 20:39
  • So then you don't even need to write the depth to a color render target. Why are you? – Andon M. Coleman Jun 21 '14 at 22:35
  • Baacuse I need this depth buffer to render – Alatriste Jun 22 '14 at 10:12
  • Sorry, I do not know how to make this any clearer. I would suggest you look into depth-only rendering. There is no reason to output your depth to both a color render target and the depth buffer. Until you understand that, I would not worry about the performance of writing arbitrary values to the depth buffer. – Andon M. Coleman Jun 22 '14 at 12:23
  • I'm writing only in depth buffer but perfomance still same – Alatriste Jun 22 '14 at 13:23

0 Answers0