NVIDIA Index example code nvidia_logo_transpbg.gif Up
xac_compute.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 *****************************************************************************/
4// Example for IndeX XAC compute.
5
6
7#include "xac_compute.h"
8#include "xac_compute_app.h"
10
11#include <nv/index/icompute.h>
12#include <nv/index/idistributed_data_access.h>
13
14// Include code shared by all examples.
15#define USE_NVINDEX_ACCESS
16#include "utility/example_shared.h"
17#include "utility/app_rendering_context.h"
18#include "utility/canvas_utility.h"
19
20#include <nv/index/app/iimage_importer.h>
21#include <nv/index/app/index_connect_.h> // FIXME should be updated to index_connect.h
22
23#include <iostream>
24#include <sstream>
25
26//----------------------------------------------------------------------
27namespace xac_compute {
28
29//----------------------------------------------------------------------
31 public nv::index::app::Index_connect
32{
33public:
35 :
36 Index_connect()
37 {
38 // INFO_LOG << "DEBUG: Create_xac_compute_index_connect() ctor";
39 }
40
42 {
43 // Note: Index_connect::~Index_connect() will be called after here.
44 // INFO_LOG << "DEBUG: ~Create_xac_compute_index_connect() dtor";
45 }
46
47 // launch application
48 mi::Sint32 launch();
49
50protected:
51 // virtual bool evaluate_options(nv::index::app::String_dict& sdict) CPP11_OVERRIDE;
52 // override
54 mi::neuraylib::INetwork_configuration* network_configuration,
55 nv::index::app::String_dict& options) CPP11_OVERRIDE
56 {
57 check_success(network_configuration != 0);
58
59 check_success(options.is_defined("unittest"));
60 const bool is_unittest = nv::index::app::get_bool(options.get("unittest"));
61 if (is_unittest)
62 {
63 info_cout("NETWORK: disabled networking mode.", options);
64 network_configuration->set_mode(mi::neuraylib::INetwork_configuration::MODE_OFF);
65 return true;
66 }
67
68 return initialize_networking_as_default_udp(network_configuration, options);
69 }
70protected:
71
72private:
73 // This session tag
74 mi::neuraylib::Tag m_session_tag;
75 // NVIDIA IndeX cluster configuration
76 mi::base::Handle<nv::index::ICluster_configuration> m_cluster_configuration;
77 // Application layer image file canvas (a render target)
78 mi::base::Handle<nv::index::app::canvas_infrastructure::IIndex_image_file_canvas> m_image_file_canvas;
79 // Create_icons options
80 std::string m_outfname;
81 bool m_is_unittest;
82 // std::string m_verify_image_fname_sequence;
83 // std::string m_verify_image_fname;
84
85};
86
87
88// //----------------------------------------------------------------------
89// mi::Sint32 launch()
90// {
91
92// }
93
94// //----------------------------------------------------------------------
95// bool evaluate_options(nv::index::app::String_dict& sdict)
96// {
97
98// }
99
100
101using mi::base::Handle;
102using mi::neuraylib::IDice_transaction;
103using mi::neuraylib::Tag_struct;
104
105
106
107//----------------------------------------------------------------------
109 Option_map& opt_map,
110 int argc, char* argv[])
111{
112 get_default_options(opt_map);
113 process_command_line(argc, argv, opt_map.get_map());
114
115 if (nv::index::app::get_bool(opt_map["unittest"])) {
116 if (nv::index::app::get_bool(opt_map["is_call_from_test"])) {
117 opt_map["is_dump_comparison_image_when_failed"] = "0";
118 }
119 opt_map["outfname"] = ""; // turn off file output in the unit test mode
120 opt_map["dice::verbose"] = "2";
121 }
122 const std::string com_name(argv[0]);
123 info_cout(std::string("running ") + com_name, opt_map.get_map());
124 info_cout(std::string("outfname = [") + opt_map["outfname"] +
125 "], verify_image_fname = [" + opt_map["verify_image_fname"] +
126 "], dice::verbose = " + opt_map["dice::verbose"], opt_map.get_map());
127
128
129 // print help and exit if -h
130 if (opt_map.has_key("h")) {
131 std::cout << "info: Usage: " << com_name << " [option]\n" << get_usage(opt_map);
132
133 exit(1);
134 }
135
136 int iscene = nv::index::app::get_sint32(opt_map["scene"]);
137 const IXac_compute_scene_setup* scene_setup = get_scene_setup(iscene);
138 return scene_setup;
139}
140
141
142
143//----------------------------------------------------------------------
144
145std::string get_error_info(const nv::index::IError_set* err_set)
146{
147 std::ostringstream os;
148 const mi::Uint32 nb_err = err_set->get_nb_errors();
149 for (mi::Uint32 e = 0; e < nb_err; ++e)
150 {
151 if (e != 0) os << '\n';
152 Handle<const nv::index::IError> err(err_set->get_error(e));
153 os << err->get_error_string();
154 }
155 return os.str();
156}
157
158
159//----------------------------------------------------------------------
160
161inline mi::Uint32 reverse(mi::Uint32 x)
162{
163 // after http://aggregate.org/MAGIC
164
165 x = ((x & 0xaaaaaaaau) >> 1u) | ((x & 0x55555555u) << 1u);
166 x = ((x & 0xccccccccu) >> 2u) | ((x & 0x33333333u) << 2u);
167 x = ((x & 0xf0f0f0f0u) >> 4u) | ((x & 0x0f0f0f0fu) << 4u);
168 x = ((x & 0xff00ff00u) >> 8u) | ((x & 0x00ff00ffu) << 8u);
169 x = (x >> 16u) | (x << 16u);
170
171 return x;
172}
173
174
176{
178 nv::index::app::IApplication_layer* app_layer,
179 const Vec2u& res,
180 const std::string& plane_img_basename,
181 const std::string& verify_img_basename)
182 : app_layer_ref(app_layer)
183 , colors(res.x* res.y)
184 , resolution(res)
185 , img_basename(!verify_img_basename.empty() ? verify_img_basename : plane_img_basename)
186 , write_image(!plane_img_basename.empty())
187 , verify_image(!verify_img_basename.empty())
188 {
189 }
190
191 bool write_or_verify(const char* postfix) const;
192
193 nv::index::app::IApplication_layer* app_layer_ref;
194 std::vector<mi::math::Color_struct> colors;
196 std::string img_basename;
199};
200
201
202
203bool Plane_img_helper::write_or_verify(const char* postfix) const
204{
205 std::string imgfname = img_basename + postfix;
206 if (verify_image) {
207
209 mi::base::Handle<nv::index::app::image::IImage_importer> image_importer(
210 app_layer_ref->get_api_component<nv::index::app::image::IImage_importer>());
211 check_success(image_importer.is_valid_interface());
212 mi::base::Handle<mi::neuraylib::ICanvas> canvas(
213 image_importer->create_canvas_from_file(imgfname.c_str()));
214 check_success(canvas.is_valid_interface());
215
216 std::map<std::string, std::string> opt_map;
217 // When "1" force to dump the images.
218 opt_map["is_dump_comparison_image"] = "0";
219 // When "1" dump the images when comparison failed.
220 opt_map["is_dump_comparison_image_when_failed"] = "0";
221 return verify_canvas_result(app_layer_ref, canvas.get(), imgfname, opt_map);
222 }
223 else if (write_image)
224 {
225 return export_color_pixels(app_layer_ref, colors, resolution, imgfname);
226 }
227 return true;
228}
229
230
231
233 Nvindex_access& nvindex_accessor,
234 const Compute_launch_info& launch_info,
235 const nv::index::ICompute_results* cpt_results,
236 IDice_transaction* transaction,
237 const std::string& plane_img_basename,
238 const std::string& verify_img_basename)
239{
240 if (cpt_results == NULL) {
241 ERROR_LOG << "NULL compute results.";
242 return false;
243 }
244
245 if (!cpt_results->is_valid()) {
246 ERROR_LOG << "Invalid compute results.";
247 return false;
248 }
249 Handle<const nv::index::IError_set> err_set(cpt_results->get_error_set());
250 if (err_set && err_set->any_errors()) {
251 ERROR_LOG << "Compute results has errors: \n" << get_error_info(err_set.get());
252 return false;
253 }
254
255
256 const bool use_compute_plane = launch_info.plane_tag.is_valid();
257 if (use_compute_plane) {
258 Handle<nv::index::IDistributed_data_access> data_access(cpt_results->access_compute_results());
259 if (!data_access) {
260 ERROR_LOG << "Compute plane results - no data access.";
261 return false;
262 }
263
264 const int access_status = data_access->access(
265 launch_info.scene_roi, // query full scene bbox
266 transaction);
267
268 if (access_status < 0) {
269 ERROR_LOG << "Compute plane results - access error " << access_status << ".";
270 return false;
271 }
272
273 Handle<const nv::index::IDistributed_data_subset> result_data_subset(
274 data_access->get_distributed_data_subset());
275 if (!result_data_subset) {
276 ERROR_LOG << "Compute plane results - no data subset.";
277 return false;
278 }
279 Handle<const nv::index::ICompute_result_buffer_2D> result_buffer(
280 result_data_subset->get_interface<const nv::index::ICompute_result_buffer_2D>());
281 if (!result_buffer) {
282 ERROR_LOG << "Compute plane results - data subset is not result buffer.";
283 return false;
284 }
285
286 // now we have the 2D result buffer, do something with it...
287 std::ostringstream ss;
288 const Vec2u res = result_buffer->get_resolution();
289 ss << "Compute plane result [" << res.x << "x" << res.y << "]["
290 << result_buffer->get_nb_values() << "] ( ";
291 for (mi::Uint32 i=0; i < result_buffer->get_nb_values(); ++i) {
292 ss << result_buffer->get_value_size(i) << " ";
293 }
294 ss << ")";
295 INFO_LOG << ss.str();
296
297
298 Plane_img_helper helper(nvindex_accessor.get_application_layer_interface(),
299 res, plane_img_basename, verify_img_basename);
300
301 if (helper.write_image || helper.verify_image) {
302
303 const size_t nb_pixels = res.x * res.y;
304 //std::vector<mi::math::Color_struct> colors(nb_pixels);
305
306 const float* values = reinterpret_cast<const float*>(result_buffer->get_values(0));
307 for (size_t i = 0; i < nb_pixels; ++i) {
308 float s = values[i];
309 mi::math::Color_struct col = {s,s,s,1.f};
310 helper.colors[i] = col;
311 }
312 if (!helper.write_or_verify("_plane_compute.ppm")) {
313 return false;
314 }
315
316 const mi::Uint32* masks = result_buffer->get_value_masks();
317 const mi::math::Color_struct mcol[2] = {
318 {1.f, 0.f, 0.f, 1.f}, // 0 == red
319 {0.f, 1.f, 0.f, 1.f} // 1 == green
320 };
321 for (size_t i = 0; i < nb_pixels; ++i) {
322 helper.colors[i] = mcol[masks[i] & 0x1];
323 }
324 if (!helper.write_or_verify("_plane_compute_mask.ppm")) {
325 return false;
326 }
327
328 const Vec3f* values2 = reinterpret_cast<const Vec3f*>(result_buffer->get_values(1));
329 for (size_t i = 0; i < nb_pixels; ++i) {
330 Vec3f v = values2[i];
331 mi::math::Color_struct col = {v.x, v.y, v.z, 1.f};
332 helper.colors[i] = col;
333 }
334 if (!helper.write_or_verify("_plane_compute2.ppm")) {
335 return false;
336 }
337
338 if (result_buffer->get_nb_values() > 2) {
339 const mi::Uint32* values3 = reinterpret_cast<const mi::Uint32*>(result_buffer->get_values(2));
340 for (size_t i = 0; i < nb_pixels; ++i) {
341 mi::Uint32 v = reverse(values3[i] * 0x18273645u);
342 mi::math::Color_struct col = {
343 ((v >> 24) & 0xff) / 255.f,
344 ((v >> 16) & 0xff) / 255.f,
345 ((v >> 8) & 0xff) / 255.f,
346 1.f};
347 helper.colors[i] = col;
348 }
349 if (!helper.write_or_verify("_plane_compute3.ppm")) {
350 return false;
351 }
352 }
353 if (result_buffer->get_nb_values() > 3) {
354 const mi::Uint32* values4 = reinterpret_cast<const mi::Uint32*>(result_buffer->get_values(3));
355 for (size_t i = 0; i < nb_pixels; ++i) {
356 float s = values4[i] * 0.1f;
357 mi::math::Color_struct col = {s,s,s,1.f};
358 helper.colors[i] = col;
359 }
360 if (!helper.write_or_verify("_plane_compute4.ppm")) {
361 return false;
362 }
363 }
364 }
365 }
366 return true;
367}
368
369
371 Nvindex_access& nvindex_accessor,
372 const Compute_launch_info& launch_info,
373 const Handle<const nv::index::ICompute_results>& cpt_results,
374 App_rendering_context& arc,
375 const Option_map& opt_map,
376 int frame_idx)
377{
378 Handle<IDice_transaction> transaction(arc.m_global_scope->create_transaction<IDice_transaction>());
379
380 std::string plane_img_basename = get_output_file_name(opt_map["outfname"], frame_idx);
381
382 std::stringstream ref_img_opt;
383 ref_img_opt << "verify_plane_fname_" << frame_idx;
384 std::string verify_fname = opt_map[ref_img_opt.str()];
385
386 bool result =
387 print_compute_info(nvindex_accessor, launch_info, cpt_results.get(), transaction.get(), plane_img_basename, verify_fname);
388
389 transaction->commit();
390
391 return result;
392}
393
394
395//----------------------------------------------------------------------
396
397
398Handle<const nv::index::ICompute_results>
400 Nvindex_access& nvindex_accessor,
401 const Compute_launch_info& launch_info,
402 App_rendering_context& arc,
403 const Option_map& opt_map)
404{
405 const bool use_compute_plane = nv::index::app::get_sint32(opt_map["compute_plane"]) != 0;
406
407
408 Handle<IDice_transaction> transaction(arc.m_global_scope->create_transaction<IDice_transaction>());
409 check_success(transaction.is_valid_interface());
410
411 //Handle<const nv::index::ISession> session(transaction->access<const nv::index::ISession>(arc.m_session_tag));
412 //check_success(session.is_valid_interface());
413
414 //Handle<const nv::index::IScene> scene(transaction->access<const nv::index::IScene>(session->get_scene()));
415 //check_success(scene.is_valid_interface());
416
417 // needed?
418 arc.m_iindex_session->update(arc.m_session_tag, transaction.get());
419
420 // Access the compute interface.
421 Handle<nv::index::IIndex_compute> index_compute(nvindex_accessor.get_interface()->get_api_component<nv::index::IIndex_compute>());
422 check_success(index_compute.is_valid_interface());
423
424 // Create a compute launch request.
425 Handle<nv::index::ICompute_launch_request> launch_request(index_compute->create_launch_request());
426 check_success(launch_request.is_valid_interface());
427
428 // Set up the request.
429 if (use_compute_plane) {
430 // XAC compute plane supports a separate compute target and write target.
431 launch_request->set_launch(
432 launch_info.plane_compute_program_tag,
433 launch_info.scene_element_tag, // compute-target
434 launch_info.plane_tag); // write-target
435 }
436 else {
437 launch_request->set_launch(
438 launch_info.compute_program_tag,
439 launch_info.scene_element_tag);
440 }
441
442 // Optionally set region of interest. (An empty bbox means use complete dataset)
443 if (launch_info.compute_roi.is_volume()) {
444 launch_request->set_region_of_interest(launch_info.compute_roi);
445 }
446
447
448 // Launch.
449 Handle<const nv::index::ICompute_results> cpt_results;
450
451 if (launch_request->is_valid()) {
452 cpt_results = index_compute->perform_compute(
453 launch_request.get(),
454 arc.m_iindex_rendering.get(),
455 arc.m_session_tag,
456 transaction.get());
457 }
458 else {
459 ERROR_LOG << "Invalid compute launch request.";
460 }
461
462 transaction->commit();
463
464 return cpt_results;
465}
466
467
469 Nvindex_access& nvindex_accessor,
470 const Compute_launch_info& launch_info,
471 App_rendering_context& arc,
472 const Option_map& opt_map,
473 int frame_idx)
474{
475 Handle<const nv::index::ICompute_results> cpt_results =
476 perform_compute(nvindex_accessor, launch_info, arc, opt_map);
477
478 return print_compute_info(nvindex_accessor, launch_info, cpt_results, arc, opt_map, frame_idx);
479}
480
481
482
483// Render a frame and save the rendered image to a file or verify using a reference image.
485 Nvindex_access& nvindex_accessor,
486 mi::Sint32 frame_idx,
487 App_rendering_context& arc,
488 const Option_map& opt_map)
489{
490 const std::string out_fname = get_output_file_name(opt_map["outfname"], frame_idx);
491
492 INFO_LOG << "Rendering frame " << (frame_idx + 1) << " \n";
493 Handle<const nv::index::IFrame_results> frame_results(render_frame(arc, out_fname));
494 Handle<const nv::index::IError_set> err_set(frame_results->get_error_set());
495 if (err_set && err_set->any_errors()) {
496 ERROR_LOG << "IIndex_rendering rendering call failed with the following error(s): \n"
497 << get_error_info(err_set.get());
498 return false;
499 }
500
501 print_performance(frame_results.get(), opt_map);
502
503 // verify the generated frame
504 std::stringstream ref_img_opt;
505 ref_img_opt << "verify_image_fname_" << frame_idx;
506
507 std::string verify_fname = opt_map[ref_img_opt.str()];
508 if (!verify_fname.empty()) {
509 if (!(verify_canvas_result(nvindex_accessor.get_application_layer_interface(),
510 arc.m_image_canvas.get(), verify_fname, opt_map.get_map()))) {
511 return false;
512 }
513 }
514
515 return true;
516}
517
518
520 Nvindex_access& nvindex_accessor,
521 const IXac_compute_scene_setup* scene_setup,
522 App_rendering_context& arc,
523 const Option_map& opt_map)
524{
525 {
526 Handle<IDice_transaction> transaction(arc.m_global_scope->create_transaction<IDice_transaction>());
527 check_success(transaction.is_valid_interface());
528
529 //Handle<const nv::index::ISession> session(transaction->access<const nv::index::ISession>(arc.m_session_tag));
530 //check_success(session.is_valid_interface());
531
532 //Handle<const nv::index::IScene> scene(transaction->access<const nv::index::IScene>(session->get_scene()));
533 //check_success(scene.is_valid_interface());
534
535 // needed?
536 arc.m_iindex_session->update(arc.m_session_tag, transaction.get());
537
538 scene_setup->unload_scene(arc.m_session_tag, opt_map, transaction.get());
539 transaction->commit();
540 }
541
542 bool ok = false;
543 if (scene_setup->can_reload())
544 {
545 Handle<IDice_transaction> transaction(arc.m_global_scope->create_transaction<IDice_transaction>());
546 check_success(transaction.is_valid_interface());
547
548 //Handle<const nv::index::ISession> session(transaction->access<const nv::index::ISession>(arc.m_session_tag));
549 //check_success(session.is_valid_interface());
550
551 //Handle<const nv::index::IScene> scene(transaction->access<const nv::index::IScene>(session->get_scene()));
552 //check_success(scene.is_valid_interface());
553
554 // needed?
555 arc.m_iindex_session->update(arc.m_session_tag, transaction.get());
556
557 ok = scene_setup->reload_scene(nvindex_accessor, arc.m_session_tag, opt_map, transaction.get());
558 transaction->commit();
559 }
560 else {
561 ok = true; // testing unload only
562 }
563 return ok;
564}
565
566
567
568// returns 0 if success, else error (exit) code
570 const IXac_compute_scene_setup* scene_setup,
571 Nvindex_access& nvindex_accessor,
572 const Option_map& opt_map)
573{
574 mi::Sint32 exit_code = 0;
575
576 const char* sep_line = "----------------------------------------------------------------------------";
577
578 App_rendering_context arc;
579 setup_app_context(arc, nvindex_accessor);
580
581 // Verifying that local host has joined. This may fail when there is a license problem.
582 check_success(arc.is_local_host_joined());
583
584 INFO_LOG << "\n" << sep_line << "\n XAC Compute Example - Scene " << scene_setup->name() << "\n" << sep_line;
585
586 // Scene setup
587 Compute_launch_info launch_info;
588 setup_scene(nvindex_accessor, scene_setup, launch_info, arc, opt_map);
589
590 setup_performance_monitoring(arc, opt_map);
591
592 const mi::Uint32 compute_mode = nv::index::app::get_uint32(opt_map["run_compute"]);
593
594 int frame_idx = 0;
595 // Compute, pre-render
596 if (compute_mode >= 2) {
597 if (!run_compute(nvindex_accessor, launch_info, arc, opt_map, frame_idx)) {
598 exit_code = 2;
599 return exit_code;
600 }
601 }
602
603
604 // Rendering 1st
605 INFO_LOG << sep_line;
606 if (!render_frame_and_save_or_verify(nvindex_accessor, frame_idx, arc, opt_map)) {
607 exit_code = 1;
608 return exit_code;
609 }
610
611
612 frame_idx = 1;
613 // Compute, post-render
614 if (compute_mode == 1 || compute_mode == 3) {
615 if (!run_compute(nvindex_accessor, launch_info, arc, opt_map, frame_idx)) {
616 exit_code = 3;
617 return exit_code;
618 }
619 }
620
621 // Rendering 2nd
622 INFO_LOG << sep_line;
623 if (!render_frame_and_save_or_verify(nvindex_accessor, frame_idx, arc, opt_map)) {
624 exit_code = 4;
625 return exit_code;
626 }
627
628 frame_idx = 2;
629 // Export computed data
630 if (nv::index::app::get_bool(opt_map["export_scene"])) {
631 if (!export_scene_data(scene_setup, arc, opt_map)) {
632 exit_code = 5;
633 return exit_code;
634 }
635
636 if (!reload_scene(nvindex_accessor, scene_setup, arc, opt_map)) {
637 exit_code = 6;
638 return exit_code;
639 }
640 INFO_LOG << sep_line;
641 if (!render_frame_and_save_or_verify(nvindex_accessor, frame_idx, arc, opt_map)) {
642 exit_code = 7;
643 return exit_code;
644 }
645 }
646 return exit_code;
647}
648
649}//xac_compute
650//----------------------------------------------------------------------
651
652//=================================================================================================
653
654int main(int argc, char* argv[])
655{
656 using namespace xac_compute;
657
658 Option_map opt_map;
659 const IXac_compute_scene_setup* scene_setup = handle_arguments(opt_map, argc, argv);
660
661 // Load IndeX library
662 const std::string comp_dso_prefix = "libnvindex_application_layer_";
663 const std::string plug_dso_prefix = "libnvindex_plugin_";
664 Nvindex_access nvindex_accessor;
665 check_success(nvindex_accessor.load_library());
666 check_success(nvindex_accessor.load_application_layer_library());
667 check_success(nvindex_accessor.load_application_layer_component((comp_dso_prefix + "canvas_infrastructure").c_str()));
668 check_success(nvindex_accessor.load_application_layer_component((comp_dso_prefix + "image").c_str()));
669 check_success(nvindex_accessor.load_application_layer_component((comp_dso_prefix + "io").c_str()));
670 check_success(nvindex_accessor.load_application_layer_component((comp_dso_prefix + "data_analysis_and_processing").c_str()));
671 check_success(nvindex_accessor.load_application_layer_plugin( (plug_dso_prefix + "base_importer"). c_str()));
672 check_success(nvindex_accessor.load_application_layer_plugin( (plug_dso_prefix + "legacy_importer").c_str()));
673
674 start_nvindex_service(nvindex_accessor, opt_map, scene_setup);
675 if (!nvindex_accessor.is_initialized()) {
676 info_cout("Fatal error! Initialization of the IndeX library failed.", opt_map.get_map());
677 return 1;
678 }
679
680 mi::Sint32 exit_code = run_test_sequence(scene_setup, nvindex_accessor, opt_map);
681
682 nvindex_accessor.shutdown();
683
684 return exit_code;
685}
686
virtual bool initialize_networking(mi::neuraylib::INetwork_configuration *network_configuration, nv::index::app::String_dict &options) CPP11_OVERRIDE
Definition: xac_compute.cpp:53
virtual const char * name() const =0
virtual void unload_scene(mi::neuraylib::Tag session_tag, const Option_map &opt_map, mi::neuraylib::IDice_transaction *transaction) const
virtual bool reload_scene(Nvindex_access &nvindex_accessor, mi::neuraylib::Tag session_tag, const Option_map &opt_map, mi::neuraylib::IDice_transaction *transaction) const
bool has_key(const std::string &key) const
Definition: xac_compute.h:79
Map_type & get_map()
Definition: xac_compute.h:77
XAC compute example scenes.
Definition: xac_compute.cpp:27
void setup_app_context(App_rendering_context &arc, Nvindex_access &nvindex_accessor)
void start_nvindex_service(Nvindex_access &nvindex_accessor, const Option_map &opt_map, const xac_compute::IXac_compute_scene_setup *scene_setup)
bool render_frame_and_save_or_verify(Nvindex_access &nvindex_accessor, mi::Sint32 frame_idx, App_rendering_context &arc, const Option_map &opt_map)
bool export_scene_data(const xac_compute::IXac_compute_scene_setup *scene_setup, App_rendering_context &arc, const Option_map &opt_map)
void get_default_options(Option_map &opt_map)
mi::Uint32 reverse(mi::Uint32 x)
Handle< const nv::index::ICompute_results > perform_compute(Nvindex_access &nvindex_accessor, const Compute_launch_info &launch_info, App_rendering_context &arc, const Option_map &opt_map)
const IXac_compute_scene_setup * handle_arguments(Option_map &opt_map, int argc, char *argv[])
void setup_scene(Nvindex_access &nvindex_accessor, const xac_compute::IXac_compute_scene_setup *scene_setup, Compute_launch_info &info, App_rendering_context &arc, const Option_map &opt_map)
std::string get_usage(const Option_map &opt_map)
bool print_compute_info(Nvindex_access &nvindex_accessor, const Compute_launch_info &launch_info, const nv::index::ICompute_results *cpt_results, IDice_transaction *transaction, const std::string &plane_img_basename, const std::string &verify_img_basename)
nv::index::IFrame_results * render_frame(App_rendering_context &arc, const std::string &output_fname)
mi::Sint32 run_test_sequence(const IXac_compute_scene_setup *scene_setup, Nvindex_access &nvindex_accessor, const Option_map &opt_map)
const IXac_compute_scene_setup * get_scene_setup(int i)
void print_performance(const nv::index::IPerformance_values *performance_values, const Option_map &opt_map, const char *info)
mi::math::Vector< mi::Float32, 3 > Vec3f
Definition: xac_compute.h:38
std::string get_error_info(const nv::index::IError_set *err_set)
mi::math::Vector< mi::Uint32, 2 > Vec2u
Definition: xac_compute.h:31
bool reload_scene(Nvindex_access &nvindex_accessor, const IXac_compute_scene_setup *scene_setup, App_rendering_context &arc, const Option_map &opt_map)
bool run_compute(Nvindex_access &nvindex_accessor, const Compute_launch_info &launch_info, App_rendering_context &arc, const Option_map &opt_map, int frame_idx)
void setup_performance_monitoring(App_rendering_context &arc, const Option_map &opt_map)
std::map< std::string, std::string > Option_map
Definition: scene_setup.h:15
#define check_success(expr)
mi::neuraylib::Tag plane_tag
Definition: xac_compute.h:132
mi::neuraylib::Tag scene_element_tag
Definition: xac_compute.h:130
mi::neuraylib::Tag plane_compute_program_tag
Definition: xac_compute.h:131
mi::neuraylib::Tag compute_program_tag
Definition: xac_compute.h:129
std::vector< mi::math::Color_struct > colors
bool write_or_verify(const char *postfix) const
nv::index::app::IApplication_layer * app_layer_ref
Plane_img_helper(nv::index::app::IApplication_layer *app_layer, const Vec2u &res, const std::string &plane_img_basename, const std::string &verify_img_basename)
int main(int argc, char *argv[])
XAC Compute example definitions.
XAC compute example app setup.
Scene setup interface for xac compute example.