Skip to content

Commit 20136d9

Browse files
committed
Merge branch 'next_release'
2 parents e688375 + eb185ec commit 20136d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4524
-2015
lines changed

CHANGELOG.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2828
# POSSIBILITY OF SUCH DAMAGE.
2929

30-
cmake_minimum_required(VERSION 3.23)
30+
cmake_minimum_required(VERSION 3.17)
3131

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

@@ -46,7 +46,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
4646
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
4747
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
4848

49-
project(VisRTX VERSION 0.7.1 LANGUAGES C CXX)
49+
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
50+
if (CMAKE_VERSION VERSION_LESS "3.23")
51+
set(CMAKE_CUDA_ARCHITECTURES OFF)
52+
endif()
53+
endif()
54+
55+
project(VisRTX VERSION 0.8.0 LANGUAGES C CXX)
5056

5157
include(GNUInstallDirs)
5258

@@ -70,7 +76,7 @@ endif()
7076
## Dependencies ###############################################################
7177

7278
# ANARI-SDK
73-
set(ANARI_REQUIRED_VERSION 0.8.0)
79+
set(ANARI_REQUIRED_VERSION 0.9.0)
7480
find_package(anari ${ANARI_REQUIRED_VERSION} REQUIRED)
7581

7682
# CUDA

README.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ provided extensions, and known missing extensions to add in the future.
7575

7676
## Queryable ANARI Extensions
7777

78-
In addition to standard `ANARI_KHR` extensions, the following vendor extensions
79-
are also implemented in the `visrtx` device. Note that all vendor extensions are
80-
subject to change
78+
In addition to standard `ANARI_KHR` extensions, the following extensions are
79+
also implemented in the `visrtx` device. Note that all extensions are subject to
80+
change
8181

8282
#### "VISRTX_CUDA_OUTPUT_BUFFERS"
8383

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

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

95-
#### "VISRTX_TRIANGLE_ATTRIBUTE_INDEXING" (experimental)
95+
#### "VISRTX_UNIFORM_ATTRIBUTES" (experimental)
9696

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

101-
- `vertex.color.index`
102-
- `vertex.normal.index`
103-
- `vertex.attribute0.index`
104-
- `vertex.attribute1.index`
105-
- `vertex.attribute2.index`
106-
- `vertex.attribute3.index`
100+
#### "VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES" (experimental)
107101

108-
Each of these arrays must be of type `UINT32_VEC3` and is indexed per-triangle
109-
on the geometry where each component indexes into the corresponding index array
110-
that matches. For example, `vertex.color.index` for primitive 0 (first triangle)
111-
will load values from `vertex.color` accordingly. For every `.index` array
112-
present, the matching vertex array must also be present. All index values must
113-
be within the size of the corresponding vertex array it accesses.
102+
This extension indicates that additional attribute mappings are available for
103+
the `triangle` geometry subtype. Specifically, the following face-unique vertex
104+
attribute arrays can be specified:
105+
106+
- `faceVarying.normal`
107+
- `faceVarying.color`
108+
- `faceVarying.attribute0`
109+
- `faceVarying.attribute1`
110+
- `faceVarying.attribute2`
111+
- `faceVarying.attribute3`
112+
113+
Each `faceVarying` attribute array is indexed by 3 * `primID` + `{0, 1, 2}`,
114+
giving each triangle primitive a unique set of 3 vertex attributes. This follows
115+
the USD definition of "face-varying" interpolated primvars.
116+
117+
If a `faceVarying` attribute array is present, it takes precedence over `vertex`
118+
and `primitive` attribute arrays when they are also present.
114119

115120
## Additional ANARI Parameter and Property Extensions
116121

@@ -175,7 +180,8 @@ The following extensions are either partially or fully implemented by VisRTX:
175180
- `KHR_SPATIAL_FIELD_STRUCTURED_REGULAR`
176181
- `KHR_VOLUME_TRANSFER_FUNCTION1D`
177182
- `VISRTX_CUDA_OUTPUT_BUFFERS`
178-
- `VISRTX_TRIANGLE_ATTRIBUTE_INDEXING`
183+
- `VISRTX_TRIANGLE_FACE_VARYING_ATTRIBUTES`
184+
- `VISRTX_UNIFORM_ATTRIBUTES`
179185

