D3D10CompileShader equivelent in D3D11

Started by
5 comments, last by MJP 13 years, 6 months ago
Hey guys,

I'm working on my wrappers for the various flavors of D3D. I have 10 and 10.1 working fine, and am about halfway through D3D11. But I've hit a snag with the shaders.

In D3D10, there is the function D3D10CompileShader. This function appears to have been removed from DX11 (i.e. there is no D3D11CompileShader function). How, then, would I compile shaders?

Oh, and don't say "D3DXCompileFrom*". Not interested. There is no D3DX in my code, it's not a dependency I need or want. I'm looking for core functions/interfaces only.

Thanks gang.
Creation is an act of sheer will
Advertisement
D3DCompile.
That's an HLSL function. Sorry, I guess I should have been more specific. I want to compile the shader in the C++ code, not in HLSL. e.g. this is my D3D 10.1 wrapper function. I want somthing similar for my D3D 11 wrapper.

HRESULT DX10_1Wrapper::CompileShader(String *Source, String *MainFunction, String *ShaderProfile, unsigned int Flags, ID3D10Blob **Shader, ID3D10Blob **Errors)	{	return D3D10CompileShader(Source->c_strA(), Source->Size(), nullptr, nullptr, nullptr, MainFunction->c_strA(), ShaderProfile->c_strA(), Flags, Shader, Errors);	}
Creation is an act of sheer will
No, read again; that is the function you want.
Really? Hmmmmmm.

Okay, well, perhaps you could me a bit more of a clue. Because this:

HRESULT DX11Wrapper::CompileShader(String *Source, String *MainFunction, String *ShaderProfile, unsigned int Flags, ID3DBlob **Shader, ID3DBlob **Errors)	{	return D3DCompile(Source->c_strA(), Source->Size(), nullptr, nullptr, nullptr, MainFunction->c_strA(), ShaderProfile->c_strA(), Flags, Shader, Errors);	}

gives me

1>e:\engine\graphicsapiwrapper.cpp(1024): error C3861: 'D3DCompile': identifier not found

I've hunted through a bunch of the interface docs to see if they associated it with something (like the device, device context, all the shader interfaces, and so on), but I don't see it. And the search is just giving the same link to the HLSL page that Erik linked to.

Sorry for my being dense. I'm just not getting how to call that HLSL function in a C++ environment.
Creation is an act of sheer will
Ah, got it.

I needed to add D3Dcompiler.h to my includes. That gives me access to that function. Thanks guys.
Creation is an act of sheer will
There's no HLSL function. It's declared in D3DCompiler.h, and you have to link to d3dcompiler.lib. It's implemented in a DLL (D3dcompiler_xx.dll) that gets installed with the redistributable, so if you're looking to avoid that you're out of luck.

This topic is closed to new replies.

Advertisement