This topic is 2140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I'm converting a project to not use D3DX and I'm currently working on the shaders part.  They currently work fine with D3DXCompileShader, so I'm just more or less checking that I have my steps right.

First, just a very simple shader pair:

struct VS_INPUT {
float4 Position : POSITION;
float3 Normal : NORMAL;
};

struct VS_OUTPUT {
float4 Position : POSITION;
};

VS_OUTPUT vs_main(in VS_INPUT In)
{
VS_OUTPUT output;
output.Position = In.Position;

return output;
}

struct PS_INPUT {
float4 Position : VPOS;
};

struct PS_OUTPUT {
float4 Color : COLOR0;
};

PS_OUTPUT ps_main(in PS_INPUT In)
{
PS_OUTPUT output;
output.Color = float4(0.5f, 0.2f, 0.4f, 1.0f);

return output;
}


Second, I compile the shaders using fxc:

fxc /Fo test.vso /T vs_2_0 /E vs_main /Zi test.vs
fxc /Fo test.pso /T ps_2_0 /E ps_main /Zi test.ps



These compile fine.

// Set the vertex declaration exactly as I did before

uint8_t* pBuffer;

if (pBuffer != nullptr) {
// Check for failure
}

// Do the same for pixel shader



All of my pointers are valid and I'm not getting any errors or warnings.  Did I miss something?

##### Share on other sites

So you actually don't have any problems with that code? Wouldn't it be faster to test it than to post it here? But you say you get no errors and warnings, so you already did try it. Is the rendering wrong? What actually is wrong, why does this thread exist? :)

##### Share on other sites

It's not rendering anything (e.g. black).  I thought I might have missed something or had something conceptually wrong.  I've also tried using the /Fh switch -- generating the header file for the shader -- and got the same results.

##### Share on other sites

All of my pointers are valid and I'm not getting any errors or warnings

Does that include the the D3D debug runtime ?

Also, probably a good time to fire up PIX to see what you get. And post your whole render code (declaration, states, draw call), maybe we see something.

As an aside: VPOS is a shader model 3 semantic. It's not a problem now, since your pixel shader doesn't use it (the compiler will strip it), but the compilation fails if it does.

##### Share on other sites

It's not rendering anything (e.g. black).

Just a small tip (maybe you're doing it, so sorry if it sounds too obvious for you) - don't clear your backbuffer to black or white color, pick some other color. Black is very good in hiding your rendering if you have some problems with lighting. It seems that nothing is rendered, while you just cannot see it. On let's say pink background you'll at least see black silhouettes of your objects, so you know that at least some parts of your code are working.

##### Share on other sites

Totally not what I expected ... The problem had to do with my transforms not being sent to the shaders correctly (untransposed).  The answer is here.

• 9
• 17
• 10
• 11
• 18