Skip to content

Enable Metal in pointer test suite#958

Draft
jhelferty-nv wants to merge 9 commits into
shader-slang:mainfrom
jhelferty-nv:enable-metal-ptr
Draft

Enable Metal in pointer test suite#958
jhelferty-nv wants to merge 9 commits into
shader-slang:mainfrom
jhelferty-nv:enable-metal-ptr

Conversation

@jhelferty-nv
Copy link
Copy Markdown
Contributor

@jhelferty-nv jhelferty-nv commented Apr 25, 2026

Summary

  • Add SGL_LOCAL_RHI cmake option to build slang-rhi from a local checkout (mirrors SGL_LOCAL_SLANG)
  • Enable DeviceType.metal in POINTER_DEVICE_TYPES so pointer tests run on Metal hardware, exercising the slang-rhi argument buffer pointer data path
  • Disable & operator pointer tests on Metal (the & operator is being removed)

Fixes shader-slang/slang#10841.

TODO:

  • After slang-rhi#713 is merged, update the external/slang-rhi submodule pointer in this PR to include it.
  • After slang#10947 is merged and a new Slang release is cut, update the slangpy Slang version pointer to include it.

Test plan

  • Pointer tests pass on Metal with corresponding Slang and slang-rhi fixes
  • Existing non-Metal tests unaffected

Mirrors the existing SGL_LOCAL_SLANG option. When SGL_LOCAL_RHI=ON,
slang-rhi is built from SGL_LOCAL_RHI_DIR instead of the submodule.

Made-with: Cursor
Add DeviceType.metal to POINTER_DEVICE_TYPES so pointer tests run on
Metal hardware. This exercises the slang-rhi argument buffer pointer
data path that was previously broken (see shader-slang/slang#10841).

Made-with: Cursor
The `&` operator is intended to be removed soon, no point enabling
this for macos.
@jhelferty-nv jhelferty-nv requested a review from a team as a code owner April 25, 2026 01:20
@jhelferty-nv jhelferty-nv requested review from bmillsNV and removed request for a team April 25, 2026 01:20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0bda83f6-5c03-4429-b62c-eed9821bae8f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR extends documentation for local slang-rhi build configuration and implements configurable CMake support for building against a local slang-rhi source tree with conditional fallback logic. Additionally, pointer tests are parameterized to include Metal device type with selective device-specific skips.

Changes

Cohort / File(s) Summary
Build Configuration & Documentation
AGENTS.md, external/CMakeLists.txt
Added CMake cache variables (SGL_LOCAL_RHI, SGL_LOCAL_RHI_DIR) to enable local slang-rhi builds. Replaced unconditional subdirectory inclusion with conditional logic that uses local path when enabled or falls back to submodule. Updated shader-header copy to source from configurable SGL_RHI_SOURCE_DIR.
Test Coverage
slangpy/tests/slangpy_tests/test_pointers.py
Extended pointer test matrix to include Metal device type alongside Vulkan and CUDA. Added explicit Metal skip for test_atomic_float_in_struct_access due to operator& incompatibility.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • tomas-davidovic

Poem

🐰 A rabbit hops through code so bright,
New paths emerge for local builds just right,
Metal joins the testing spree,
Where Vulkan, CUDA, and logic dance free,
Configuration blooms where options take flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Enable Metal in pointer test suite' directly and concisely describes the main change: adding Metal device support to the pointer test suite, which is the primary objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
slangpy/tests/slangpy_tests/test_pointers.py (1)

594-596: Skip looks correct; consider pytest.mark.skipif for clarity.

The runtime skip is fine and matches the shader on Line 609 which uses &buffer[call_id%10].value. As an optional refactor, @pytest.mark.skipif(... , reason=...) keeps the gating with the parametrize decorators rather than at the top of the body, but the current form is consistent with other conditional skips in the file (e.g. Line 768).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@slangpy/tests/slangpy_tests/test_pointers.py` around lines 594 - 596, The
test test_atomic_float_in_struct_access currently performs a runtime skip for
DeviceType.metal; replace this with a pytest.mark.skipif decorator on the test
to make the gating declarative — use pytest.mark.skipif(device_type ==
DeviceType.metal, reason="operator& is not supported on Metal and is being
removed from Slang") so the skip is applied at collection time and sits
alongside the parametrize decorators rather than inside the test body.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@slangpy/tests/slangpy_tests/test_pointers.py`:
- Around line 594-596: The test test_atomic_float_in_struct_access currently
performs a runtime skip for DeviceType.metal; replace this with a
pytest.mark.skipif decorator on the test to make the gating declarative — use
pytest.mark.skipif(device_type == DeviceType.metal, reason="operator& is not
supported on Metal and is being removed from Slang") so the skip is applied at
collection time and sits alongside the parametrize decorators rather than inside
the test body.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98031c6c-d460-452a-8a05-3264573b42b3

📥 Commits

Reviewing files that changed from the base of the PR and between fe1d16b and d0aabdb.

📒 Files selected for processing (3)
  • AGENTS.md
  • external/CMakeLists.txt
  • slangpy/tests/slangpy_tests/test_pointers.py

Updates external/slang-rhi to a7e218ee which includes Metal residency
tracking and GPU address support needed for pointer operations.

Made-with: Cursor
Sync the Feature enum with slang-rhi after the addition of
Feature::ResidencySet, fixing a static_assert size mismatch.

Made-with: Cursor
The underlying crash ("invalid reflection data") appears to have been
fixed by upstream slang-rhi changes. Verified passing on both the
MTLResidencySet and useResources fallback paths.

Made-with: Cursor
Comment thread external/CMakeLists.txt
Comment on lines 218 to +238
@@ -226,10 +229,16 @@ set(SLANG_RHI_BUILD_FROM_SLANG_REPO ON)
set(SLANG_RHI_FETCH_SLANG OFF)
set(SLANG_RHI_SLANG_INCLUDE_DIR ${SLANG_INCLUDE_DIR} CACHE STRING "" FORCE)
set(SLANG_RHI_SLANG_BINARY_DIR ${SLANG_DIR} CACHE STRING "" FORCE)
add_subdirectory(slang-rhi)
if(SGL_LOCAL_RHI)
add_subdirectory(${SGL_LOCAL_RHI_DIR} ${CMAKE_BINARY_DIR}/slang-rhi)
set(SGL_RHI_SOURCE_DIR ${SGL_LOCAL_RHI_DIR})
else()
add_subdirectory(slang-rhi)
set(SGL_RHI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/slang-rhi)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably rename these to SGL_LOCAL_SLANG_RHI and SGL_LOCAL_SLANG_RHI_DIR to be more consistent with SGL_LOCAL_SLANG. Also rename SGL_RHI_SOURCE_DIR to SGL_SLANG_RHI_SOURCE_DIR

Copy link
Copy Markdown
Contributor

@ccummingsNV ccummingsNV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the twaks Simon proposes, and need to look at fixing the tests

@jhelferty-nv jhelferty-nv marked this pull request as draft May 5, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metal pointer failure

3 participants