【发布时间】:2018-05-11 09:22:48
【问题描述】:
其实这个问题是从我之前发过的thisquestion 得到的。它可以在带有 directx 12 的 windows 10 下工作。但是我无法在带有 directx 11 的 windows 7 下创建 Texture2D。我创建了第二个 texture2d 来生成这样的 mipmap:
D3D11_TEXTURE2D_DESC textureDesc;
textureDesc.Width = nWidth;//Video width
textureDesc.Height = nHeight;//Video height
textureDesc.MipLevels = 0;//generate a full set of subtextures.
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
m_pD3dDevice->CreateTexture2D(&textureDesc, NULL, &m_pTexture);
我刚刚在 Windows7 下得到“无效参数”。根据Extended support for shared Texture2D resources,似乎只有DirectX11.1保证这种用法。 Windows 7下不支持D3D11_BIND_SHADER_RESOURCE和D3D11_BIND_RENDER_TARGET的绑定标志(DirectX的版本应该是directx11)。没有这个,ID3D11DeviceContext::GenerateMips method无效。我的应用程序必须支持 Windows 7,那么有什么替代解决方案吗?
【问题讨论】:
-
调试 Direct3D 问题的第一步是启用调试设备。你有没有从中得到任何诊断输出?此外,如果您安装了KB2670838,Windows 7 也支持 DirectX 11.1。 Autogen mipmap 在 DirectX 11.0 或更高版本上工作得很好,所以问题可能是其他问题......
标签: directx-11 texture2d mipmaps