Skip to content

OPAQUE Macro compiling on Windows #302

@nnn911

Description

@nnn911

When compiling VisRTX 0.13.0 on Windows I get the following error:

FAILED: devices/rtx/device/CMakeFiles/MatteShader_ptx.dir/material/shaders/MatteShader_ptx.ptx
C:\Work\proj-~2\NVIDIA~1\CUDA\v13.3\bin\nvcc.exe -forward-unknown-to-host-compiler -DGLM_ENABLE_EXPERIMENTAL -DNOMINMAX -D_USE_MATH_DEFINES -IC:\Work\proj-deps\VisRTX-0.13.0\build\devices\rtx\device -IC:\Work\proj-deps\VisRTX-0.13.0\devices\rtx\device -isystem C:\Work\proj-deps\anari\include -isystem C:\Work\proj-deps\anari\include\anari\backend -isystem C:\Work\proj-deps\VisRTX-0.13.0\build\deps\source\optix_headers\include -isystem "C:\Work\proj-deps\NVIDIA GPU Computing Toolkit\CUDA\v13.3\include" -isystem "C:\Work\proj-deps\NVIDIA GPU Computing Toolkit\CUDA\v13.3\include\cccl" -isystem C:\Work\proj-deps\VisRTX-0.13.0\devices\rtx\external\glm\include -isystem C:\Work\proj-deps\VisRTX-0.13.0\devices\rtx\device\..\external\nanovdb\include -Xcompiler=/Zc:preprocessor -Xcompiler="-O2 -Ob2" -DNDEBUG -std=c++17 "--generate-code=arch=compute_75,code=[compute_75]" -Xcompiler=-MD --expt-relaxed-constexpr --extended-lambda -Xcudafe=--diag_suppress=20012 -Wno-deprecated-gpu-targets -rdc=true --entries __direct__callable__evalSurfaceMaterial -MD -MT devices\rtx\device\CMakeFiles\MatteShader_ptx.dir\material\shaders\MatteShader_ptx.ptx -MF devices\rtx\device\CMakeFiles\MatteShader_ptx.dir\material\shaders\MatteShader_ptx.ptx.d -x cu -ptx C:\Work\proj-deps\VisRTX-0.13.0\devices\rtx\device\material\shaders\MatteShader_ptx.cu -o devices\rtx\device\CMakeFiles\MatteShader_ptx.dir\material\shaders\MatteShader_ptx.ptx -Xcompiler=-Fddevices\rtx\device\CMakeFiles\MatteShader_ptx.dir\,-FS

C:/Work/proj-deps/VisRTX-0.13.0/devices/rtx/device\gpu/evalMaterialParameters.h(47): error: expected an identifier
    if (mode == AlphaMode::2 )
                           ^

C:/Work/proj-deps/VisRTX-0.13.0/devices/rtx/device\gpu/evalMaterialParameters.h(47): error: expected a ")"
    if (mode == AlphaMode::2 )

I assume it happens because AlphaMode::OPAQUE is broken by the OPAQUE macro defined elsewhere:

// From evalMaterialParameters.h
VISRTX_DEVICE float adjustedMaterialOpacity(
    float opacityIn, AlphaMode mode, float cutoff)
{
  if (mode == AlphaMode::OPAQUE)
    return 1.f;
  else {
    if (mode == AlphaMode::BLEND)
      return opacityIn;
    else
      return opacityIn < cutoff ? 0.f : 1.f;
  }
}

One fix is to undefine OPAQUE before adjustedMaterialOpacity, however, I'm not sure if this has any unintended side effects.

#ifdef OPAQUE
#undef OPAQUE
#endif

System details:

MSVC

Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36246 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

NVCC

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Fri_Apr_24_19:26:09_Pacific_Daylight_Time_2026
Cuda compilation tools, release 13.3, V13.3.33
Build cuda_13.3.r13.3/compiler.37862127_0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions