| 71 | } |
| 72 | |
| 73 | CComPtr<ID3D11ShaderResourceView> srvFromTex(const CComPtr<ID3D11Texture2D>& tex) { |
| 74 | decltype(textureToSrvMap)::iterator it = textureToSrvMap.find(tex); |
| 75 | |
| 76 | if (it != textureToSrvMap.end()) { |
| 77 | return it->second; |
| 78 | } else { |
| 79 | D3D11_SHADER_RESOURCE_VIEW_DESC desc; |
| 80 | ZeroMemory(&desc, sizeof(desc)); |
| 81 | |
| 82 | D3D11_TEXTURE2D_DESC texDesc; |
| 83 | tex->GetDesc(&texDesc); |
| 84 | |
| 85 | desc.Format = texDesc.Format; |
| 86 | desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; |
| 87 | // Turns out "-1" actually gets converted to "(UINT_MAX + 1) - 1" and is a portable way of getting all bits set to 1, |
| 88 | // static_cast makes the compiler ignore this as a potential issue. |
| 89 | desc.Texture2D.MipLevels = static_cast<UINT>(-1); |
| 90 | |
| 91 | CComPtr<ID3D11ShaderResourceView> srv = nullptr; |
| 92 | HRESULT createSRVResult = g_device->CreateShaderResourceView(tex, &desc, &srv); |
| 93 | |
| 94 | if (!SUCCEEDED(createSRVResult) && !srv) { |
| 95 | DebugBreak(); |
| 96 | } |
| 97 | |
| 98 | textureToSrvMap[tex] = srv.p; |
| 99 | return srv; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | CComPtr<ID3D11UnorderedAccessView> uavFromTex(const CComPtr<ID3D11Texture2D>& tex) { |
| 104 | decltype(textureToUavMap)::iterator it = textureToUavMap.find(tex); |
no outgoing calls
no test coverage detected