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 Mar 21, 2024
2 parents e688375 + eb185ec commit 20136d9
Show file tree
Hide file tree
Showing 92 changed files with 4,524 additions and 2,015 deletions.
102 changes: 0 additions & 102 deletions CHANGELOG.md

This file was deleted.

12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required(VERSION 3.23)
cmake_minimum_required(VERSION 3.17)

message(STATUS "CMake version: ${CMAKE_VERSION}")

Expand All @@ -46,7 +46,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

project(VisRTX VERSION 0.7.1 LANGUAGES C CXX)
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
if (CMAKE_VERSION VERSION_LESS "3.23")
set(CMAKE_CUDA_ARCHITECTURES OFF)
endif()
endif()

project(VisRTX VERSION 0.8.0 LANGUAGES C CXX)

include(GNUInstallDirs)

Expand All @@ -70,7 +76,7 @@ endif()
## Dependencies ###############################################################

# ANARI-SDK
set(ANARI_REQUIRED_VERSION 0.8.0)
set(ANARI_REQUIRED_VERSION 0.9.0)
find_package(anari ${ANARI_REQUIRED_VERSION} REQUIRED)

# CUDA
Expand Down
52 changes: 29 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ provided extensions, and known missing extensions to add in the future.

## Queryable ANARI Extensions

In addition to standard `ANARI_KHR` extensions, the following vendor extensions
are also implemented in the `visrtx` device. Note that all vendor extensions are
subject to change
In addition to standard `ANARI_KHR` extensions, the following extensions are
also implemented in the `visrtx` device. Note that all extensions are subject to
change

#### "VISRTX_CUDA_OUTPUT_BUFFERS"

This vendor extension indicates that raw CUDA GPU buffers from frame objects can
be mapped for applications which are already using CUDA. The following
additional channels can be mapped:
This extension indicates that raw CUDA GPU buffers from frame objects can be
mapped for applications which are already using CUDA. The following additional
channels can be mapped:

- `"colorGPU"`
- `"depthGPU"`
Expand All @@ -92,25 +92,30 @@ GPU pointers returned by `anariMapFrame()` are device pointers intended to be
kept on the device. Applications which desire to copy data from the device back
to the host should instead map the ordinary `color` and `depth` channels.

#### "VISRTX_TRIANGLE_ATTRIBUTE_INDEXING" (experimental)
#### "VISRTX_UNIFORM_ATTRIBUTES" (experimental)

This vendor extension indicates that additional attribute indexing is
available for the `triangle` geometry subtype. Specifically, the following
additional index arrays will be interpreted if set on the geometry:
This extension indicates that all attributes can be set as a single
`ANARI_FLOAT32_VEC4` value, which is constant over the entire geometry.

- `vertex.color.index`
- `vertex.normal.index`
- `vertex.attribute0.index`
- `vertex.attribute1.index`
- `vertex.attribute2.index`
- `vertex.attribute3.index`
#### "VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES" (experimental)

Each of these arrays must be of type `UINT32_VEC3` and is indexed per-triangle
on the geometry where each component indexes into the corresponding index array
that matches. For example, `vertex.color.index` for primitive 0 (first triangle)
will load values from `vertex.color` accordingly. For every `.index` array
present, the matching vertex array must also be present. All index values must
be within the size of the corresponding vertex array it accesses.
This extension indicates that additional attribute mappings are available for
the `triangle` geometry subtype. Specifically, the following face-unique vertex
attribute arrays can be specified:

- `faceVarying.normal`
- `faceVarying.color`
- `faceVarying.attribute0`
- `faceVarying.attribute1`
- `faceVarying.attribute2`
- `faceVarying.attribute3`

Each `faceVarying` attribute array is indexed by 3 * `primID` + `{0, 1, 2}`,
giving each triangle primitive a unique set of 3 vertex attributes. This follows
the USD definition of "face-varying" interpolated primvars.

If a `faceVarying` attribute array is present, it takes precedence over `vertex`
and `primitive` attribute arrays when they are also present.

## Additional ANARI Parameter and Property Extensions

Expand Down Expand Up @@ -175,7 +180,8 @@ The following extensions are either partially or fully implemented by VisRTX:
- `KHR_SPATIAL_FIELD_STRUCTURED_REGULAR`
- `KHR_VOLUME_TRANSFER_FUNCTION1D`
- `VISRTX_CUDA_OUTPUT_BUFFERS`
- `VISRTX_TRIANGLE_ATTRIBUTE_INDEXING`
- `VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES`
- `VISRTX_UNIFORM_ATTRIBUTES`

