Repository navigation
nvrhi::IMessageCallback implemented in tslang (needs TypeScriptCompiler #554 released) - #39
Merged
Merged
Conversation
…rhi_direct nvrhi.IMessageCallback is bound in both ABI files (one / two destructor slots, checked by check_nvrhi_slots.py), with IDevice::getMessageCallback and the MESSAGE_SEVERITY_* values. A @cppvtable class extending it whose message() has a body is an object NVRHI calls through the vtable tslang makes (a tslang newer than pre-alpha94: TypeScriptCompiler's C++ method implementations). - Donut_SetNvrhiMessageCallback: the devices made after it get the callback (DeviceCreationParameters::messageCallback, which a Donut patch makes Vulkan and D3D11 use too, as D3D12 does); Donut_LogNvrhiMessage passes a message on to Donut's handling. - nvrhi_direct's MessageLog: checks the device's getMessageCallback() is it, and with -debug provokes a validation error (closing a command list never opened) that NVRHI reports to it; every other message goes on to Donut's log, so CTest still fails on validation errors. Tested with a local tslang (main + TypeScriptCompiler #553 + the implementations): Windows CTest headless/nvrhi_direct dx12+vk with -debug pass, a provoked message expected under another text fails the test; JIT too; Android x86_64 emulator nvrhi_direct and headless pass (getMessageCallback only: no validation layer there); arm64 builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NVRHI reports messages through
nvrhi::IMessageCallback, an interface the application implements. This PR implements it in tslang: a@cppvtableclass extendingnvrhi.IMessageCallbackwhosemessage()has a body. tslang builds the C++ vtable for it (#554), and NVRHI calls it like a C++ object.Changes
Bindings:
nvrhi.IMessageCallbackin both ABI files:_destructor,message;_completeDestructor,_deletingDestructor,message.IDevice::getMessageCallbackis bound (slot 71 win32 / 72 linux), andMESSAGE_SEVERITY_*values are added.tools/check_nvrhi_slots.pychecksIMessageCallbacktoo: both ABIs match.Donut patch
Donut-message-callback-all-apis:DeviceCreationParameters::messageCallbackis now used on Vulkan and D3D11, as D3D12 already does. It applies cleanly after the other patches, both on a clean Donut checkout and on the already-patched submodule.Interop:
Donut_SetNvrhiMessageCallback(callback): the devices created afterwards get this callback (null restores Donut's).Donut_LogNvrhiMessage(severity, text): Donut's own handling (logs; Fatal ends the program), for a callback that passes messages on.check_interop_types.py: the callback pointer is listed as raw memory, likeDonut_GetNvrhiDevice's.nvrhi_direct:MessageLog:device.getMessageCallback()is the object implemented here;-debug, closes a command list that was never opened. The validation layer reports that as an error and does nothing else, and the test checks NVRHI delivered it toMessageLog;Docs:
core/nvrhi.tsheader and README.Testing
All runs used a local tslang built from main plus #554:
-debugheadless.dx12/.vk,headless.donut.dx12/.vkandnvrhi_direct.dx12/.vkpass. A mutated copy that expects a different message text fails, as it should: the provoked error reached Donut's log, and the check reported NVRHI didn't callMessageLognvrhi_directpassesnvrhi_directandheadlesspass. That coversgetMessageCallback()only: the emulator has no validation layer, somessage()isn't provoked there. The C++-to-tslang call under the Itanium ABI is covered by #554's g++ test🤖 Generated with Claude Code