180186
For any found bugs in extensions that are implemented, please [open an
181187
issue](https://github.com/NVIDIA/VisRTX/issues/new)!

cmake/EmbedPTX.cmake

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,12 @@ function(EmbedPTX)
4242
endif()
4343

4444
get_target_property(PTX_PROP ${EMBED_PTX_INPUT_TARGET} CUDA_PTX_COMPILATION)
45-
if (NOT PTX_PROP)
45+
get_target_property(OPTIX_PROP ${EMBED_PTX_INPUT_TARGET} CUDA_OPTIX_COMPILATION)
46+
if (NOT PTX_PROP AND NOT OPTIX_PROP)
4647
message(FATAL_ERROR "'${EMBED_PTX_INPUT_TARGET}' target property 'CUDA_PTX_COMPILATION' must be set to 'ON'")
4748
endif()
4849

49-
## Find bin2c and CMake script to feed it ##
50-
51-
# We need to wrap bin2c with a script for multiple reasons:
52-
# 1. bin2c only converts a single file at a time
53-
# 2. bin2c has only standard out support, so we have to manually redirect to
54-
# a cmake buffer
55-
# 3. We want to pack everything into a single output file, so we need to use
56-
# the --name option
57-
58-
get_filename_component(CUDA_COMPILER_BIN "${CMAKE_CUDA_COMPILER}" DIRECTORY)
59-
find_program(BIN_TO_C NAMES bin2c PATHS ${CUDA_COMPILER_BIN})
60-
mark_as_advanced(BIN_TO_C)
61-
if(NOT BIN_TO_C)
62-
message(FATAL_ERROR
63-
"bin2c not found:\n"
64-
" CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'\n"
65-
" CUDA_COMPILER_BIN='${CUDA_COMPILER_BIN}'\n"
66-
)
67-
endif()
50+
## Find EmbedPTXRun CMake script ##
6851

6952
set(CMAKE_PREFIX_PATH ${CMAKE_MODULE_PATH})
7053
find_file(EMBED_PTX_RUN EmbedPTXRun.cmake)

cmake/EmbedPTXRun.cmake

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,33 @@
3131

3232
unset(file_contents)
3333

34+
string(APPEND file_contents "/* Autogenerated by EmbedPTX */\n\n")
35+
3436
foreach(obj ${OBJECTS})
3537
get_filename_component(obj_ext ${obj} EXT)
3638
get_filename_component(obj_name ${obj} NAME_WE)
3739
get_filename_component(obj_dir ${obj} DIRECTORY)
3840

39-
if(obj_ext MATCHES ".ptx")
40-
set(args --name ${obj_name} ${obj} --padd 0,0)
41-
execute_process(
42-
COMMAND "${BIN_TO_C_COMMAND}" ${args}
43-
WORKING_DIRECTORY ${obj_dir}
44-
RESULT_VARIABLE result
45-
OUTPUT_VARIABLE output
46-
ERROR_VARIABLE error_var
47-
)
48-
set(file_contents "${file_contents} \n${output}")
41+
if(obj_ext MATCHES ".ptx" OR obj_ext MATCHES ".optixir")
42+
# Read file contents as hex data
43+
file(READ ${obj} filedata HEX)
44+
45+
# Calculate the number of bytes
46+
string(LENGTH ${filedata} len)
47+
math(EXPR numBytes "${len} / 2")
48+
49+
# Convert hex data for C compatibility
50+
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})
51+
52+
# Get rid of the last comma
53+
string(LENGTH ${filedata} len)
54+
math(EXPR len "${len} - 1")
55+
string(SUBSTRING "${filedata}" 0 ${len} filedata)
56+
57+
# Append data to file
58+
string(APPEND file_contents "unsigned char ${obj_name}[${numBytes}] = {\n")
59+
string(APPEND file_contents "${filedata}\n")
60+
string(APPEND file_contents "};\n\n")
4961
endif()
5062
endforeach()
5163

devices/gl/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ PUBLIC
100100
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glad/include>
101101
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/egl>
102102
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glx>
103+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/wgl>
103104
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
104105
)
105106

@@ -110,10 +111,18 @@ PUBLIC
110111
)
111112

112113
if(WIN32)
114+
target_sources(${PROJECT_NAME} PRIVATE
115+
src/wgl/wgl_context.cpp
116+
src/glad/src/wgl.c
117+
)
113118
target_link_libraries(${PROJECT_NAME}
114119
PUBLIC
115120
OpenGL::GL
116121
)
122+
target_compile_definitions(${PROJECT_NAME}
123+
PUBLIC
124+
VISGL_USE_WGL
125+
)
117126
else()
118127
target_link_libraries(${PROJECT_NAME}
119128
PUBLIC

devices/gl/src/VisGLDeviceObject.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#include "glx_context.h"
4848
#endif
4949

50+
51+
#ifdef VISGL_USE_WGL
52+
#include "wgl_context.h"
53+
#endif
5054
namespace visgl {
5155

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

128132
if (debug && deviceObj->gl.DebugMessageCallback) {
133+
anariReportStatus(deviceObj->device,
134+
deviceObj->handle,
135+
ANARI_DEVICE,
136+
ANARI_SEVERITY_INFO,
137+
ANARI_STATUS_NO_ERROR,
138+
"[OpenGL] setup debug callback\n");
129139
gl.DebugMessageCallback(debug_callback, deviceObj->device);
140+
gl.DebugMessageInsert(
141+
GL_DEBUG_SOURCE_APPLICATION,
142+
GL_DEBUG_TYPE_OTHER,
143+
0,
144+
GL_DEBUG_SEVERITY_NOTIFICATION,
145+
-1, "test message callback.");
130146
}
131147

132148
anariReportStatus(deviceObj->device,
@@ -216,6 +232,13 @@ void Object<Device>::update()
216232
}
217233
#endif
218234

235+
#ifdef VISGL_USE_WGL
236+
HDC dc = wglGetCurrentDC();
237+
HGLRC wgl_context = wglGetCurrentContext();
238+
context.reset(new wglContext(
239+
device, dc, wgl_context, clientapi == STRING_ENUM_OpenGL_ES, debug));
240+
#endif
241+
219242
queue.enqueue(device_context_init, this, clientapi, debug).wait();
220243
}
221244

devices/gl/src/VisGLFrameObject.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ void frame_render(ObjectRef<Frame> frameObj,
896896
gl.ActiveTexture(GL_TEXTURE0 + 1);
897897
gl.BindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameObj->multidepthtarget);
898898

899+
gl.Disable(GL_CULL_FACE);
899900
gl.BindVertexArray(frameObj->resolve_vao);
900901
gl.Disable(GL_DEPTH_TEST);
901902
gl.DrawArrays(GL_TRIANGLES, 0, 3);

0 commit comments

Comments
 (0)