Jump to content
  • Advertisement
Sign in to follow this  
matt77hias

X4717 Effects deprecated for D3DCompiler_47

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I started to learn while coding some basic Direct3D 11 functionality.

 

My current code compiles and runs fine, but I still obtain:

X4717 Effects deprecated for D3DCompiler_47

I use only one .fx file named effect.fx:

//--------------------------------------------------------------------------------------
// ModelTransform Variables
//--------------------------------------------------------------------------------------
cbuffer ModelTransform : register(b0) {
    matrix model_to_world;
    matrix world_to_view;
    matrix view_to_projection;
}

//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
struct VS_OUTPUT {
    float4 p : SV_POSITION;
    float4 diffuse : COLOR0;
};

VS_OUTPUT VS(float4 p : POSITION, float4 diffuse : COLOR) {
    VS_OUTPUT output = (VS_OUTPUT)0;
    output.p = mul(p, model_to_world);
    output.p = mul(output.p, world_to_view);
    output.p = mul(output.p, view_to_projection);
    output.diffuse = diffuse;
    return output;
}

//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
float4 PS(VS_OUTPUT input) : SV_Target {
    return input.diffuse;
}

which I compile at runtime

const HRESULT result_vertex_shader_blob = CompileShaderFromFile(L"Project 4/shaders/effect.fx", "VS", "vs_4_0", &vertex_shader_blob);
const HRESULT result_pixel_shader_blob = CompileShaderFromFile(L"Project 4/shaders/effect.fx", "PS", "ps_4_0", &pixel_shader_blob);

These methods eventually call

D3DCompileFromFile

Should I break the code in one .vs and .ps file?


There is some discussion about Effects 11. But it doesn't really help.

Share this post


Link to post
Share on other sites
Advertisement
The warning shouldn't stop you.
For future development you could consider managing the "effects" yourself.

It's no problem/ actually common practice to have the PS and VS in one HLSL file.

Share this post


Link to post
Share on other sites

For future development you could consider managing the "effects" yourself.

 

Do you mean compiling them in advance (i.e. not at runtime)?

Share this post


Link to post
Share on other sites
I don't see any effects extensions being used in your code and you don't seem to be compiling with an effects target (fx_*). Can we see the call to D3DCompileFromFile?

Share this post


Link to post
Share on other sites
inline HRESULT CompileShaderFromFile(LPCWSTR file_name, LPCSTR entry_point, LPCSTR shader_target, ID3DBlob **output_blob) {

    DWORD shader_flags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
    shader_flags |= D3DCOMPILE_DEBUG;
    shader_flags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif

    ID3DBlob *error_blob = NULL;
    const HRESULT result_compile = D3DCompileFromFile(file_name, NULL, NULL, entry_point, shader_target, shader_flags, 0, output_blob, &error_blob);
    if (FAILED(result_compile)) {
        if (error_blob) {
            OutputDebugStringA(reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
            error_blob->Release();
        }
        return result_compile;
    }
    if (error_blob) {
        error_blob->Release();
    }

    return S_OK;
}

Project Properties > General Configuration > HLSL Compiler:

Shader type: Effect (/fx)

Shader Model: Shader Model 5.0 (/5.0)

Edited by matt77hias

Share this post


Link to post
Share on other sites
In this case visual studio "checks" your HLSL files in the project using the compiler as it where an FX / effect. But in your code your not using the effects.

If you go to the properties of the HLSL file and exclude it from build, the warning probably disappears. I'd ignore it because the advantage now is that you can directly go to any error in the HLSL file if there is one.

Basically the shaders are now compiled twice.

Share this post


Link to post
Share on other sites

In this case visual studio "checks" your HLSL files in the project using the compiler as it where an FX / effect. But in your code your not using the effects.

If you go to the properties of the HLSL file and exclude it from build, the warning probably disappears. I'd ignore it because the advantage now is that you can directly go to any error in the HLSL file if there is one.

Basically the shaders are now compiled twice.

 

So excluding from the build removes the specific warning but also all other warnings and errors that could sneak into the code in the future. ok so I leave it be.

 

Since you say I am compiling the shaders twice, can I obtain the binary blob somehow without doing a second compile in my code?

Share this post


Link to post
Share on other sites
Question 1;
You wont miss any errors, assuming you have the debug flag enabled in your compilation code. Possible errors and warnings from the shaders will appear in your output window (without the warning you got rid off :))

Question 2:
This is definately possible, I believe the VS compiler (if you enable it again), automatically produces a compiled shader file). I think it has a .cod extension

Share this post


Link to post
Share on other sites

This is definately possible, I believe the VS compiler (if you enable it again), automatically produces a compiled shader file). I think it has a .cod extension

 

I have some .cso files.

 

This should do the job apparently:

ID3DBlob *buffer;
D3DReadFileToBlob(L"test.cso", &buffer);
Edited by matt77hias

Share this post


Link to post
Share on other sites
My advice and it's only my opinion is move away from Effects as soon as you feel conformable. Yes. It is more complex initially but after the initial hump its much more modular and flexible.

I just found after a while it stunted my progress.

Anyway gl.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!