-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcsfthreaded.cpp
729 lines (590 loc) · 19.9 KB
/
csfthreaded.cpp
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/*
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-FileCopyrightText: Copyright (c) 2014-2021 NVIDIA CORPORATION
* SPDX-License-Identifier: Apache-2.0
*/
/* Contact [email protected] (Christoph Kubisch) for feedback */
#define DEBUG_FILTER 1
#include <imgui/imgui_helper.h>
#include <glm/gtc/type_ptr.hpp>
#if HAS_OPENGL
#include <include_gl.h>
#include <nvgl/appwindowprofiler_gl.hpp>
#include <nvgl/base_gl.hpp>
#include <nvgl/error_gl.hpp>
#include <nvgl/glsltypes_gl.hpp>
#else
#include <nvvk/appwindowprofiler_vk.hpp>
#endif
#include <nvvk/context_vk.hpp>
#include <nvh/cameracontrol.hpp>
#include <nvh/fileoperations.hpp>
#include <nvh/geometry.hpp>
#include "renderer.hpp"
#include "glm/gtc/matrix_access.hpp"
namespace csfthreaded {
int const SAMPLE_SIZE_WIDTH(800);
int const SAMPLE_SIZE_HEIGHT(600);
void setupVulkanContextInfo(nvvk::ContextCreateInfo& info)
{
#if HAS_OPENGL
// not compatible with OPENGL extension
info.removeInstanceLayer("VK_LAYER_KHRONOS_validation");
#endif
}
class Sample
#if HAS_OPENGL
: public nvgl::AppWindowProfilerGL
#else
: public nvvk::AppWindowProfilerVK
#endif
{
enum GuiEnums
{
GUI_SHADE,
GUI_RENDERER,
GUI_STRATEGY,
GUI_MSAA,
};
public:
struct Tweak
{
int renderer = 0;
ShadeType shade = SHADE_SOLID;
Strategy strategy = STRATEGY_GROUPS;
int msaa = 0;
int copies = 1;
int threads = 1;
int workingSet = 4096;
bool batchedSubmit = true;
bool sorted = false;
bool animation = false;
bool animationSpin = false;
int cloneaxisX = 1;
int cloneaxisY = 1;
int cloneaxisZ = 1;
float percent = 1.001f;
};
bool m_useUI = true;
ImGuiH::Registry m_ui;
double m_uiTime = 0;
Tweak m_tweak;
Tweak m_lastTweak;
bool m_lastVsync;
CadScene m_scene;
std::vector<unsigned int> m_renderersSorted;
std::string m_rendererName;
Renderer* NV_RESTRICT m_renderer;
Resources* NV_RESTRICT m_resources;
Resources::Global m_shared;
std::string m_modelFilename = "geforce.csf.gz";
double m_animBeginTime;
double m_lastFrameTime = 0;
double m_frames = 0;
double m_statsFrameTime = 0;
double m_statsCpuTime = 0;
double m_statsGpuTime = 0;
bool initProgram();
bool initScene(const char* filename, int clones, int cloneaxis);
bool initFramebuffers(int width, int height);
void initRenderer(int type, Strategy strategy, int threads, bool sorted, float percent, double uiTime = -1.0);
void deinitRenderer();
void setupConfigParameters();
void setRendererFromName();
Sample()
#if HAS_OPENGL
: AppWindowProfilerGL(false)
#else
: AppWindowProfilerVK(false)
#endif
{
setupConfigParameters();
#if !HAS_OPENGL
setupVulkanContextInfo(m_contextInfo);
#endif
#if defined(NDEBUG)
setVsync(false);
#endif
}
public:
bool validateConfig() override;
void postBenchmarkAdvance() override { setRendererFromName(); }
bool begin() override;
void think(double time) override;
void resize(int width, int height) override;
void processUI(int width, int height, double time);
nvh::CameraControl m_control;
void end() override;
// return true to prevent m_window updates
bool mouse_pos(int x, int y) override
{
if(!m_useUI)
return false;
return ImGuiH::mouse_pos(x, y);
}
bool mouse_button(int button, int action) override
{
if(!m_useUI)
return false;
return ImGuiH::mouse_button(button, action);
}
bool mouse_wheel(int wheel) override
{
if(!m_useUI)
return false;
return ImGuiH::mouse_wheel(wheel);
}
bool key_char(int key) override
{
if(!m_useUI)
return false;
return ImGuiH::key_char(key);
}
bool key_button(int button, int action, int mods) override
{
if(!m_useUI)
return false;
return ImGuiH::key_button(button, action, mods);
}
};
bool Sample::initProgram()
{
return true;
}
bool Sample::initScene(const char* filename, int clones, int cloneaxis)
{
std::string modelFilename(filename);
if(!nvh::fileExists(filename))
{
modelFilename = nvh::getFileName(filename);
std::vector<std::string> searchPaths;
searchPaths.push_back("./");
searchPaths.push_back(exePath() + PROJECT_RELDIRECTORY);
searchPaths.push_back(exePath() + PROJECT_DOWNLOAD_RELDIRECTORY);
modelFilename = nvh::findFile(modelFilename, searchPaths);
}
m_scene.unload();
bool status = m_scene.loadCSF(modelFilename.c_str(), clones, cloneaxis);
if(status)
{
LOGI("\nscene %s\n", filename);
LOGI("geometries: %6d\n", uint32_t(m_scene.m_geometry.size()));
LOGI("materials: %6d\n", uint32_t(m_scene.m_materials.size()));
LOGI("nodes: %6d\n", uint32_t(m_scene.m_matrices.size()));
LOGI("objects: %6d\n", uint32_t(m_scene.m_objects.size()));
LOGI("\n");
}
else
{
LOGW("\ncould not load model %s\n", modelFilename.c_str());
}
m_shared.animUbo.numMatrices = uint(m_scene.m_matrices.size());
return status;
}
bool Sample::initFramebuffers(int width, int height)
{
return m_resources->initFramebuffer(width, height, m_tweak.msaa, getVsync());
}
void Sample::deinitRenderer()
{
if(m_renderer)
{
m_resources->synchronize();
m_renderer->deinit();
delete m_renderer;
m_renderer = NULL;
}
}
void Sample::initRenderer(int typesort, Strategy strategy, int threads, bool sorted, float percent, double uiTime)
{
int type = m_renderersSorted[typesort];
deinitRenderer();
if(Renderer::getRegistry()[type]->resources() != m_resources)
{
if(m_resources)
{
m_resources->synchronize();
m_resources->deinit();
// if we were triggered by UI then we are within imgui frame
// we must terminate this frame as we are changing the imgui backend
// later we will restart the frame
if (uiTime >= 0.0 && m_useUI)
{
ImGui::EndFrame();
}
}
m_resources = Renderer::getRegistry()[type]->resources();
#if HAS_OPENGL
bool valid = m_resources->init(&m_contextWindow, &m_profiler);
#else
bool valid = m_resources->init(&m_context, &m_swapChain, &m_profiler);
#endif
valid = valid && m_resources->initFramebuffer(m_windowState.m_swapSize[0], m_windowState.m_swapSize[1], m_tweak.msaa, getVsync());
valid = valid && m_resources->initPrograms(exePath(), std::string());
valid = valid && m_resources->initScene(m_scene);
m_resources->m_frame = 0;
if(!valid)
{
LOGE("resource initialization failed for renderer: %s\n", Renderer::getRegistry()[type]->name());
exit(-1);
}
m_lastVsync = getVsync();
if(uiTime >= 0.0 && m_useUI)
{
int width = m_windowState.m_swapSize[0];
int height = m_windowState.m_swapSize[1];
processUI(width,height, uiTime + 0.0000001);
}
}
Renderer::Config config;
config.objectFrom = 0;
config.objectNum = uint32_t(double(m_scene.m_objects.size()) * double(m_tweak.percent));
config.strategy = strategy;
config.threads = threads;
config.sorted = sorted;
LOGI("renderer: %s\n", Renderer::getRegistry()[type]->name());
m_renderer = Renderer::getRegistry()[type]->create();
m_renderer->init(&m_scene, m_resources, config);
}
void Sample::end()
{
deinitRenderer();
if(m_resources)
{
m_resources->deinit();
}
}
bool Sample::begin()
{
#if !PRINT_TIMER_STATS
m_profilerPrint = false;
m_timeInTitle = true;
#else
m_profilerPrint = true;
m_timeInTitle = true;
#endif
m_renderer = NULL;
m_resources = NULL;
int maxthreads = ThreadPool::sysGetNumCores();
Renderer::s_threadpool.init(maxthreads);
ImGuiH::Init(m_windowState.m_winSize[0], m_windowState.m_winSize[1], this);
#if HAS_OPENGL
{
// smoother CPU timings for GL vs Vulkan comparison, don't do this in actual applications!!
// it will disable optimizations
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
GLuint defaultVAO;
glGenVertexArrays(1, &defaultVAO);
glBindVertexArray(defaultVAO);
}
#endif
bool validated(true);
validated = validated && initProgram();
validated = validated
&& initScene(m_modelFilename.c_str(), m_tweak.copies - 1,
(m_tweak.cloneaxisX << 0) | (m_tweak.cloneaxisY << 1) | (m_tweak.cloneaxisZ << 2));
const Renderer::Registry registry = Renderer::getRegistry();
for(size_t i = 0; i < registry.size(); i++)
{
if(registry[i]->isAvailable())
{
uint sortkey = uint(i);
sortkey |= registry[i]->priority() << 16;
m_renderersSorted.push_back(sortkey);
}
}
if(m_renderersSorted.empty())
{
LOGE("No renderers available\n");
return false;
}
std::sort(m_renderersSorted.begin(), m_renderersSorted.end());
for(size_t i = 0; i < m_renderersSorted.size(); i++)
{
m_renderersSorted[i] &= 0xFFFF;
}
for(size_t i = 0; i < m_renderersSorted.size(); i++)
{
LOGI("renderers found: %d %s\n", uint32_t(i), registry[m_renderersSorted[i]]->name());
}
setRendererFromName();
if(m_useUI)
{
auto& imgui_io = ImGui::GetIO();
imgui_io.IniFilename = nullptr;
for(size_t i = 0; i < m_renderersSorted.size(); i++)
{
m_ui.enumAdd(GUI_RENDERER, int(i), registry[m_renderersSorted[i]]->name());
}
m_ui.enumAdd(GUI_STRATEGY, STRATEGY_INDIVIDUAL, "drawcall individual");
m_ui.enumAdd(GUI_STRATEGY, STRATEGY_GROUPS, "material groups");
m_ui.enumAdd(GUI_SHADE, SHADE_SOLID, toString(SHADE_SOLID));
m_ui.enumAdd(GUI_SHADE, SHADE_SOLIDWIRE, toString(SHADE_SOLIDWIRE));
m_ui.enumAdd(GUI_MSAA, 0, "none");
m_ui.enumAdd(GUI_MSAA, 2, "2x");
m_ui.enumAdd(GUI_MSAA, 4, "4x");
m_ui.enumAdd(GUI_MSAA, 8, "8x");
}
m_control.m_sceneOrbit = glm::vec3(m_scene.m_bbox.max + m_scene.m_bbox.min) * 0.5f;
m_control.m_sceneDimension = glm::length((m_scene.m_bbox.max - m_scene.m_bbox.min));
m_control.m_viewMatrix = glm::lookAt(m_control.m_sceneOrbit - (-glm::vec3(1, 1, 1) * m_control.m_sceneDimension * 0.5f),
m_control.m_sceneOrbit, glm::vec3(0, 1, 0));
m_shared.animUbo.sceneCenter = m_control.m_sceneOrbit;
m_shared.animUbo.sceneDimension = m_control.m_sceneDimension * 0.2f;
m_shared.animUbo.numMatrices = uint32_t(m_scene.m_matrices.size());
m_shared.sceneUbo.wLightPos = (m_scene.m_bbox.max + m_scene.m_bbox.min) * 0.5f + m_control.m_sceneDimension;
m_shared.sceneUbo.wLightPos.w = 1.0;
initRenderer(m_tweak.renderer, m_tweak.strategy, m_tweak.threads, m_tweak.sorted, m_tweak.percent);
m_lastTweak = m_tweak;
return validated;
}
void Sample::processUI(int width, int height, double time)
{
// Update imgui configuration
auto& imgui_io = ImGui::GetIO();
imgui_io.DeltaTime = static_cast<float>(time - m_uiTime);
imgui_io.DisplaySize = ImVec2(width, height);
m_uiTime = time;
ImGui::NewFrame();
ImGui::SetNextWindowSize(ImGuiH::dpiScaled(350, 0), ImGuiCond_FirstUseEver);
if(ImGui::Begin("NVIDIA " PROJECT_NAME, nullptr))
{
//ImGui::PushItemWidth(200);
#if HAS_OPENGL
ImGui::Text("gl and vk version");
#else
ImGui::Text("vk only version");
#endif
ImGui::Separator();
m_ui.enumCombobox(GUI_RENDERER, "renderer", &m_tweak.renderer);
m_ui.enumCombobox(GUI_STRATEGY, "strategy", &m_tweak.strategy);
m_ui.enumCombobox(GUI_SHADE, "shademode", &m_tweak.shade);
m_ui.enumCombobox(GUI_MSAA, "msaa", &m_tweak.msaa);
//guiRegistry.enumCombobox(GUI_SUPERSAMPLE, "supersample", &tweak.supersample);
ImGui::SliderFloat("pct visible", &m_tweak.percent, 0.0f, 1.001f);
ImGui::PushItemWidth(ImGuiH::dpiScaled(100));
ImGuiH::InputIntClamped("copies", &m_tweak.copies, 1, 16, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue);
ImGuiH::InputIntClamped("threaded: worker threads", &m_tweak.threads, 1, Renderer::s_threadpool.getNumThreads());
ImGuiH::InputIntClamped("threaded: workingset", &m_tweak.workingSet, 128, 16 * 1024, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::Checkbox("threaded: batched submit", &m_tweak.batchedSubmit);
ImGui::Checkbox("sorted", &m_tweak.sorted);
ImGui::Checkbox("animation", &m_tweak.animation);
ImGui::PopItemWidth();
ImGui::Separator();
{
int avg = 50;
if(m_lastFrameTime == 0)
{
m_lastFrameTime = time;
m_frames = -1;
}
if(m_frames > 4)
{
double curavg = (time - m_lastFrameTime) / m_frames;
if(curavg > 1.0 / 30.0)
{
avg = 10;
}
}
if(m_profiler.getTotalFrames() % avg == avg - 1)
{
m_profiler.getAveragedValues("Render", m_statsCpuTime, m_statsGpuTime);
m_statsFrameTime = (time - m_lastFrameTime) / m_frames;
m_lastFrameTime = time;
m_frames = -1;
}
m_frames++;
float gpuTimeF = float(m_statsGpuTime);
float cpuTimeF = float(m_statsCpuTime);
float maxTimeF = std::max(std::max(cpuTimeF, gpuTimeF), 0.0001f);
ImGui::Text("Frame [ms]: %2.1f", m_statsFrameTime * 1000.0f);
ImGui::Text("Scene GPU [ms]: %2.3f", gpuTimeF / 1000.0f);
ImGui::ProgressBar(gpuTimeF / maxTimeF, ImVec2(0.0f, 0.0f));
ImGui::Text("Scene CPU [ms]: %2.3f", cpuTimeF / 1000.0f);
ImGui::ProgressBar(cpuTimeF / maxTimeF, ImVec2(0.0f, 0.0f));
}
}
ImGui::End();
}
void Sample::think(double time)
{
int width = m_windowState.m_swapSize[0];
int height = m_windowState.m_swapSize[1];
if(m_useUI)
{
processUI(width, height, time);
}
m_control.processActions(glm::ivec2(m_windowState.m_winSize[0],m_windowState.m_winSize[1]),
glm::vec2(m_windowState.m_mouseCurrent[0], m_windowState.m_mouseCurrent[1]),
m_windowState.m_mouseButtonFlags, m_windowState.m_mouseWheel);
if(m_windowState.onPress(KEY_R))
{
m_resources->synchronize();
m_resources->reloadPrograms(std::string());
}
if(m_tweak.msaa != m_lastTweak.msaa || getVsync() != m_lastVsync)
{
m_lastVsync = getVsync();
m_resources->initFramebuffer(width, height, m_tweak.msaa, getVsync());
}
bool sceneChanged = false;
if(m_tweak.copies != m_lastTweak.copies || m_tweak.cloneaxisX != m_lastTweak.cloneaxisX
|| m_tweak.cloneaxisY != m_lastTweak.cloneaxisY || m_tweak.cloneaxisZ != m_lastTweak.cloneaxisZ)
{
sceneChanged = true;
m_resources->synchronize();
deinitRenderer();
m_resources->deinitScene();
initScene(m_modelFilename.c_str(), m_tweak.copies - 1,
(m_tweak.cloneaxisX << 0) | (m_tweak.cloneaxisY << 1) | (m_tweak.cloneaxisZ << 2));
m_resources->initScene(m_scene);
}
if(sceneChanged || m_tweak.renderer != m_lastTweak.renderer || m_tweak.strategy != m_lastTweak.strategy
|| m_tweak.threads != m_lastTweak.threads || m_tweak.sorted != m_lastTweak.sorted || m_tweak.percent != m_lastTweak.percent)
{
m_resources->synchronize();
initRenderer(m_tweak.renderer, m_tweak.strategy, m_tweak.threads, m_tweak.sorted, m_tweak.percent, time);
}
m_resources->beginFrame();
if(m_tweak.animation != m_lastTweak.animation)
{
m_resources->synchronize();
m_resources->animationReset();
m_animBeginTime = time;
}
{
m_shared.winWidth = width;
m_shared.winHeight = height;
SceneData& sceneUbo = m_shared.sceneUbo;
sceneUbo.viewport = ivec2(width, height);
glm::mat4 projection =
m_resources->perspectiveProjection((45.f), float(width) / float(height), m_control.m_sceneDimension * 0.001f,
m_control.m_sceneDimension * 10.0f);
glm::mat4 view = m_control.m_viewMatrix;
if(m_tweak.animation && m_tweak.animationSpin)
{
double animTime = (time - m_animBeginTime) * 0.3 + glm::pi<double>() * 0.2;
vec3 dir = vec3(cos(animTime), 1, sin(animTime));
view = glm::lookAt(m_control.m_sceneOrbit - (-dir * m_control.m_sceneDimension * 0.5f),
m_control.m_sceneOrbit, vec3(0, 1, 0));
}
sceneUbo.viewProjMatrix = projection * view;
sceneUbo.viewMatrix = view;
sceneUbo.viewMatrixIT = glm::transpose(glm::inverse(view));
sceneUbo.viewPos = glm::row(sceneUbo.viewMatrixIT, 3);
sceneUbo.viewDir = -glm::row(view,2);
sceneUbo.wLightPos = glm::row(sceneUbo.viewMatrixIT,3);
sceneUbo.wLightPos.w = 1.0;
m_shared.workingSet = m_tweak.workingSet;
m_shared.batchedSubmit = m_tweak.batchedSubmit;
}
if(m_tweak.animation)
{
AnimationData& animUbo = m_shared.animUbo;
animUbo.time = float(time - m_animBeginTime);
m_resources->animation(m_shared);
}
{
m_renderer->draw(m_tweak.shade, m_resources, m_shared);
}
{
if(m_useUI)
{
ImGui::Render();
m_shared.imguiDrawData = ImGui::GetDrawData();
}
else
{
m_shared.imguiDrawData = nullptr;
}
m_resources->blitFrame(m_shared);
}
m_resources->endFrame();
m_resources->m_frame++;
if(m_useUI)
{
ImGui::EndFrame();
}
m_lastTweak = m_tweak;
}
void Sample::resize(int width, int height)
{
initFramebuffers(width, height);
}
void Sample::setRendererFromName()
{
if(!m_rendererName.empty())
{
const Renderer::Registry registry = Renderer::getRegistry();
for(size_t i = 0; i < m_renderersSorted.size(); i++)
{
if(strcmp(m_rendererName.c_str(), registry[m_renderersSorted[i]]->name()) == 0)
{
m_tweak.renderer = int(i);
}
}
}
}
void Sample::setupConfigParameters()
{
m_parameterList.addFilename(".csf", &m_modelFilename);
m_parameterList.addFilename(".csf.gz", &m_modelFilename);
m_parameterList.addFilename(".gltf", &m_modelFilename);
m_parameterList.add("vkdevice", &Resources::s_vkDevice);
m_parameterList.add("gldevice", &Resources::s_glDevice);
m_parameterList.add("noui", &m_useUI, false);
m_parameterList.add("renderer", (uint32_t*)&m_tweak.renderer);
m_parameterList.add("renderernamed", &m_rendererName);
m_parameterList.add("strategy", (uint32_t*)&m_tweak.strategy);
m_parameterList.add("shademode", (uint32_t*)&m_tweak.shade);
m_parameterList.add("workerthreads", &m_tweak.threads);
m_parameterList.add("msaa", &m_tweak.msaa);
m_parameterList.add("copies", &m_tweak.copies);
m_parameterList.add("animation", &m_tweak.animation);
m_parameterList.add("animationspin", &m_tweak.animationSpin);
m_parameterList.add("minstatechanges", &m_tweak.sorted);
m_parameterList.add("workingset", &m_tweak.workingSet);
}
bool Sample::validateConfig()
{
if(m_modelFilename.empty())
{
LOGI("no .csf model file specified\n");
LOGI("exe <filename.csf/cfg> parameters...\n");
m_parameterList.print();
return false;
}
return true;
}
} // namespace csfthreaded
using namespace csfthreaded;
int main(int argc, const char** argv)
{
NVPSystem system(PROJECT_NAME);
#if defined(_WIN32) && defined(NDEBUG)
//SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#endif
Sample sample;
{
std::vector<std::string> directories;
directories.push_back(NVPSystem::exePath());
directories.push_back(NVPSystem::exePath() + "/media");
directories.push_back(NVPSystem::exePath() + std::string(PROJECT_DOWNLOAD_RELDIRECTORY));
sample.m_modelFilename = nvh::findFile(std::string("geforce.csf.gz"), directories);
}
return sample.run(PROJECT_NAME, argc, argv, SAMPLE_SIZE_WIDTH, SAMPLE_SIZE_HEIGHT);
}