1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
/**
* @file llfloatertexturefetchdebugger.cpp
* @brief LLFloaterTextureFetchDebugger class definition
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfloatertexturefetchdebugger.h"
#include "lluictrlfactory.h"
#include "llbutton.h"
#include "llspinctrl.h"
#include "llresmgr.h"
#include "llmath.h"
#include "llviewerwindow.h"
#include "llappviewer.h"
#include "lltexturefetch.h"
#include "llviewercontrol.h"
LLFloaterTextureFetchDebugger::LLFloaterTextureFetchDebugger(const LLSD& key)
: LLFloater(key),
mDebugger(NULL)
{
setTitle("Texture Fetching Debugger Floater");
mCommitCallbackRegistrar.add("TexFetchDebugger.ChangeTexelPixelRatio", boost::bind(&LLFloaterTextureFetchDebugger::onChangeTexelPixelRatio, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.Start", boost::bind(&LLFloaterTextureFetchDebugger::onClickStart, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.Clear", boost::bind(&LLFloaterTextureFetchDebugger::onClickClear, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.Close", boost::bind(&LLFloaterTextureFetchDebugger::onClickClose, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.CacheRead", boost::bind(&LLFloaterTextureFetchDebugger::onClickCacheRead, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.CacheWrite", boost::bind(&LLFloaterTextureFetchDebugger::onClickCacheWrite, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.HTTPLoad", boost::bind(&LLFloaterTextureFetchDebugger::onClickHTTPLoad, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.Decode", boost::bind(&LLFloaterTextureFetchDebugger::onClickDecode, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.GLTexture", boost::bind(&LLFloaterTextureFetchDebugger::onClickGLTexture, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchVisCache", boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchVisCache, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchVisHTTP", boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchVisHTTP, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchAllCache", boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchAllCache, this));
mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchAllHTTP", boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchAllHTTP, this));
}
//----------------------------------------------
BOOL LLFloaterTextureFetchDebugger::postBuild(void)
{
mDebugger = LLAppViewer::getTextureFetch()->getFetchDebugger();
//set states for buttons
mButtonStateMap["start_btn"] = true;
mButtonStateMap["close_btn"] = true;
mButtonStateMap["clear_btn"] = true;
mButtonStateMap["cacheread_btn"] = false;
mButtonStateMap["cachewrite_btn"] = false;
mButtonStateMap["http_btn"] = false;
mButtonStateMap["decode_btn"] = false;
mButtonStateMap["gl_btn"] = false;
mButtonStateMap["refetchviscache_btn"] = false;
mButtonStateMap["refetchvishttp_btn"] = false;
mButtonStateMap["refetchallcache_btn"] = false;
mButtonStateMap["refetchallhttp_btn"] = false;
updateButtons();
getChild<LLUICtrl>("texel_pixel_ratio")->setValue(gSavedSettings.getF32("TexelPixelRatio"));
return TRUE ;
}
LLFloaterTextureFetchDebugger::~LLFloaterTextureFetchDebugger()
{
//stop everything
mDebugger->stopDebug();
}
void LLFloaterTextureFetchDebugger::updateButtons()
{
for(std::map<std::string, bool>::iterator iter = mButtonStateMap.begin(); iter != mButtonStateMap.end(); ++iter)
{
if(iter->second)
{
childEnable(iter->first.c_str());
}
else
{
childDisable(iter->first.c_str());
}
}
}
void LLFloaterTextureFetchDebugger::disableButtons()
{
childDisable("start_btn");
childDisable("clear_btn");
childDisable("cacheread_btn");
childDisable("cachewrite_btn");
childDisable("http_btn");
childDisable("decode_btn");
childDisable("gl_btn");
childDisable("refetchviscache_btn");
childDisable("refetchvishttp_btn");
childDisable("refetchallcache_btn");
childDisable("refetchallhttp_btn");
}
void LLFloaterTextureFetchDebugger::idle()
{
LLTextureFetchDebugger::e_debug_state state = mDebugger->getState();
if(mDebugger->update())
{
switch(state)
{
case LLTextureFetchDebugger::IDLE:
break;
case LLTextureFetchDebugger::READ_CACHE:
mButtonStateMap["decode_btn"] = true;
updateButtons();
break;
case LLTextureFetchDebugger::WRITE_CACHE:
updateButtons();
break;
case LLTextureFetchDebugger::DECODING:
mButtonStateMap["gl_btn"] = true;
updateButtons();
break;
case LLTextureFetchDebugger::HTTP_FETCHING:
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["cachewrite_btn"] = true;
mButtonStateMap["decode_btn"] = true;
updateButtons();
break;
case LLTextureFetchDebugger::GL_TEX:
updateButtons();
break;
case LLTextureFetchDebugger::REFETCH_VIS_CACHE:
updateButtons();
case LLTextureFetchDebugger::REFETCH_VIS_HTTP:
updateButtons();
break;
case LLTextureFetchDebugger::REFETCH_ALL_CACHE:
updateButtons();
case LLTextureFetchDebugger::REFETCH_ALL_HTTP:
updateButtons();
break;
default:
break;
}
}
}
//----------------------
void LLFloaterTextureFetchDebugger::onChangeTexelPixelRatio()
{
gSavedSettings.setF32("TexelPixelRatio", getChild<LLUICtrl>("texel_pixel_ratio")->getValue().asReal());
}
void LLFloaterTextureFetchDebugger::onClickStart()
{
disableButtons();
mDebugger->startDebug();
mButtonStateMap["start_btn"] = false;
if(LLAppViewer::getTextureFetch()->canLoadFromCache())
{
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["http_btn"] = false;
mButtonStateMap["refetchviscache_btn"] = true;
mButtonStateMap["refetchvishttp_btn"] = false;
mButtonStateMap["refetchallcache_btn"] = true;
mButtonStateMap["refetchallhttp_btn"] = false;
mButtonStateMap["cachewrite_btn"] = false;
}
else
{
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["http_btn"] = true;
mButtonStateMap["refetchviscache_btn"] = true;
mButtonStateMap["refetchvishttp_btn"] = true;
mButtonStateMap["refetchallcache_btn"] = true;
mButtonStateMap["refetchallhttp_btn"] = true;
}
updateButtons();
}
void LLFloaterTextureFetchDebugger::onClickClose()
{
setVisible(FALSE);
//stop everything
mDebugger->stopDebug();
}
void LLFloaterTextureFetchDebugger::onClickClear()
{
mButtonStateMap["start_btn"] = true;
mButtonStateMap["close_btn"] = true;
mButtonStateMap["clear_btn"] = true;
mButtonStateMap["cacheread_btn"] = false;
mButtonStateMap["cachewrite_btn"] = false;
mButtonStateMap["http_btn"] = false;
mButtonStateMap["decode_btn"] = false;
mButtonStateMap["gl_btn"] = false;
mButtonStateMap["refetchviscache_btn"] = true;
mButtonStateMap["refetchvishttp_btn"] = true;
updateButtons();
//stop everything
mDebugger->stopDebug();
mDebugger->clearHistory();
}
void LLFloaterTextureFetchDebugger::onClickCacheRead()
{
disableButtons();
mDebugger->debugCacheRead();
}
void LLFloaterTextureFetchDebugger::onClickCacheWrite()
{
disableButtons();
mDebugger->debugCacheWrite();
}
void LLFloaterTextureFetchDebugger::onClickHTTPLoad()
{
disableButtons();
mDebugger->debugHTTP();
}
void LLFloaterTextureFetchDebugger::onClickDecode()
{
disableButtons();
mDebugger->debugDecoder();
}
void LLFloaterTextureFetchDebugger::onClickGLTexture()
{
disableButtons();
mDebugger->debugGLTextureCreation();
}
void LLFloaterTextureFetchDebugger::onClickRefetchVisCache()
{
disableButtons();
mDebugger->debugRefetchVisibleFromCache();
}
void LLFloaterTextureFetchDebugger::onClickRefetchVisHTTP()
{
disableButtons();
mDebugger->debugRefetchVisibleFromHTTP();
}
void LLFloaterTextureFetchDebugger::onClickRefetchAllCache()
{
disableButtons();
mDebugger->debugRefetchAllFromCache();
}
void LLFloaterTextureFetchDebugger::onClickRefetchAllHTTP()
{
disableButtons();
mDebugger->debugRefetchAllFromHTTP();
}
void LLFloaterTextureFetchDebugger::draw()
{
//total number of fetched textures
{
getChild<LLUICtrl>("total_num_fetched_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumFetchedTextures()));
}
//total number of fetching requests
{
getChild<LLUICtrl>("total_num_fetching_requests_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumFetchingRequests()));
}
//total number of cache hits
{
getChild<LLUICtrl>("total_num_cache_hits_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumCacheHits()));
}
//total number of visible textures
{
getChild<LLUICtrl>("total_num_visible_tex_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumVisibleFetchedTextures()));
}
//total number of visible texture fetching requests
{
getChild<LLUICtrl>("total_num_visible_tex_fetch_req_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumVisibleFetchingRequests()));
}
//total number of fetched data
{
getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getFetchedData() >> 10));
getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getDecodedData() >> 10));
getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getFetchedPixels() / 1000000.f));
}
//total number of visible fetched data
{
getChild<LLUICtrl>("total_fetched_vis_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getVisibleFetchedData() >> 10));
getChild<LLUICtrl>("total_fetched_vis_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getVisibleDecodedData() >> 10));
}
//total number of rendered fetched data
{
getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getRenderedData() >> 10));
getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getRenderedDecodedData() >> 10));
getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRenderedPixels() / 1000000.f));
}
//total time on cache readings
if(mDebugger->getCacheReadTime() < 0.f)
{
getChild<LLUICtrl>("total_time_cache_read_label")->setTextArg("[TIME]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_cache_read_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getCacheReadTime()));
}
//total time on cache writings
if(mDebugger->getCacheWriteTime() < 0.f)
{
getChild<LLUICtrl>("total_time_cache_write_label")->setTextArg("[TIME]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_cache_write_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getCacheWriteTime()));
}
//total time on decoding
if(mDebugger->getDecodeTime() < 0.f)
{
getChild<LLUICtrl>("total_time_decode_label")->setTextArg("[TIME]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_decode_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getDecodeTime()));
}
//total time on gl texture creation
if(mDebugger->getGLCreationTime() < 0.f)
{
getChild<LLUICtrl>("total_time_gl_label")->setTextArg("[TIME]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_gl_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getGLCreationTime()));
}
//total time on HTTP fetching
if(mDebugger->getHTTPTime() < 0.f)
{
getChild<LLUICtrl>("total_time_http_label")->setTextArg("[TIME]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getHTTPTime()));
}
//total time on entire fetching
{
getChild<LLUICtrl>("total_time_fetch_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getTotalFetchingTime()));
}
//total time on refetching visible textures from cache
if(mDebugger->getRefetchVisCacheTime() < 0.f)
{
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[TIME]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[SIZE]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[PIXEL]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchVisCacheTime()));
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedVisData() >> 10));
getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedVisPixels() / 1000000.f));
}
//total time on refetching all textures from cache
if(mDebugger->getRefetchAllCacheTime() < 0.f)
{
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[TIME]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[SIZE]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[PIXEL]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchAllCacheTime()));
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedAllData() >> 10));
getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedAllPixels() / 1000000.f));
}
//total time on refetching visible textures from http
if(mDebugger->getRefetchVisHTTPTime() < 0.f)
{
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[TIME]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[SIZE]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[PIXEL]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchVisHTTPTime()));
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedVisData() >> 10));
getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedVisPixels() / 1000000.f));
}
//total time on refetching all textures from http
if(mDebugger->getRefetchAllHTTPTime() < 0.f)
{
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[TIME]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[SIZE]", std::string("----"));
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[PIXEL]", std::string("----"));
}
else
{
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchAllHTTPTime()));
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedAllData() >> 10));
getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedAllPixels() / 1000000.f));
}
LLFloater::draw();
}
|