MCPcopy Create free account
hub / github.com/aliasIsolation/aliasIsolation / srvFromTex

Function srvFromTex

src/dll/resourceUtil.cpp:73–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73CComPtr<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
103CComPtr<ID3D11UnorderedAccessView> uavFromTex(const CComPtr<ID3D11Texture2D>& tex) {
104 decltype(textureToUavMap)::iterator it = textureToUavMap.find(tex);

Callers 4

renderTaaFunction · 0.85
modifySharpenPassFunction · 0.85
caOnDrawFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected