CreateVertexShader produces _com_error

I'm walking through a directx tutorial (http://www.directxtutorial.com/Lesson.aspx?lessonid=11-4-5)

I'm having problems with these two:
1
2
	dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);
	dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);


dev, VS and PS are not null. Buffer size is greater than zero.

Output:

First-chance exception at 0x000007FEFD0BBCCD in Test2.exe: Microsoft C++ exception: _com_error at memory location 0x000000000031F818.


Call stack:
KernelBase.dll!RaiseException() Unknown
msvcrt.dll!_CxxThrowException() Unknown
d3d11.dll!CDevice::CreateVertexShader_Worker(void const *,unsigned __int64,struct ID3D11ClassLinkage *,void * *,struct _GUID const &,bool) Unknown
d3d11.dll!CDevice::CreateVertexShader(void const *,unsigned __int64,struct ID3D11ClassLinkage *,struct ID3D11VertexShader * *) Unknown
> Test2.exe!InitPipeline() Line 279 C++
Test2.exe!InitD3D(HWND__ * hWnd=0x0000000000730806) Line 188 C++
Test2.exe!WinMain(HINSTANCE__ * hInstance=0x000000013f830000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * lpCmdLine=0x0000000000423e90, int nCmdShow=10) Line 88 C++
Test2.exe!__tmainCRTStartup() Line 528 C
Test2.exe!WinMainCRTStartup() Line 377 C
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown

Tried both x86 and x64, but same problem. I'm using visual studio 2012 on Windows 7 64, directx 11. If anyone has any ideas or can point me in the right direction it would be very appreciated.
These methods returns HRESULT codes, always check return values using SUCCEEDED or FAILED macros.

1
2
3
4
5
6
7
8
9
10
11
HRESULT hr;
hr = dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);

if (FAILED (hr)) {
// some error occured
}

	hr = dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);
if (FAILED (hr)) {
// some error occured
}
Last edited on
I do, and they failed, but I found a solution, I changed pixel and vertex profile:
1
2
D3DX11CompileFromFile(L"vertex.hlsl", 0, 0, "VShader", "vs_5_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile(L"pixel.hlsl", 0, 0, "PShader", "ps_5_0", 0, 0, 0, &PS, 0, 0);


to:

1
2
D3DX11CompileFromFile(L"vertex.hlsl", 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile(L"pixel.hlsl", 0, 0, "PShader", "ps_4_0", 0, 0, 0, &PS, 0, 0);


D3D feature level is 10 for some reason. Now it works in windowed mode, but if I toggle fullscreen I get a _com_error.
If D3D feature level is 10 it could be that your video card does not support DirectX 11 or parts of it.
Topic archived. No new replies allowed.