Skip to content

Commit

Permalink
add uniform geometry attributes to queries and implement in helide (#175
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jeffamstutz committed Dec 8, 2023
1 parent 01ac08a commit 869a992
Show file tree
Hide file tree
Showing 15 changed files with 4,620 additions and 1,879 deletions.
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_cone.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_curve.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_cylinder.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_quad.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_sphere.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
25 changes: 25 additions & 0 deletions code_gen/api/khr_geometry_triangle.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"types" : ["ANARI_STRING"],
"tags" : [],
"description" : "optional object name"
}, {
"name" : "color",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform color"
}, {
"name" : "attribute0",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute0"
}, {
"name" : "attribute1",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute1"
}, {
"name" : "attribute2",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute2"
}, {
"name" : "attribute3",
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"description" : "uniform attribute3"
}, {
"name" : "primitive.color",
"types" : ["ANARI_ARRAY1D"],
Expand Down
2,199 changes: 1,535 additions & 664 deletions libs/debug_device/ExtendedQueries.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/debug_device/ExtendedQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace debug_queries {
#define ANARI_INFO_parameter 9
#define ANARI_INFO_channel 10
#define ANARI_INFO_use 11
const int extension_count = 46;
const int extension_count = 47;
const char ** query_extensions();
const char ** query_object_types(ANARIDataType type);
const ANARIParameter * query_params(ANARIDataType type, const char *subtype);
Expand Down
1,918 changes: 1,379 additions & 539 deletions libs/helide/HelideDeviceQueries.cpp

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions libs/helide/scene/surface/geometry/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ RTCGeometry Geometry::embreeGeometry() const

void Geometry::commit()
{
m_attributes[0] = getParamObject<Array1D>("primitive.attribute0");
m_attributes[1] = getParamObject<Array1D>("primitive.attribute1");
m_attributes[2] = getParamObject<Array1D>("primitive.attribute2");
m_attributes[3] = getParamObject<Array1D>("primitive.attribute3");
m_attributes[4] = getParamObject<Array1D>("primitive.color");
m_uniformAttr[0] = getParam<float4>("attribute0", DEFAULT_ATTRIBUTE_VALUE);
m_uniformAttr[1] = getParam<float4>("attribute1", DEFAULT_ATTRIBUTE_VALUE);
m_uniformAttr[2] = getParam<float4>("attribute2", DEFAULT_ATTRIBUTE_VALUE);
m_uniformAttr[3] = getParam<float4>("attribute3", DEFAULT_ATTRIBUTE_VALUE);
m_uniformAttr[4] = getParam<float4>("color", DEFAULT_ATTRIBUTE_VALUE);
m_primitiveAttr[0] = getParamObject<Array1D>("primitive.attribute0");
m_primitiveAttr[1] = getParamObject<Array1D>("primitive.attribute1");
m_primitiveAttr[2] = getParamObject<Array1D>("primitive.attribute2");
m_primitiveAttr[3] = getParamObject<Array1D>("primitive.attribute3");
m_primitiveAttr[4] = getParamObject<Array1D>("primitive.color");
}

void Geometry::markCommitted()
Expand All @@ -72,7 +77,8 @@ float4 Geometry::getAttributeValue(const Attribute &attr, const Ray &ray) const
return DEFAULT_ATTRIBUTE_VALUE;

auto attrIdx = static_cast<int>(attr);
return readAttributeValue(m_attributes[attrIdx].ptr, ray.primID);
return readAttributeValue(
m_primitiveAttr[attrIdx].ptr, ray.primID, m_uniformAttr[attrIdx]);
}

} // namespace helide
Expand Down
3 changes: 2 additions & 1 deletion libs/helide/scene/surface/geometry/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct Geometry : public Object
protected:
RTCGeometry m_embreeGeometry{nullptr};

std::array<helium::IntrusivePtr<Array1D>, 5> m_attributes;
std::array<float4, 5> m_uniformAttr;
std::array<helium::IntrusivePtr<Array1D>, 5> m_primitiveAttr;
};

} // namespace helide
Expand Down
4 changes: 2 additions & 2 deletions libs/helium/array/Array1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ void Array1D::privatize()
makePrivatizedCopy(size());
}

float4 readAttributeValue(const Array1D *arr, uint32_t i)
float4 readAttributeValue(const Array1D *arr, uint32_t i, const float4 &d)
{
return arr ? arr->readAsAttributeValue(i) : DEFAULT_ATTRIBUTE_VALUE;
return arr ? arr->readAsAttributeValue(i) : d;
}

} // namespace helium
Expand Down
4 changes: 3 additions & 1 deletion libs/helium/array/Array1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ struct Array1D : public Array
size_t m_end{0};
};

anari::math::float4 readAttributeValue(const Array1D *arr, uint32_t i);
anari::math::float4 readAttributeValue(const Array1D *arr,
uint32_t i,
const anari::math::float4 &defaultValue = DEFAULT_ATTRIBUTE_VALUE);

// Inlined definitions ////////////////////////////////////////////////////////

Expand Down
2,199 changes: 1,535 additions & 664 deletions libs/sink_device/SinkDeviceQueries.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/sink_device/SinkDeviceQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace sink_device {
#define ANARI_INFO_parameter 9
#define ANARI_INFO_channel 10
#define ANARI_INFO_use 11
const int extension_count = 46;
const int extension_count = 47;
const char ** query_extensions();
const char ** query_object_types(ANARIDataType type);
const ANARIParameter * query_params(ANARIDataType type, const char *subtype);
Expand Down

0 comments on commit 869a992

Please sign in to comment.