1

this being my first question, please provide me with a little mercy. I am currently working with the following bits of shader code in the Pixel Shader:

struct PixelShaderInput
{
        float4 pos : SV_POSITION;
};

float4 main(PixelShaderInput input) : SV_TARGET
{
    return float4(0.1f, 0.1f, 0.1f, 1.0f);
}

In the Vertex Shader:

cbuffer ModelViewProjectionConstantBuffer : register(b0)
{
    matrix model;
    matrix view;
    matrix projection;
};

struct VertexShaderInput
{
    float3 pos : POSITION;
};

struct PixelShaderInput
{
    float4 pos : SV_POSITION;
};

PixelShaderInput main(VertexShaderInput input)
{
    PixelShaderInput output;
    float4 pos = float4(input.pos, 1.0f);

    pos = mul(pos, model);
    pos = mul(pos, view);
    pos = mul(pos, projection);
    output.pos = pos;

    return output;
}

Now comes the odd part. On my Virtual machine without DirectX11 support, this version of the code works if i copy the above shader code to the two files created by the project skeleton:

void SUS3DApp1Main::SUSCreateDeviceResources()
{
    //auto loadVSTask = DX::ReadDataAsync(L"SUSPixelShader.cso");
    //auto loadPSTask = DX::ReadDataAsync(L"SUSVertexShader.cso");

    // Load shaders asynchronously.
    //this version works
    auto loadVSTask = DX::ReadDataAsync(L"SampleVertexShader.cso");
    auto loadPSTask = DX::ReadDataAsync(L"SamplePixelShader.cso");

While this one does not:

void SUS3DApp1Main::SUSCreateDeviceResources()
{
    auto loadVSTask = DX::ReadDataAsync(L"SUSPixelShader.cso");
    auto loadPSTask = DX::ReadDataAsync(L"SUSVertexShader.cso");

I checked and rechecked the compile settings in Visual Studio, but they look the same to me. Does anyone of you know what is different in the "special" files which were created during the creation of the project skeleton?

Tam HANNA
  • 51
  • 6
  • Since the filenames are different, then the problem is likely that you are not building the shader names you expected. Look at the project settings for your HLSL code. – Chuck Walbourn Jan 10 '17 at 18:25
  • Hello chuck, thank you so much for responding. I am using the same shader code - both of the HLSL files contain the same code! – Tam HANNA Jan 10 '17 at 22:08
  • Sure, but do they both actually get build by Visual Studio? If so, then both CSO files should be in the layout folder – Chuck Walbourn Jan 10 '17 at 22:15
  • Hello,strangely, yes. Both of them get copied to /Debug! Furthermore, I tested that it is not a file load error by renaming SUSPixelShader to XSUSPixelShader. This changed the exception thrown to 0x80070002 – Tam HANNA Jan 11 '17 at 17:09

0 Answers0