For any found bugs in extensions that are implemented, please [open an
issue](https://github.com/NVIDIA/VisRTX/issues/new)!
23 changes: 3 additions & 20 deletions cmake/EmbedPTX.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,12 @@ function(EmbedPTX)
endif()

get_target_property(PTX_PROP ${EMBED_PTX_INPUT_TARGET} CUDA_PTX_COMPILATION)
if (NOT PTX_PROP)
get_target_property(OPTIX_PROP ${EMBED_PTX_INPUT_TARGET} CUDA_OPTIX_COMPILATION)
if (NOT PTX_PROP AND NOT OPTIX_PROP)
message(FATAL_ERROR "'${EMBED_PTX_INPUT_TARGET}' target property 'CUDA_PTX_COMPILATION' must be set to 'ON'")
endif()

## Find bin2c and CMake script to feed it ##

# We need to wrap bin2c with a script for multiple reasons:
# 1. bin2c only converts a single file at a time
# 2. bin2c has only standard out support, so we have to manually redirect to
# a cmake buffer
# 3. We want to pack everything into a single output file, so we need to use
# the --name option

get_filename_component(CUDA_COMPILER_BIN "${CMAKE_CUDA_COMPILER}" DIRECTORY)
find_program(BIN_TO_C NAMES bin2c PATHS ${CUDA_COMPILER_BIN})
mark_as_advanced(BIN_TO_C)
if(NOT BIN_TO_C)
message(FATAL_ERROR
"bin2c not found:\n"
" CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'\n"
" CUDA_COMPILER_BIN='${CUDA_COMPILER_BIN}'\n"
)
endif()
## Find EmbedPTXRun CMake script ##

set(CMAKE_PREFIX_PATH ${CMAKE_MODULE_PATH})
find_file(EMBED_PTX_RUN EmbedPTXRun.cmake)
Expand Down
32 changes: 22 additions & 10 deletions cmake/EmbedPTXRun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,33 @@

unset(file_contents)

string(APPEND file_contents "/* Autogenerated by EmbedPTX */\n\n")

foreach(obj ${OBJECTS})
get_filename_component(obj_ext ${obj} EXT)
get_filename_component(obj_name ${obj} NAME_WE)
get_filename_component(obj_dir ${obj} DIRECTORY)

if(obj_ext MATCHES ".ptx")
set(args --name ${obj_name} ${obj} --padd 0,0)
execute_process(
COMMAND "${BIN_TO_C_COMMAND}" ${args}
WORKING_DIRECTORY ${obj_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error_var
)
set(file_contents "${file_contents} \n${output}")
if(obj_ext MATCHES ".ptx" OR obj_ext MATCHES ".optixir")
# Read file contents as hex data
file(READ ${obj} filedata HEX)

# Calculate the number of bytes
string(LENGTH ${filedata} len)
math(EXPR numBytes "${len} / 2")

# Convert hex data for C compatibility
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})

# Get rid of the last comma
string(LENGTH ${filedata} len)
math(EXPR len "${len} - 1")
string(SUBSTRING "${filedata}" 0 ${len} filedata)

# Append data to file
string(APPEND file_contents "unsigned char ${obj_name}[${numBytes}] = {\n")
string(APPEND file_contents "${filedata}\n")
string(APPEND file_contents "};\n\n")
endif()
endforeach()

Expand Down
9 changes: 9 additions & 0 deletions devices/gl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glad/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/egl>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glx>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/wgl>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)

Expand All @@ -110,10 +111,18 @@ PUBLIC
)

if(WIN32)
target_sources(${PROJECT_NAME} PRIVATE
src/wgl/wgl_context.cpp
src/glad/src/wgl.c
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
OpenGL::GL
)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
VISGL_USE_WGL
)
else()
target_link_libraries(${PROJECT_NAME}
PUBLIC
Expand Down
23 changes: 23 additions & 0 deletions devices/gl/src/VisGLDeviceObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#include "glx_context.h"
#endif


#ifdef VISGL_USE_WGL
#include "wgl_context.h"
#endif
namespace visgl {

Object<Device>::Object(ANARIDevice d) : DefaultObject(d, this), queue(128) {}
Expand Down Expand Up @@ -126,7 +130,19 @@ static void device_context_init(
}

if (debug && deviceObj->gl.DebugMessageCallback) {
anariReportStatus(deviceObj->device,
deviceObj->handle,
ANARI_DEVICE,
ANARI_SEVERITY_INFO,
ANARI_STATUS_NO_ERROR,
"[OpenGL] setup debug callback\n");
gl.DebugMessageCallback(debug_callback, deviceObj->device);
gl.DebugMessageInsert(
GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_OTHER,
0,
GL_DEBUG_SEVERITY_NOTIFICATION,
-1, "test message callback.");
}

anariReportStatus(deviceObj->device,
Expand Down Expand Up @@ -216,6 +232,13 @@ void Object<Device>::update()
}
#endif

#ifdef VISGL_USE_WGL
HDC dc = wglGetCurrentDC();
HGLRC wgl_context = wglGetCurrentContext();
context.reset(new wglContext(
device, dc, wgl_context, clientapi == STRING_ENUM_OpenGL_ES, debug));
#endif

queue.enqueue(device_context_init, this, clientapi, debug).wait();
}

Expand Down
1 change: 1 addition & 0 deletions devices/gl/src/VisGLFrameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ void frame_render(ObjectRef<Frame> frameObj,
gl.ActiveTexture(GL_TEXTURE0 + 1);
gl.BindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameObj->multidepthtarget);

gl.Disable(GL_CULL_FACE);
gl.BindVertexArray(frameObj->resolve_vao);
gl.Disable(GL_DEPTH_TEST);
gl.DrawArrays(GL_TRIANGLES, 0, 3);
Expand Down
Loading

0 comments on commit 20136d9

Please sign in to comment.