Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Archive
Alchemy Viewer
Commits
c47c1fdd
Commit
c47c1fdd
authored
5 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Optimize findImage with a hashmap find
parent
d98e2340
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/newview/llviewertexturelist.cpp
+16
-12
16 additions, 12 deletions
indra/newview/llviewertexturelist.cpp
indra/newview/llviewertexturelist.h
+16
-1
16 additions, 1 deletion
indra/newview/llviewertexturelist.h
with
32 additions
and
13 deletions
indra/newview/llviewertexturelist.cpp
+
16
−
12
View file @
c47c1fdd
...
...
@@ -119,6 +119,7 @@ void LLViewerTextureList::doPreloadImages()
llassert_always
(
mInitialized
)
;
llassert_always
(
mImageList
.
empty
())
;
llassert_always
(
mUUIDMap
.
empty
())
;
llassert_always
(
mUUIDHashMap
.
empty
());
// Set the "missing asset" image
LLViewerFetchedTexture
::
sMissingAssetImagep
=
LLViewerTextureManager
::
getFetchedTextureFromFile
(
"missing_asset.tga"
,
FTT_LOCAL_FILE
,
MIPMAP_NO
,
LLViewerFetchedTexture
::
BOOST_UI
);
...
...
@@ -326,6 +327,7 @@ void LLViewerTextureList::shutdown()
mFastCacheList
.
clear
();
mUUIDMap
.
clear
();
mUUIDHashMap
.
clear
();
mImageList
.
clear
();
...
...
@@ -622,8 +624,8 @@ void LLViewerTextureList::findTexturesByID(const LLUUID &image_id, std::vector<L
LLViewerFetchedTexture
*
LLViewerTextureList
::
findImage
(
const
LLTextureKey
&
search_key
)
{
uuid_map_t
::
itera
to
r
iter
=
mUUIDMap
.
find
(
search_key
);
if
(
iter
==
mUUIDMap
.
end
())
const
au
to
&
iter
=
mUUID
Hash
Map
.
find
(
search_key
);
if
(
iter
==
mUUID
Hash
Map
.
c
end
())
return
NULL
;
return
iter
->
second
;
}
...
...
@@ -644,12 +646,12 @@ void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image)
}
else
{
if
((
mImageList
.
insert
(
image
)).
second
!=
true
)
{
LL_WARNS
()
<<
"Error happens when insert image "
<<
image
->
getID
()
<<
" into mImageList!"
<<
LL_ENDL
;
if
((
mImageList
.
insert
(
image
)).
second
!=
true
)
{
LL_WARNS
()
<<
"Error happens when insert image "
<<
image
->
getID
()
<<
" into mImageList!"
<<
LL_ENDL
;
}
image
->
setInImageList
(
TRUE
)
;
}
image
->
setInImageList
(
TRUE
)
;
}
}
void
LLViewerTextureList
::
removeImageFromList
(
LLViewerFetchedTexture
*
image
)
...
...
@@ -675,17 +677,17 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
<<
" but doesn't have mInImageList set"
<<
" ref count is "
<<
image
->
getNumRefs
()
<<
LL_ENDL
;
uuid_map_t
::
itera
to
r
iter
=
mUUIDMap
.
find
(
LLTextureKey
(
image
->
getID
(),
(
ETexListType
)
image
->
getTextureListType
()));
if
(
iter
==
mUUIDMap
.
end
())
const
au
to
&
iter
=
mUUID
Hash
Map
.
find
(
LLTextureKey
(
image
->
getID
(),
(
ETexListType
)
image
->
getTextureListType
()));
if
(
iter
==
mUUID
Hash
Map
.
c
end
())
{
LL_INFOS
()
<<
"Image "
<<
image
->
getID
()
<<
" is also not in mUUIDMap!"
<<
LL_ENDL
;
}
else
if
(
iter
->
second
!=
image
)
{
LL_INFOS
()
<<
"Image "
<<
image
->
getID
()
<<
" was in mUUIDMap but with different pointer"
<<
LL_ENDL
;
}
}
else
{
{
LL_INFOS
()
<<
"Image "
<<
image
->
getID
()
<<
" was in mUUIDMap with same pointer"
<<
LL_ENDL
;
}
count
=
mImageList
.
erase
(
image
)
;
...
...
@@ -718,7 +720,8 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image, ETexListTy
sNumImages
++
;
addImageToList
(
new_image
);
mUUIDMap
[
key
]
=
new_image
;
mUUIDMap
.
emplace
(
key
,
new_image
);
mUUIDHashMap
.
emplace
(
key
,
new_image
);
new_image
->
setTextureListType
(
tex_type
);
}
...
...
@@ -733,6 +736,7 @@ void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image)
}
LLTextureKey
key
(
image
->
getID
(),
(
ETexListType
)
image
->
getTextureListType
());
llverify
(
mUUIDMap
.
erase
(
key
)
==
1
);
llverify
(
mUUIDHashMap
.
erase
(
key
)
==
1
);
sNumImages
--
;
removeImageFromList
(
image
);
}
...
...
This diff is collapsed.
Click to expand it.
indra/newview/llviewertexturelist.h
+
16
−
1
View file @
c47c1fdd
...
...
@@ -35,6 +35,8 @@
#include
<list>
#include
"lluiimage.h"
#include
"absl/container/flat_hash_map.h"
const
U32
LL_IMAGE_REZ_LOSSLESS_CUTOFF
=
128
;
const
BOOL
MIPMAP_YES
=
TRUE
;
...
...
@@ -82,6 +84,17 @@ struct LLTextureKey
return
key1
.
textureType
<
key2
.
textureType
;
}
}
friend
bool
operator
==
(
const
LLTextureKey
&
lhs
,
const
LLTextureKey
&
rhs
)
{
return
lhs
.
textureId
==
rhs
.
textureId
&&
lhs
.
textureType
==
rhs
.
textureType
;
}
template
<
typename
H
>
friend
H
AbslHashValue
(
H
h
,
const
LLTextureKey
&
id
)
{
return
H
::
combine
(
std
::
move
(
h
),
id
.
textureId
,
id
.
textureType
);
}
};
class
LLViewerTextureList
...
...
@@ -209,8 +222,10 @@ public:
BOOL
mForceResetTextureStats
;
private
:
typedef
std
::
map
<
LLTextureKey
,
LLPointer
<
LLViewerFetchedTexture
>
>
uuid_map_t
;
using
uuid_map_t
=
std
::
map
<
LLTextureKey
,
LLPointer
<
LLViewerFetchedTexture
>
>
;
using
uuid_hash_map_t
=
absl
::
flat_hash_map
<
LLTextureKey
,
LLPointer
<
LLViewerFetchedTexture
>
>
;
uuid_map_t
mUUIDMap
;
uuid_hash_map_t
mUUIDHashMap
;
LLTextureKey
mLastUpdateKey
;
LLTextureKey
mLastFetchKey
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment