Skip to content

Commit

Permalink
Merge branch 'next_release'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffamstutz committed Sep 11, 2023
2 parents b03822e + b27c54a commit 286e28b
Show file tree
Hide file tree
Showing 23 changed files with 4,670 additions and 5,064 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

## Establish project

project(anari VERSION 0.7.1 LANGUAGES C CXX)
project(anari VERSION 0.7.2 LANGUAGES C CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ If you find any problems with the SDK, please do not hesitate to
[open an issue](https://github.com/KhronosGroup/ANARI-SDK/issues/new) on this
project!

## Building the SDK
## Getting the SDK from vcpkg

The ANARI-SDK is available as the `anari` package in
[vcpkg](https://vcpkg.io/en/). Simply follow [these
instructions](https://vcpkg.io/en/getting-started) for setting up your
environment to use vcpkg, then run the following to get ANARI:

```bash
% vcpkg install anari
```

## Building the SDK from source

The repository uses CMake 3.11+ to build the library, example implementation,
sample apps, and tests. For example, to build (must be in a separate directory
Expand Down
5 changes: 3 additions & 2 deletions cmake/anariConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ if (@INSTALL_CODE_GEN_SCRIPTS@)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/anari_generate_codegen.cmake)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/cmake/anari_sdk_fetch_project.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/cmake_project_commands.cmake)

if (@INSTALL_VIEWER_LIBRARY@ AND NOT TARGET anari_viewer)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/anari_sdk_fetch_project.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/cmake_project_commands.cmake)
add_subdirectory(
${ANARI_DATAROOTDIR}/anari_viewer
${CMAKE_CURRENT_BINARY_DIR}/anari_viewer
Expand Down
2 changes: 1 addition & 1 deletion code_gen/api/khr_sampler_transform.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"description" : "transform applied to the input attribute"
}, {
"name" : "outOffset",
"types" : ["ANARI_FLOAT32_MAT4"],
"types" : ["ANARI_FLOAT32_VEC4"],
"tags" : [],
"default" : [0,0,0,0],
"description" : "offset added to output outTransform result"
Expand Down
1 change: 0 additions & 1 deletion cts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ add_custom_target(generate_cts
--prefix cts
--device ${ANARI_CODE_GEN_ROOT}/devices/experimental_device.json
--namespace cts
--includefile
--out src
COMMAND ${CMAKE_COMMAND} -E copy ${python_files} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/createReferenceData.py
Expand Down
2 changes: 1 addition & 1 deletion cts/src/anariInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ std::string queryInfo(const std::string &library,
}
}

for (int i = 0; devices.size(); ++i) {
for (int i = 0; i < devices.size(); ++i) {
s << "Device \"" << deviceNames[i] << "\":\n";
s << " Subtypes:\n";
for (size_t j = 0; j < sizeof(namedTypes) / sizeof(ANARIDataType); ++j) {
Expand Down
9,590 changes: 4,578 additions & 5,012 deletions cts/src/ctsQueries.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cts/src/ctsQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace cts {
#define ANARI_INFO_parameter 9
#define ANARI_INFO_channel 10
#define ANARI_INFO_use 11
const int extension_count = 36;
const int extension_count = 46;
const char ** query_extensions();
const char ** query_object_types(ANARIDataType type);
const ANARIParameter * query_params(ANARIDataType type, const char *subtype);
Expand Down
2 changes: 1 addition & 1 deletion libs/anari/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PUBLIC
${CMAKE_DL_LIBS}
PRIVATE
Threads::Threads
glm::glm
$<BUILD_INTERFACE:glm::glm>
)

## Create version header
Expand Down
4 changes: 2 additions & 2 deletions libs/anari_viewer/external/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ anari_sdk_fetch_project(
include(CMakeFindDependencyMacro)

set(OpenGL_GL_PREFERENCE "LEGACY")
find_dependency(OpenGL 4)
find_dependency(glfw3)
find_dependency(OpenGL 4 REQUIRED)
find_dependency(glfw3 REQUIRED)

project_add_library(INTERFACE)

Expand Down
6 changes: 3 additions & 3 deletions libs/debug_device/ExtendedQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11218,8 +11218,8 @@ static const void * ANARI_SAMPLER_transform_outOffset_info(ANARIDataType paramTy
return nullptr;
}
case 1: // default
if(paramType == ANARI_FLOAT32_MAT4 && infoType == ANARI_FLOAT32_MAT4) {
static const float default_value[16] = {0.000000f, 0.000000f, 0.000000f, 0.000000f};
if(paramType == ANARI_FLOAT32_VEC4 && infoType == ANARI_FLOAT32_VEC4) {
static const float default_value[4] = {0.000000f, 0.000000f, 0.000000f, 0.000000f};
return default_value;
} else {
return nullptr;
Expand Down Expand Up @@ -13012,7 +13012,7 @@ static const void * ANARI_SAMPLER_transform_info(int infoName, ANARIDataType inf
{"name", ANARI_STRING},
{"inAttribute", ANARI_STRING},
{"outTransform", ANARI_FLOAT32_MAT4},
{"outOffset", ANARI_FLOAT32_MAT4},
{"outOffset", ANARI_FLOAT32_VEC4},
{0, ANARI_UNKNOWN}
};
return parameters;
Expand Down
6 changes: 3 additions & 3 deletions libs/helide/HelideDeviceQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6465,8 +6465,8 @@ static const void * ANARI_SAMPLER_transform_outOffset_info(ANARIDataType paramTy
return nullptr;
}
case 1: // default
if(paramType == ANARI_FLOAT32_MAT4 && infoType == ANARI_FLOAT32_MAT4) {
static const float default_value[16] = {0.000000f, 0.000000f, 0.000000f, 0.000000f};
if(paramType == ANARI_FLOAT32_VEC4 && infoType == ANARI_FLOAT32_VEC4) {
static const float default_value[4] = {0.000000f, 0.000000f, 0.000000f, 0.000000f};
return default_value;
} else {
return nullptr;
Expand Down Expand Up @@ -7845,7 +7845,7 @@ static const void * ANARI_SAMPLER_transform_info(int infoName, ANARIDataType inf
{"name", ANARI_STRING},
{"inAttribute", ANARI_STRING},
{"outTransform", ANARI_FLOAT32_MAT4},
{"outOffset", ANARI_FLOAT32_MAT4},
{"outOffset", ANARI_FLOAT32_VEC4},
{0, ANARI_UNKNOWN}
};
return parameters;
Expand Down
2 changes: 2 additions & 0 deletions libs/helide/camera/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void Camera::commit()
m_pos = getParam<float3>("position", float3(0.f));
m_dir = normalize(getParam<float3>("direction", float3(0.f, 0.f, 1.f)));
m_up = normalize(getParam<float3>("up", float3(0.f, 1.f, 0.f)));
m_imageRegion = float4(0.f, 0.f, 1.f, 1.f);
getParam("imageRegion", ANARI_FLOAT32_BOX2, &m_imageRegion);
markUpdated();
}

Expand Down
10 changes: 10 additions & 0 deletions libs/helide/camera/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ struct Camera : public Object

virtual Ray createRay(const float2 &screen) const = 0;

float4 imageRegion() const;

protected:
float3 m_pos;
float3 m_dir;
float3 m_up;
float4 m_imageRegion;
};

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

inline float4 Camera::imageRegion() const
{
return m_imageRegion;
}

} // namespace helide

HELIDE_ANARI_TYPEFOR_SPECIALIZATION(helide::Camera *, ANARI_CAMERA);
5 changes: 4 additions & 1 deletion libs/helide/frame/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ void Frame::renderFrame()
const auto &size = m_frameData.size;
embree::parallel_for(size.y, [&](int y) {
serial_for(size.x, [&](int x) {
const auto screen = screenFromPixel(float2(x, y));
auto screen = screenFromPixel(float2(x, y));
auto imageRegion = m_camera->imageRegion();
screen.x = linalg::lerp(imageRegion.x, imageRegion.z, screen.x);
screen.y = linalg::lerp(imageRegion.y, imageRegion.w, screen.y);
Ray ray = m_camera->createRay(screen);
writeSample(x, y, m_renderer->renderSample(screen, ray, *m_world));
});
Expand Down
23 changes: 11 additions & 12 deletions libs/helide/renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static float3 readAttributeValue(Attribute a, const Ray &r, const World &w)
return float3(v.x, v.y, v.z);
}

static float3 backgroundColorFromImage(
static float4 backgroundColorFromImage(
const Array2D &image, const float2 &screen)
{
const auto interp_x = getInterpolant(screen.x, image.size().x, true);
Expand All @@ -81,9 +81,7 @@ static float3 backgroundColorFromImage(
const auto v0 = linalg::lerp(v00, v01, interp_y.frac);
const auto v1 = linalg::lerp(v10, v11, interp_y.frac);

const auto v = linalg::lerp(v0, v1, interp_x.frac);

return float3(v.x, v.y, v.z);
return linalg::lerp(v0, v1, interp_x.frac);
}

// Renderer definitions ///////////////////////////////////////////////////////
Expand Down Expand Up @@ -139,9 +137,9 @@ PixelSample Renderer::renderSample(

// Shade //

const float3 color = shadeRay(screen, ray, vray, w);
const float4 color = shadeRay(screen, ray, vray, w);
const float depth = hitVolume ? std::min(ray.tfar, vray.t.lower) : ray.tfar;
return {float4(color, 1.f), depth};
return {color, depth};
}

Renderer *Renderer::createInstance(
Expand All @@ -150,20 +148,21 @@ Renderer *Renderer::createInstance(
return new Renderer(s);
}

float3 Renderer::shadeRay(const float2 &screen,
float4 Renderer::shadeRay(const float2 &screen,
const Ray &ray,
const VolumeRay &vray,
const World &w) const
{
const bool hitGeometry = ray.geomID != RTC_INVALID_GEOMETRY_ID;
const bool hitVolume = vray.volume != nullptr;

const float3 bgColor = m_bgImage
? backgroundColorFromImage(*m_bgImage, screen)
: float3(m_bgColor.x, m_bgColor.y, m_bgColor.z);
const float4 bgColorOpacity =
m_bgImage ? backgroundColorFromImage(*m_bgImage, screen) : m_bgColor;

if (!hitGeometry && !hitVolume)
return float3(bgColor.x, bgColor.y, bgColor.z);
return bgColorOpacity;

const float3 bgColor(bgColorOpacity.x, bgColorOpacity.y, bgColorOpacity.z);

float3 color(0.f, 0.f, 0.f);
float opacity = 0.f;
Expand Down Expand Up @@ -267,7 +266,7 @@ float3 Renderer::shadeRay(const float2 &screen,
color *= opacity;
accumulateValue(color, bgColor, opacity);

return color;
return {color, opacity};
}

} // namespace helide
Expand Down
2 changes: 1 addition & 1 deletion libs/helide/renderer/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct Renderer : public Object
std::string_view subtype, HelideGlobalState *d);

private:
float3 shadeRay(const float2 &screen,
float4 shadeRay(const float2 &screen,
const Ray &ray,
const VolumeRay &vray,
const World &w) const;
Expand Down
16 changes: 12 additions & 4 deletions libs/helide/scene/volume/TransferFunction1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ namespace helide {

TransferFunction1D::TransferFunction1D(HelideGlobalState *d) : Volume(d) {}

TransferFunction1D::~TransferFunction1D()
{
if (m_field)
m_field->removeCommitObserver(this);
}

void TransferFunction1D::commit()
{
if (m_field)
m_field->removeCommitObserver(this);

m_field = getParamObject<SpatialField>("field");
if (!m_field) {
reportMessage(ANARI_SEVERITY_WARNING,
"no spatial field provided to transferFunction1D volume");
return;
}

m_bounds = m_field ? m_field->bounds() : box3();

m_valueRange = getParam<box1>("valueRange", box1(0.f, 1.f));
m_invSize = 1.f / size(m_valueRange);

Expand All @@ -30,12 +37,13 @@ void TransferFunction1D::commit()
"no color data provided to transferFunction1D volume");
return;
}

if (!m_opacityData) {
reportMessage(ANARI_SEVERITY_WARNING,
"no opacity data provided to transfer function");
return;
}

m_field->addCommitObserver(this);
}

bool TransferFunction1D::isValid() const
Expand All @@ -45,7 +53,7 @@ bool TransferFunction1D::isValid() const

box3 TransferFunction1D::bounds() const
{
return m_bounds;
return m_field->bounds();
}

void TransferFunction1D::render(
Expand Down
3 changes: 1 addition & 2 deletions libs/helide/scene/volume/TransferFunction1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace helide {
struct TransferFunction1D : public Volume
{
TransferFunction1D(HelideGlobalState *d);
~TransferFunction1D() override;

void commit() override;

Expand All @@ -35,8 +36,6 @@ struct TransferFunction1D : public Volume

helium::IntrusivePtr<SpatialField> m_field;

box3 m_bounds;

box1 m_valueRange{0.f, 1.f};
float m_invSize{0.f};
float m_densityScale{1.f};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ float StructuredRegularField::sampleAt(const float3 &coord) const

box3 StructuredRegularField::bounds() const
{
return box3(m_origin, m_origin + ((float3(m_dims) - 1.f) * m_spacing));
return isValid()
? box3(m_origin, m_origin + ((float3(m_dims) - 1.f) * m_spacing))
: box3{};
}

float3 StructuredRegularField::objectToLocal(const float3 &object) const
Expand Down
20 changes: 10 additions & 10 deletions libs/helium/utility/AnariAny.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ inline AnariAny::AnariAny()

inline AnariAny::AnariAny(const AnariAny &copy)
{
reset();
std::memcpy(m_storage.data(), copy.m_storage.data(), m_storage.size());
m_string = copy.m_string;
m_type = copy.m_type;
Expand All @@ -93,15 +92,14 @@ inline AnariAny::AnariAny(const AnariAny &copy)

inline AnariAny::AnariAny(AnariAny &&tmp)
{
reset();
std::memcpy(m_storage.data(), tmp.m_storage.data(), m_storage.size());
m_string = std::move(tmp.m_string);
m_type = tmp.m_type;
tmp.m_type = ANARI_UNKNOWN;
}

template <typename T>
inline AnariAny::AnariAny(T value)
inline AnariAny::AnariAny(T value) : AnariAny()
{
constexpr auto type = anari::ANARITypeFor<T>::value;
static_assert(
Expand All @@ -116,15 +114,17 @@ inline AnariAny::AnariAny(T value)
refIncObject();
}

inline AnariAny::AnariAny(ANARIDataType type, const void *v)
inline AnariAny::AnariAny(ANARIDataType type, const void *v) : AnariAny()
{
m_type = type;
if (type == ANARI_STRING)
m_string = (const char *)v;
else if (type == ANARI_VOID_POINTER)
std::memcpy(m_storage.data(), &v, anari::sizeOf(type));
else
std::memcpy(m_storage.data(), v, anari::sizeOf(type));
if (v != nullptr) {
if (type == ANARI_STRING)
m_string = (const char *)v;
else if (type == ANARI_VOID_POINTER)
std::memcpy(m_storage.data(), &v, anari::sizeOf(type));
else
std::memcpy(m_storage.data(), v, anari::sizeOf(type));
}
refIncObject();
}

Expand Down
Loading

0 comments on commit 286e28b

Please sign in to comment.