MCPcopy Create free account
hub / github.com/RenderKit/ospray / SetUp

Method SetUp

apps/ospTestSuite/test_sharedusm_data.cpp:46–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void TestUSMSharing::SetUp()
47{
48 Base::SetUp();
49
50 vec3i dims{100, 100, 100};
51 size_t numVoxels = dims.long_product();
52 voxels = std::vector<float>(numVoxels);
53 for (int x = 0; x < dims.x; ++x) {
54 double dx = (double)x / (double)dims.x - 0.5;
55 for (int y = 0; y < dims.y; ++y) {
56 double dy = (double)y / (double)dims.y - 0.5;
57 for (int z = 0; z < dims.z; ++z) {
58 double dz = (double)z / (double)dims.z - 0.5;
59 voxels[x * dims.y * dims.z + y * dims.z + z] =
60 1.0 - sqrt(dx * dx + dy * dy + dz * dz);
61 }
62 }
63 }
64
65 deviceVoxels = voxels.data();
66 sycl::queue *appsSyclQueue = ospEnv->GetAppsSyclQueue();
67 if (appsSyclQueue) {
68 if (memoryType == "host") {
69 deviceVoxels = sycl::malloc_host<float>(numVoxels, *appsSyclQueue);
70 } else if (memoryType == "device") {
71 deviceVoxels = sycl::malloc_device<float>(numVoxels, *appsSyclQueue);
72 } else {
73 deviceVoxels = sycl::malloc_shared<float>(numVoxels, *appsSyclQueue);
74 }
75 appsSyclQueue->memcpy(
76 deviceVoxels, voxels.data(), numVoxels * sizeof(float));
77 appsSyclQueue->wait();
78 }
79
80 // create and setup camera
81 camera.setParam("position", vec3f(200.f, 50.f, 50.f));
82 camera.setParam("up", vec3f(0.f, 1.f, 0.f));
83 camera.setParam("direction", vec3f(-1.f, 0.f, 0.f));
84
85 // create and setup model and mesh
86 ospray::cpp::Volume volume("structuredRegular");
87 volume.setParam("data", cpp::SharedData(deviceVoxels, dims));
88 volume.commit();
89
90 ospray::cpp::TransferFunction tf("piecewiseLinear");
91 std::vector<vec3f> color = {vec3f(0.5f, 0.0f, 0.0f),
92 vec3f(0.0f, 0.5f, 0.0f),
93 vec3f(0.0f, 0.0f, 1.0f)};
94 std::vector<float> opacity = {0.05f, 0.0f, 0.1f, 0.0f, 0.2f, 0.0f, 1.0f};
95
96 tf.setParam("value", box1f(0.14f, 1.0f));
97 tf.setParam("color", ospray::cpp::CopiedData(color));
98 tf.setParam("opacity", ospray::cpp::CopiedData(opacity));
99 tf.commit();
100
101 ospray::cpp::VolumetricModel vm(volume);
102 vm.setParam("transferFunction", tf);
103 vm.commit();

Callers

nothing calls this directly

Calls 7

ospNewLightFunction · 0.85
GetAppsSyclQueueMethod · 0.80
dataMethod · 0.45
memcpyMethod · 0.45
waitMethod · 0.45
setParamMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected