Skip to content

Commit 9147302

Browse files
MarijnS95claude
andcommitted
Bind acceleration structures and enable the InlineRT tests
Wire up acceleration-structure descriptor binding end-to-end across all three backends so shaders can actually consume the TLAS that buildPipelineAccelerationStructures produced — completing the stack and promoting the three InlineRT tests from XFAIL to passing. Vulkan: createDescriptorPool counts AS descriptors in a separate scalar (the KHR enum value 1000150000 doesn't fit in the indexed array used for the core types) and emits one VkDescriptorPoolSize for them. createDescriptorSets resolves each AS resource via Resource::TLASPtr, locates the matching VulkanAccelerationStructure in InvocationState::AccelStructs (BLASes-then-TLASes layout, matching the helper's documented declaration order), and writes the handle through a VkWriteDescriptorSetAccelerationStructureKHR chained on the descriptor write's pNext. The dispatch's pre-barrier dst access now includes VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR so the prior AS-build's writes are made visible to the shader's RayQuery reads. Device creation also enables VK_KHR_ray_query when supported so the RayQuery shader instructions actually function. DX12: writes a D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE SRV with the AS GPU virtual address as Location into the heap slot that createBuffers reserved (CreateShaderResourceView with a null resource — the AS data lives in the buffer pointed to by Location). Metal: the Metal shader converter doesn't bind the AS directly; the shader reads a buffer containing an IRRaytracingAccelerationStructure- GPUHeader that holds the AS's gpuResourceID plus a pointer to an instance-contributions array. createBuffers allocates and fills both buffers per AS-descriptor entry, then points the descriptor at the header buffer's GPU address. The TLAS itself is built with the UserID instance-descriptor variant so HLSL CommittedInstanceID() returns the YAML-specified per-instance ID instead of the array index. The three InlineRT tests now actually exercise the AS end-to-end: TraceRayInline issues a RayQuery against `Scene` and writes a hit-dependent value into `Output` (the instance ID for multi-instance, 1/0 otherwise). The catch-all `XFAIL: *` is dropped; `XFAIL: Clang` remains. The test shaders gain explicit `[[vk::binding]]` annotations since their `t0`/`u0` registers would otherwise collide under the default dxc HLSL→SPIR-V mapping. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0089566 commit 9147302

6 files changed

Lines changed: 201 additions & 39 deletions

File tree

lib/API/DX/Device.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,12 +2251,33 @@ class DXDevice : public offloadtest::Device {
22512251

22522252
// Bind descriptors in descriptor tables.
22532253
uint32_t HeapIndex = 0;
2254+
const uint32_t DescIncSize = Device->GetDescriptorHandleIncrementSize(
2255+
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
22542256
for (auto &T : IS.DescTables) {
22552257
for (auto &R : T.Resources) {
2256-
// AS descriptor binding lands in the AS-bind commit; this loop runs
2257-
// its dedicated path then continues. Advance HeapIndex so subsequent
2258-
// resources land in the slots the shader's root signature expects.
22592258
if (R.first->isAccelerationStructure()) {
2259+
assert(R.first->TLASPtr && "AS resource must be resolved to a TLAS");
2260+
assert(R.first->getArraySize() == 1 && "AS arrays not yet supported");
2261+
// OutAS layout from buildPipelineAccelerationStructures: BLASes
2262+
// first, then TLASes — both in P.AccelStructs declaration order.
2263+
const size_t TLASIdx = R.first->TLASPtr - &P.AccelStructs.TLAS[0];
2264+
const size_t ASIdx = P.AccelStructs.BLAS.size() + TLASIdx;
2265+
auto *DXAS =
2266+
llvm::cast<DXAccelerationStructure>(IS.AccelStructs[ASIdx].get());
2267+
D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
2268+
SRVDesc.Format = DXGI_FORMAT_UNKNOWN;
2269+
SRVDesc.ViewDimension =
2270+
D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE;
2271+
SRVDesc.Shader4ComponentMapping =
2272+
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
2273+
SRVDesc.RaytracingAccelerationStructure.Location =
2274+
DXAS->getGPUVirtualAddress();
2275+
D3D12_CPU_DESCRIPTOR_HANDLE Handle =
2276+
IS.DescHeap->GetCPUDescriptorHandleForHeapStart();
2277+
Handle.ptr += HeapIndex * DescIncSize;
2278+
// AS SRVs are created with a null resource; the AS lives in the
2279+
// buffer referenced by Location.
2280+
Device->CreateShaderResourceView(nullptr, &SRVDesc, Handle);
22602281
HeapIndex += R.first->getArraySize();
22612282
continue;
22622283
}

lib/API/MTL/MTLDevice.cpp

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#define IR_PRIVATE_IMPLEMENTATION
1818
#include "metal_irconverter.h"
1919
#include "metal_irconverter_runtime.h"
20+
// ir_raytracing.h depends on types defined in metal_irconverter_runtime.h —
21+
// keep this include in its own block so clang-format won't sort it above.
22+
#include "ir_raytracing.h"
2023

2124
#include "API/Device.h"
2225
#include "API/Encoder.h"
@@ -962,6 +965,10 @@ class MTLDevice : public offloadtest::Device {
962965
AccelStructs;
963966
// Vertex/index buffers consumed during AS builds; must outlive submission.
964967
llvm::SmallVector<std::unique_ptr<offloadtest::Buffer>> ASInputBuffers;
968+
// Per-AS-descriptor header + instance-contribution buffers backing inline
969+
// RT bindings; must be resident on the dispatch encoder so the shader can
970+
// read the header.
971+
llvm::SmallVector<MTL::Buffer *> ASDescriptorBuffers;
965972
};
966973

967974
llvm::Error createRootSignature(
@@ -1349,10 +1356,48 @@ class MTLDevice : public offloadtest::Device {
13491356
uint32_t HeapIndex = 0;
13501357
for (auto &T : IS.DescTables) {
13511358
for (auto &R : T.Resources) {
1352-
// AS descriptor binding lands in the AS-bind commit; this loop runs
1353-
// its dedicated path then continues. Advance HeapIndex so subsequent
1354-
// resources land in the slots the shader's argument buffer expects.
13551359
if (R.first->isAccelerationStructure()) {
1360+
assert(R.first->TLASPtr && "AS resource must be resolved to a TLAS");
1361+
assert(R.first->getArraySize() == 1 && "AS arrays not yet supported");
1362+
// OutAS layout from buildPipelineAccelerationStructures:
1363+
// BLASes first, then TLASes — both in declaration order.
1364+
const size_t TLASIdx = R.first->TLASPtr - &P.AccelStructs.TLAS[0];
1365+
const size_t ASIdx = P.AccelStructs.BLAS.size() + TLASIdx;
1366+
auto *MTLAS = llvm::cast<MetalAccelerationStructure>(
1367+
IS.AccelStructs[ASIdx].get());
1368+
1369+
// Metal shader converter doesn't bind the AS directly; the shader
1370+
// reads a buffer containing an IRRaytracingAccelerationStructureGPU-
1371+
// Header that holds the AS's gpuResourceID plus a pointer to an
1372+
// instance-contributions array (one uint32 per instance, supplying
1373+
// the equivalent of D3D12's InstanceContributionToHitGroupIndex).
1374+
// Build both buffers here and point the descriptor entry at the
1375+
// header buffer's GPU address.
1376+
const uint32_t InstCount =
1377+
static_cast<uint32_t>(R.first->TLASPtr->Instances.size());
1378+
llvm::SmallVector<uint32_t> Contributions(InstCount, 0);
1379+
MTL::Buffer *ContribBuf = Device->newBuffer(
1380+
Contributions.data(), InstCount * sizeof(uint32_t),
1381+
MTL::ResourceStorageModeShared);
1382+
MTL::Buffer *HeaderBuf = Device->newBuffer(
1383+
sizeof(IRRaytracingAccelerationStructureGPUHeader),
1384+
MTL::ResourceStorageModeShared);
1385+
IRRaytracingSetAccelerationStructure(
1386+
static_cast<uint8_t *>(HeaderBuf->contents()),
1387+
MTLAS->AccelStruct->gpuResourceID(),
1388+
static_cast<uint8_t *>(ContribBuf->contents()),
1389+
ContribBuf->gpuAddress(), Contributions.data(), InstCount);
1390+
IS.CB->KeepAliveMTLBuffers.push_back(HeaderBuf);
1391+
IS.CB->KeepAliveMTLBuffers.push_back(ContribBuf);
1392+
// Only the header is read by the shader (via the descriptor's gpuVA).
1393+
// The contribution buffer is read indirectly via the header's
1394+
// addressOfInstanceContributions pointer, so both must be resident
1395+
// during dispatch.
1396+
IS.ASDescriptorBuffers.push_back(HeaderBuf);
1397+
IS.ASDescriptorBuffers.push_back(ContribBuf);
1398+
1399+
IRDescriptorTableSetAccelerationStructure(
1400+
IS.DescHeap->getEntryHandle(HeapIndex), HeaderBuf->gpuAddress());
13561401
HeapIndex += R.first->getArraySize();
13571402
continue;
13581403
}
@@ -1415,6 +1460,12 @@ class MTLDevice : public offloadtest::Device {
14151460
NativeEncoder->useResource(ResSet.Resource.get(),
14161461
MTL::ResourceUsageRead |
14171462
MTL::ResourceUsageWrite);
1463+
for (auto &AS : IS.AccelStructs) {
1464+
auto *MTLAS = llvm::cast<MetalAccelerationStructure>(AS.get());
1465+
NativeEncoder->useResource(MTLAS->AccelStruct, MTL::ResourceUsageRead);
1466+
}
1467+
for (MTL::Buffer *B : IS.ASDescriptorBuffers)
1468+
NativeEncoder->useResource(B, MTL::ResourceUsageRead);
14181469

14191470
if (auto Err = Encoder.dispatch(*IS.Pipeline.get(),
14201471
P.DispatchParameters.DispatchGroupCount[0],
@@ -2144,6 +2195,11 @@ class MTLDevice : public offloadtest::Device {
21442195
auto *Descriptor =
21452196
MTL::InstanceAccelerationStructureDescriptor::alloc()->init();
21462197
Descriptor->setInstanceCount(Instances.size());
2198+
// UserID descriptor type so per-instance InstanceID survives the
2199+
// build and is returned by HLSL CommittedInstanceID()/InstanceIndex()
2200+
// semantics on the shader side.
2201+
Descriptor->setInstanceDescriptorType(
2202+
MTL::AccelerationStructureInstanceDescriptorTypeUserID);
21472203

21482204
MTL::AccelerationStructureSizes Sizes =
21492205
Device->accelerationStructureSizes(Descriptor);
@@ -2458,19 +2514,20 @@ llvm::Error MTLComputeEncoder::batchBuildAS(llvm::ArrayRef<ASBuildItem> Items) {
24582514
InstanceASIdx.push_back(Idx);
24592515
}
24602516

2461-
// Pack instance descriptors. Layout differs from VK/DX12: 32-byte
2462-
// entries with an index instead of a GPU address.
2517+
// Pack instance descriptors. Layout differs from VK/DX12: indexed
2518+
// BLAS references with an extra userID slot so HLSL InstanceID()
2519+
// survives across the build.
24632520
const size_t InstByteSize =
24642521
TLAS->Instances.size() *
2465-
sizeof(MTL::AccelerationStructureInstanceDescriptor);
2522+
sizeof(MTL::AccelerationStructureUserIDInstanceDescriptor);
24662523
MTL::Buffer *InstBuf =
24672524
MTLDev->newBuffer(InstByteSize, MTL::ResourceStorageModeShared);
24682525
if (!InstBuf)
24692526
return llvm::createStringError(
24702527
std::errc::not_enough_memory,
24712528
"Failed to allocate TLAS instance buffer.");
24722529
auto *InstPtr =
2473-
static_cast<MTL::AccelerationStructureInstanceDescriptor *>(
2530+
static_cast<MTL::AccelerationStructureUserIDInstanceDescriptor *>(
24742531
InstBuf->contents());
24752532
for (size_t I = 0; I < TLAS->Instances.size(); ++I) {
24762533
const auto &Src = TLAS->Instances[I];
@@ -2484,12 +2541,15 @@ llvm::Error MTLComputeEncoder::batchBuildAS(llvm::ArrayRef<ASBuildItem> Items) {
24842541
D.mask = Src.InstanceMask;
24852542
D.intersectionFunctionTableOffset = 0;
24862543
D.accelerationStructureIndex = InstanceASIdx[I];
2544+
D.userID = Src.InstanceID;
24872545
}
24882546
CB->KeepAliveMTLBuffers.push_back(InstBuf);
24892547

24902548
auto *ID = MTL::InstanceAccelerationStructureDescriptor::alloc()->init();
24912549
ID->setInstanceDescriptorBuffer(InstBuf);
24922550
ID->setInstanceCount(TLAS->Instances.size());
2551+
ID->setInstanceDescriptorType(
2552+
MTL::AccelerationStructureInstanceDescriptorTypeUserID);
24932553
NS::Array *BLASArr = NS::Array::array(
24942554
reinterpret_cast<NS::Object *const *>(UniqueBLASes.data()),
24952555
UniqueBLASes.size());

lib/API/VK/Device.cpp

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,11 @@ class VKComputeEncoder : public offloadtest::ComputeEncoder {
849849
uint32_t GroupCountX, uint32_t GroupCountY,
850850
uint32_t GroupCountZ) override {
851851
const auto &VKPSO = llvm::cast<VulkanPipelineState>(PSO);
852+
// Include AS_READ so dispatches that issue RayQuery against a TLAS get a
853+
// proper hand-off from the prior AS-build's AS_WRITE.
852854
addDstBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
853-
VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT);
855+
VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT |
856+
VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR);
854857
insertDebugSignpost(llvm::formatv("Dispatch [{0},{1},{2}]", GroupCountX,
855858
GroupCountY, GroupCountZ)
856859
.str());
@@ -1396,12 +1399,16 @@ class VulkanDevice : public offloadtest::Device {
13961399
(HasVulkan12 ||
13971400
isExtensionSupported(AvailableDeviceExtensions,
13981401
VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
1402+
const bool HasRayQueryExt =
1403+
HasASExts && isExtensionSupported(AvailableDeviceExtensions,
1404+
VK_KHR_RAY_QUERY_EXTENSION_NAME);
13991405

14001406
VkPhysicalDeviceAccelerationStructureFeaturesKHR ASFeatures{};
14011407
// On Vulkan 1.1 we need a separate BDA features struct; on 1.2+
14021408
// bufferDeviceAddress lives in VkPhysicalDeviceVulkan12Features which is
14031409
// already in the chain, and adding a duplicate is a validation error.
14041410
VkPhysicalDeviceBufferDeviceAddressFeatures BDAFeatures{};
1411+
VkPhysicalDeviceRayQueryFeaturesKHR RayQueryFeatures{};
14051412
if (HasASExts) {
14061413
ASFeatures.sType =
14071414
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR;
@@ -1413,6 +1420,12 @@ class VulkanDevice : public offloadtest::Device {
14131420
BDAFeatures.pNext = Features.pNext;
14141421
Features.pNext = &BDAFeatures;
14151422
}
1423+
if (HasRayQueryExt) {
1424+
RayQueryFeatures.sType =
1425+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR;
1426+
RayQueryFeatures.pNext = Features.pNext;
1427+
Features.pNext = &RayQueryFeatures;
1428+
}
14161429
}
14171430

14181431
vkGetPhysicalDeviceFeatures2(PhysicalDevice, &Features);
@@ -1485,6 +1498,14 @@ class VulkanDevice : public offloadtest::Device {
14851498
if (!HasVulkan12)
14861499
EnabledDeviceExtensions.push_back(
14871500
VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
1501+
if (HasRayQueryExt) {
1502+
if (!RayQueryFeatures.rayQuery)
1503+
return llvm::createStringError(
1504+
std::errc::not_supported,
1505+
"Device advertises %s but reports rayQuery=0",
1506+
VK_KHR_RAY_QUERY_EXTENSION_NAME);
1507+
EnabledDeviceExtensions.push_back(VK_KHR_RAY_QUERY_EXTENSION_NAME);
1508+
}
14881509
}
14891510

14901511
DeviceInfo.enabledExtensionCount =
@@ -3184,11 +3205,15 @@ class VulkanDevice : public offloadtest::Device {
31843205
constexpr size_t DescriptorTypesSize =
31853206
sizeof(DescriptorTypes) / sizeof(VkDescriptorType);
31863207
uint32_t DescriptorCounts[DescriptorTypesSize] = {0};
3208+
// VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR has an out-of-range enum
3209+
// value (1000150000), so it can't share the indexed array above.
3210+
uint32_t ASDescriptorCount = 0;
31873211
for (const auto &S : P.Sets) {
31883212
for (const auto &R : S.Resources) {
3189-
// TODO: AS descriptors need a separate pool size entry.
3190-
if (R.isAccelerationStructure())
3213+
if (R.isAccelerationStructure()) {
3214+
ASDescriptorCount += R.getArraySize();
31913215
continue;
3216+
}
31923217
DescriptorCounts[getDescriptorType(R.Kind)] += R.getArraySize();
31933218
if (R.HasCounter)
31943219
DescriptorCounts[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] +=
@@ -3206,6 +3231,12 @@ class VulkanDevice : public offloadtest::Device {
32063231
PoolSizes.push_back(PoolSize);
32073232
}
32083233
}
3234+
if (ASDescriptorCount > 0) {
3235+
llvm::outs() << "Descriptors: { type = ACCELERATION_STRUCTURE_KHR"
3236+
<< ", count = " << ASDescriptorCount << " }\n";
3237+
PoolSizes.push_back(
3238+
{VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, ASDescriptorCount});
3239+
}
32093240

32103241
if (P.Sets.size() > 0) {
32113242
VkDescriptorPoolCreateInfo PoolCreateInfo = {};
@@ -3249,11 +3280,15 @@ class VulkanDevice : public offloadtest::Device {
32493280
uint32_t ImageInfoCount = 0;
32503281
uint32_t BufferInfoCount = 0;
32513282
uint32_t BufferViewCount = 0;
3283+
uint32_t ASInfoCount = 0;
3284+
uint32_t ASHandleCount = 0;
32523285
for (auto &D : P.Sets) {
32533286
for (auto &R : D.Resources) {
3254-
// TODO: Count AS descriptors when binding is implemented.
3255-
if (R.isAccelerationStructure())
3287+
if (R.isAccelerationStructure()) {
3288+
ASInfoCount += 1;
3289+
ASHandleCount += R.getArraySize();
32563290
continue;
3291+
}
32573292
if (R.isSampler()) {
32583293
ImageInfoCount += 1;
32593294
continue;
@@ -3275,23 +3310,54 @@ class VulkanDevice : public offloadtest::Device {
32753310
llvm::SmallVector<VkDescriptorImageInfo> ImageInfos;
32763311
llvm::SmallVector<VkDescriptorBufferInfo> BufferInfos;
32773312
llvm::SmallVector<VkBufferView> BufferViews;
3313+
llvm::SmallVector<VkWriteDescriptorSetAccelerationStructureKHR> ASInfos;
3314+
llvm::SmallVector<VkAccelerationStructureKHR> ASHandles;
32783315
ImageInfos.reserve(ImageInfoCount);
32793316
BufferInfos.reserve(BufferInfoCount);
32803317
BufferViews.reserve(BufferViewCount);
3318+
ASInfos.reserve(ASInfoCount);
3319+
ASHandles.reserve(ASHandleCount);
32813320

32823321
llvm::SmallVector<VkWriteDescriptorSet> WriteDescriptors;
32833322
WriteDescriptors.reserve(ImageInfoCount + BufferInfoCount +
3284-
BufferViewCount);
3323+
BufferViewCount + ASInfoCount);
32853324
assert(IS.BufferViews.empty());
32863325

32873326
uint32_t OverallResIdx = 0;
32883327
for (uint32_t SetIdx = 0; SetIdx < P.Sets.size(); ++SetIdx) {
32893328
for (uint32_t RIdx = 0; RIdx < P.Sets[SetIdx].Resources.size();
32903329
++RIdx, ++OverallResIdx) {
32913330
const Resource &R = P.Sets[SetIdx].Resources[RIdx];
3292-
// TODO: Write AS descriptors when binding is implemented.
3293-
if (R.isAccelerationStructure())
3331+
if (R.isAccelerationStructure()) {
3332+
assert(R.TLASPtr && "AS resource must be resolved to a TLAS");
3333+
assert(R.getArraySize() == 1 && "AS arrays not yet supported");
3334+
// OutAS layout from buildPipelineAccelerationStructures: BLASes
3335+
// first, then TLASes — both in P.AccelStructs declaration order.
3336+
const size_t TLASIdx = R.TLASPtr - &P.AccelStructs.TLAS[0];
3337+
const size_t ASIdx = P.AccelStructs.BLAS.size() + TLASIdx;
3338+
auto *VkAS = llvm::cast<VulkanAccelerationStructure>(
3339+
IS.AccelStructs[ASIdx].get());
3340+
const size_t HandleStart = ASHandles.size();
3341+
ASHandles.push_back(VkAS->AccelStruct);
3342+
VkWriteDescriptorSetAccelerationStructureKHR ASWrite = {};
3343+
ASWrite.sType =
3344+
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR;
3345+
ASWrite.accelerationStructureCount = 1;
3346+
ASWrite.pAccelerationStructures = &ASHandles[HandleStart];
3347+
ASInfos.push_back(ASWrite);
3348+
3349+
VkWriteDescriptorSet WDS = {};
3350+
WDS.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
3351+
WDS.pNext = &ASInfos.back();
3352+
WDS.dstSet = IS.DescriptorSets[SetIdx];
3353+
WDS.dstBinding = R.VKBinding->Binding;
3354+
WDS.descriptorCount = 1;
3355+
WDS.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
3356+
llvm::outs() << "Updating AS Descriptor [" << OverallResIdx << "] { "
3357+
<< SetIdx << ", " << RIdx << " }\n";
3358+
WriteDescriptors.push_back(WDS);
32943359
continue;
3360+
}
32953361
uint32_t IndexOfFirstBufferDataInArray;
32963362
if (R.isSampler()) {
32973363
IndexOfFirstBufferDataInArray = ImageInfos.size();

test/Feature/InlineRT/indexed-triangle-setup.test

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#--- source.hlsl
22

3-
RaytracingAccelerationStructure Scene : register(t0);
4-
RWStructuredBuffer<uint> Output : register(u0);
3+
[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
4+
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);
55

66
[numthreads(1,1,1)]
77
void main() {
8-
// Placeholder: will use TraceRayInline when available
9-
Output[0] = 1;
8+
RayDesc Ray;
9+
Ray.Origin = float3(0, 0, 1);
10+
Ray.Direction = float3(0, 0, -1);
11+
Ray.TMin = 0.0;
12+
Ray.TMax = 100.0;
13+
RayQuery<RAY_FLAG_NONE> Q;
14+
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
15+
Q.Proceed();
16+
Output[0] = Q.CommittedStatus() == COMMITTED_TRIANGLE_HIT ? 1 : 0;
1017
}
1118
//--- pipeline.yaml
1219
---
@@ -76,9 +83,6 @@ Results:
7683
# REQUIRES: acceleration-structure
7784
# XFAIL: Clang
7885

79-
# Unimplemented: https://github.com/llvm/offload-test-suite/issues/1158
80-
# XFAIL: *
81-
8286
# RUN: split-file %s %t
8387
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
8488
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)