Original Post
I''m trying to initialize all the values of a floating point render target using a pixel shader. The reason I don''t just call IDirect3DDevice9::Clear is because I want to initialize the value of each element of the render target to some kind of MAX_FLOAT value and not a regular 32bit ARGB color.
I thought that the best way to do this was to render a screen-aligned quad and just have a pixel shader write out the floating point value that I want the render target initialized to. I loaded this value as a constant to inside the shader. The problem is that it seems that the pixel shader is never run. The vertex shader runs just fine, but the pixel shader never runs.
Normally, I would think that this is because the screen-aligned quad isn''t being transformed properly so no pixels are being rasterized. But I''ve used this same transformation to draw other screen aligned quads and it works just fine. I''ve even tried to load another pixel shader that also computes values on a screen-aligned quad (but does much more work) and it runs fine. It just seems that this very simple pixel shader doesn''t want to run.
Here is the shader (I''ve tried in both HSLS and regular assembly):
// HSLS version
// Clearing to gray as default. Real value will be loaded by app.
float4 g_vClearColor = float4( 0.5f, 0.5f, 0.5f, 0.5f );
float4 main() : COLOR0
{
return g_vClearColor;
}
// Assembly version
// c0 is loaded with a value from the app by calling SetPixelShaderConstantF
ps_2_0
mov oC0, c0
Could it be that the shader is just too simple for D3D to run it somehow? I''ve tried replacing this shader with a much more complicated shader and D3D will execute the complex shader (albiet, with incorrect results because I had not loaded all the proper data but at least it runs), but not this simple one.
In the main app, I call SetVertexDeclaration, SetVertexShader, and SetPixelShader with the appropriate values. I also check the HRESULT variables and the debug spew and everything seems to be fine. I''ve also tried running on the REF device to make sure everything is ok and i get the same results. I use the REF device so that I can step into the pixel shaders. I''ve done this with the more complicated shader but I''m not able to step into this simple one.
Does anyone have an idea as to why this simple shader will not run?
neneboricua