# X4717 Effects deprecated for D3DCompiler_47

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

## 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;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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);


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 on other sites
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 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 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 on other sites
inline HRESULT CompileShaderFromFile(LPCWSTR file_name, LPCSTR entry_point, LPCSTR shader_target, ID3DBlob **output_blob) {

#ifdef _DEBUG
#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:

Edited by matt77hias

##### 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 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 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 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 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 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 am just starting to learn and getting used to D3D11. But I assume you are referring to per-stage compilation as in compiling ?s_5_[0/1], where ? is one of vertex, pixel, geometry, hull, domain, or compute?

##### Share on other sites

Maybe there's some misunderstanding here.

As I understand from your code, you are not using the effects framework at all.

The only thing that uses the effects framework, is VS, compiling your HLSL file redundantly, before your code is executed. When your code is executed, the same HLSL file is compiled without using the Effects framework.

If you change the properties of the HLSL file to VS or PS, the error would be gone and you'd have the advantage of having the HLSL files in the IDE.

When you have both the PS and VS in one file, you can use a 'stub' file, which is basically adding a 2nd HLSL file with an include to the original one. Then you configure the 1st file to compile the VS and the 2nd file to compile the PS.

##### Share on other sites

Maybe there's some misunderstanding here.

As I understand from your code, you are not using the effects framework at all.

The only thing that uses the effects framework, is VS, compiling your HLSL file redundantly, before your code is executed. When your code is executed, the same HLSL file is compiled without using the Effects framework.

If you change the properties of the HLSL file to VS or PS, the error would be gone and you'd have the advantage of having the HLSL files in the IDE.

When you have both the PS and VS in one file, you can use a 'stub' file, which is basically adding a 2nd HLSL file with an include to the original one. Then you configure the 1st file to compile the VS and the 2nd file to compile the PS.

I currently have a separate header .hlsl file that includes my effect.fx for each different entry point and I have set the entry point and shader type in the file configuration. But I can live with Visual Studio compiling the files in advance and do not compile a second time at runtime. I now load the compiled blobs from the .cso files.

But like you said I removed the body file effect.fx from the build since I actually do not need the effect.cso (i.e. the entry point is undefined).

Edited by matt77hias

##### 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 am just starting to learn and getting used to D3D11. But I assume you are referring to per-stage compilation as in compiling ?s_5_[0/1], where ? is one of vertex, pixel, geometry, hull, domain, or compute?

Yeah. And is not much of a leap which i found out.

##### Share on other sites

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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628653
• Total Posts
2984050

• 10
• 9
• 9
• 10
• 21