从内存创建效果时出错(c++,directx 11)

Error creating effect from memory (c++, directx 11)

我正在尝试从我编译的着色器创建一个效果变量,以便我可以引用变量并设置它们的值,但是出了点问题。我从 Frank Luna 的 Introduction to 3D Game Programming 中提取了一个片段,并在必要时进行了调整

HRESULT hr;
DWORD shaderFlags = 0;
ID3D10Blob * compiledShader = 0;
ID3D10Blob * compilationMessages = 0;
hr = D3DX11CompileFromFile(L"cubemap.fx", 0, 0, 0, "fx_4_0", shaderFlags, 0, 0, &compiledShader, &compilationMessages, 0);
if (FAILED(hr))
{
    MessageBox(nullptr,
        L"Failed to compile cubemap shader D3DX11", L"Error", MB_OK);
    return hr;
}
ID3DX11Effect * shader;
hr = D3DX11CreateEffectFromMemory(
    compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, device, &shader);
if (FAILED(hr))
{
    MessageBox(nullptr,
        L"Could not create effect from memory", L"Error", MB_OK);
    return hr;
}

并抛出错误

Could not create effect from memory

HR = E_FAIL

Attempted to create a device with the debug layer enabled and the layer is not installed.

我试过调试一下并重建效果库,但仍然没有。有人可以发现问题或告诉我如何找到原因吗?

编辑:我认为问题出在调试层。我尝试使用(D3D10 和 D3D11)

启用调试层
#if defined(_DEBUG) || defined (DEBUG)
    shaderFlags |= D3D10_CREATE_DEVICE_DEBUG;
    shaderFlags |= D3D10_SHADER_DEBUG;
    shaderFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
#endif

我的设备标志也启用调试模式

    UINT createDeviceFlags = 0;

#if defined (_DEBUG) || defined(DEBUG)
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

我正在使用 Windows 8.1,Visual Studio 默认使用 Windows 8.1 SDK,但我也引用了旧的 2010 年 6 月 SDK,这就是问题所在正在发生。我上面尝试使用的方法来自旧的SDK。

我相信调试层所需的所有 dll 都已安装。

我也有旧 sdk 的 dll(我用来引用旧方法的那个)

已解决

我下载了最新版本的 Effects11 并使用兼容的 fx 版本编译了着色器 (fx_5_0)

拉取最新版本的 Effects 11 似乎可以解决问题。