Skip to content

Commit

Permalink
Use simpler device types, consolidate device object initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
szellmann committed Nov 3, 2024
1 parent b723c0b commit bf29592
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 84 deletions.
272 changes: 203 additions & 69 deletions DeviceCopyableObjects.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions camera/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace visionaray {

Camera::Camera(VisionarayGlobalState *s) : Object(ANARI_CAMERA, s)
{
vcam = dco::createCamera();
s->objectCounts.cameras++;
}

Expand Down
1 change: 1 addition & 0 deletions frame/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static bool is_ready(const std::future<R> &f)

Frame::Frame(VisionarayGlobalState *s) : helium::BaseFrame(s)
{
vframe = dco::createFrame();
vframe.frameID = deviceState()->dcos.frames.alloc(vframe);
s->objectCounts.frames++;
#ifdef WITH_CUDA
Expand Down
3 changes: 1 addition & 2 deletions scene/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace visionaray {

Instance::Instance(VisionarayGlobalState *s) : Object(ANARI_INSTANCE, s)
{
memset(&vinstance,0,sizeof(vinstance));

vinstance = dco::createInstance();
vinstance.type = dco::Instance::Transform;
vinstance.instID
= deviceState()->dcos.instances.alloc(vinstance);
Expand Down
8 changes: 4 additions & 4 deletions scene/VisionarayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ VisionaraySceneImpl::VisionaraySceneImpl(

if (type == World) {
m_worldID = deviceState()->dcos.TLSs.alloc({});
deviceState()->dcos.worlds.alloc(dco::World{});
deviceState()->dcos.worlds.alloc(dco::createWorld());
}
m_groupID = deviceState()->dcos.groups.alloc(dco::Group{});
m_groupID = deviceState()->dcos.groups.alloc(dco::createGroup());
}

VisionaraySceneImpl::~VisionaraySceneImpl()
Expand Down Expand Up @@ -432,15 +432,15 @@ void VisionaraySceneImpl::dispatch()
if (type == World) {
m_state->dcos.TLSs.update(m_worldID, m_worldTLS.ref());

dco::World world; // TODO: move TLS and EPS in here!
dco::World world = dco::createWorld(); // TODO: move TLS and EPS in here!
world.numLights = m_allLights.size();
world.allLights = m_allLights.devicePtr();
m_state->dcos.worlds.update(m_worldID, world);
}

// Dispatch group
if (type == Group) {
dco::Group group;
dco::Group group = dco::createGroup();
group.groupID = m_groupID;
group.numBLSs = m_BLSs.size();
group.BLSs = m_BLSs.devicePtr();
Expand Down
2 changes: 1 addition & 1 deletion scene/light/Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace visionaray {

Light::Light(VisionarayGlobalState *s) : Object(ANARI_LIGHT, s)
{
memset(&vlight,0,sizeof(vlight));
vlight = dco::createLight();
vlight.lightID = deviceState()->dcos.lights.alloc(vlight);
s->objectCounts.lights++;
}
Expand Down
1 change: 1 addition & 0 deletions scene/surface/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace visionaray {

Surface::Surface(VisionarayGlobalState *s) : Object(ANARI_SURFACE, s)
{
vsurf = dco::createSurface();
vsurf.surfID = deviceState()->dcos.surfaces.alloc(vsurf);
s->objectCounts.surfaces++;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/surface/geometry/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace visionaray {

Geometry::Geometry(VisionarayGlobalState *s) : Object(ANARI_GEOMETRY, s)
{
memset(&vgeom,0,sizeof(vgeom));
vgeom = dco::createGeometry();
vgeom.geomID = deviceState()->dcos.geometries.alloc(vgeom);
s->objectCounts.geometries++;
}
Expand Down
1 change: 1 addition & 0 deletions scene/surface/material/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace visionaray {

Material::Material(VisionarayGlobalState *s) : Object(ANARI_MATERIAL, s)
{
vmat = dco::createMaterial();
vmat.matID = deviceState()->dcos.materials.alloc(vmat);
s->objectCounts.materials++;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/surface/material/sampler/Sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace visionaray {

Sampler::Sampler(VisionarayGlobalState *s) : Object(ANARI_SAMPLER, s)
{
memset(&vsampler,0,sizeof(vsampler));
vsampler = dco::createSampler();
vsampler.samplerID = deviceState()->dcos.samplers.alloc(vsampler);
s->objectCounts.samplers++;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/volume/Volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace visionaray {

Volume::Volume(VisionarayGlobalState *s) : Object(ANARI_VOLUME, s)
{
memset(&vvol,0,sizeof(vvol));
vvol = dco::createVolume();
vvol.volID = deviceState()->dcos.volumes.alloc(vvol);
s->objectCounts.volumes++;
}
Expand Down
5 changes: 4 additions & 1 deletion scene/volume/spatial_field/GridAccel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

namespace visionaray {

GridAccel::GridAccel(VisionarayGlobalState *s) : m_state(s) {}
GridAccel::GridAccel(VisionarayGlobalState *s) : m_state(s)
{
vaccel = dco::createGridAccel();
}

void GridAccel::init(int3 dims, box3 worldBounds)
{
Expand Down
5 changes: 1 addition & 4 deletions scene/volume/spatial_field/SpatialField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ SpatialField::SpatialField(VisionarayGlobalState *s)
, m_gridAccel(s)
{
s->objectCounts.spatialFields++;
vfield = dco::createSpatialField();
vfield.fieldID = deviceState()->dcos.spatialFields.alloc(vfield);
m_gridAccel.visionarayAccel().fieldID = vfield.fieldID;
m_gridAccel.visionarayAccel().dims = int3(0);
m_gridAccel.visionarayAccel().valueRanges = nullptr;
m_gridAccel.visionarayAccel().maxOpacities = nullptr;
}

SpatialField::~SpatialField()
Expand Down

0 comments on commit bf29592

Please sign in to comment.