| 67 | VALIDATION_MESSAGE; |
| 68 | } |
| 69 | void TestAssignedCopy::SetUp() |
| 70 | { |
| 71 | Base::SetUp(); |
| 72 | |
| 73 | camera.setParam("position", vec3f(0.f, 0.f, 4.f)); |
| 74 | camera.setParam("direction", vec3f(0.f, 0.f, -1.f)); |
| 75 | camera.setParam("up", vec3f(0.f, 1.f, 0.f)); |
| 76 | |
| 77 | cpp::Geometry spheres("sphere"); |
| 78 | |
| 79 | const int numspheres = 1000; |
| 80 | std::vector<vec3f> centersB; |
| 81 | |
| 82 | // per default use malloc |
| 83 | float *radiiB = (float *)malloc(numspheres * sizeof(float)); |
| 84 | OSPDeleterCallback radiiDeleter = customMallocDeleter; |
| 85 | void *radiiUserData = &TestAssignedCopyDelCounts::delcounts; |
| 86 | #ifdef SYCL_LANGUAGE_VERSION |
| 87 | auto *appsSyclQueue = ospEnv->GetAppsSyclQueue(); |
| 88 | if (appsSyclQueue) { // but on GPU use sycl::malloc |
| 89 | free(radiiB); |
| 90 | radiiB = sycl::malloc_shared<float>(numspheres, *appsSyclQueue); |
| 91 | radiiDeleter = customSYCLDeleter; |
| 92 | radiiUserData = appsSyclQueue; |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | vec2f *tcoordsB = new vec2f[numspheres]; |
| 97 | |
| 98 | unsigned int randomSeed{0}; |
| 99 | std::mt19937 gen(randomSeed); |
| 100 | std::uniform_real_distribution<float> centerDistribution(-1.f, 1.f); |
| 101 | std::uniform_real_distribution<float> radiusDistribution(0.05f, 0.15f); |
| 102 | |
| 103 | for (int i = 0; i < numspheres; i++) { |
| 104 | radiiB[i] = radiusDistribution(gen); |
| 105 | const float x = centerDistribution(gen); |
| 106 | const float y = centerDistribution(gen); |
| 107 | const float z = centerDistribution(gen); |
| 108 | centersB.emplace_back(x, y, z); |
| 109 | tcoordsB[i] = vec2f((float)i / (float)numspheres, 0.f); |
| 110 | } |
| 111 | |
| 112 | OSPData radii = ospNewAssignedData1D( |
| 113 | radiiB, OSP_FLOAT, numspheres, radiiDeleter, radiiUserData); |
| 114 | |
| 115 | OSPData tcoords = ospNewAssignedData1D(tcoordsB, |
| 116 | OSP_VEC2F, |
| 117 | numspheres, |
| 118 | customNewDeleter, |
| 119 | &TestAssignedCopyDelCounts::delcounts); |
| 120 | |
| 121 | spheres.setParam("sphere.position", cpp::MovedData(centersB)); |
| 122 | |
| 123 | EXPECT_TRUE(centersB.empty()) << "Buffer was not moved."; |
| 124 | |
| 125 | spheres.setParam("sphere.radius", radii); |
| 126 | spheres.setParam("sphere.texcoord", tcoords); |
nothing calls this directly
no test coverage detected