//-------------------------------------------------------------------------------------- CLASS_IMPL_FUNC(D3D10_Factory, get_Texture)( _Out_ ID3D10ShaderResourceView ** _texture, _In_ const wchar_t * _directory, _In_ const D3DX10_IMAGE_INFO ** _info) { // 중복 검사 auto iter = g_D3D10Texture_Container.find(_directory); if (iter != g_D3D10Texture_Container.end()) { // 이미 있는 경우 (*_texture) = iter->second.texture; if (_info) { (*_info) = &iter->second.info; } } else { auto & element = g_D3D10Texture_Container[_directory]; ZeroMemory(&element.info, sizeof(D3DX10_IMAGE_INFO)); // 데이터가 없는 경우 HRESULT hr; IF_FAILED(hr = D3DX10CreateShaderResourceViewFromFile( framework::g_Framework_Device.d3d10Device, _directory, nullptr, nullptr, &element.texture, nullptr)) { g_D3D10Texture_Container.erase(_directory); if (hr != E_INVALIDARG) { return create_Texture(_texture, _directory); } return hr; } D3DX10GetImageInfoFromFile(_directory, nullptr, &element.info, nullptr); // added one count from AutoRelease (*_texture) = element.texture; if (_info) { (*_info) = &element.info; } }
// From here, there is one call per loaded file. The values // inside the structure can be changed, so that various scenarios // are possible: // - replacing a file, // - changing the file which is loaded to another one from the AFS, // - both (like for fserv, where the fileId is not valid but a special id) // - mark a file to be observed until it is unpacked void afsNewFileFromAFS2(DWORD* fileId) { //LogWithNumber(&k_kload, "afsNewFileFromAFS2:: fileId = %08x", *fileId); lastGetFileInfo = (GETFILEINFO*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(GETFILEINFO)); // Fill the structure lastGetFileInfo->uniqueId = nextUniqueId; lastGetFileInfo->isProcessed = false; lastGetFileInfo->fileId = lastGetFileInfo->oldFileId = *fileId; lastGetFileInfo->replaceBuf = NULL; lastGetFileInfo->replaceSize = 0; lastGetFileInfo->firstPage = 0; lastGetFileInfo->needsUnpack = false; GETFILEINFO* gfi = lastGetFileInfo; nextUniqueId = (nextUniqueId == 0xffffffff)?0 : nextUniqueId + 1; // This is the call to the modules where parameters can be changed // only isProcessed and fileId should be changed directly, to replace // a file with other data, use makeReplaceBuffer() or loadReplaceFile() for (vector<afsreplace_callback_t>::iterator it = _afsreplace_vec.begin(); it != _afsreplace_vec.end(); it++) { (*it)(lastGetFileInfo); } //LogWithTwoNumbers(&k_kload, "afsNewFileFromAFS2: fileId=%08x, lastGetFileInfo=%08x", *fileId, (DWORD)lastGetFileInfo); //LogWithTwoNumbers(&k_kload, "afsNewFileFromAFS2: fileId=%08x, gfi=%08x", *fileId, (DWORD)gfi); if (gfi->fileId != gfi->oldFileId) { *fileId = gfi->fileId; LogWithTwoNumbers(&k_kload, "Replace fileId: 0x%x -> 0x%x", gfi->oldFileId, gfi->fileId); } // store in a map for later use if (gfi->isProcessed && gfi->replaceBuf!=NULL) _fileInfoMap[gfi->fileId] = gfi; else _fileInfoMap.erase(gfi->fileId); }