Skip to content

[SER] Const correctness with HitObjects and payload #7760

@Hengoo

Description

@Hengoo

Description

You can write code that modifies const HitObject and const payload.
I would expect to get a compiler error instead.

Steps to Reproduce

RaytracingAccelerationStructure     gScene      : register(t0, space0); // acceleration structure
RWBuffer<float>                     output      : register(u0, space0);

struct [raypayload] Payload {
    float value : write(caller, closesthit, miss) : read(caller, closesthit, miss);
};

[shader("raygeneration")]
void BasicRayGen()
{
    RayDesc rayInit;
    rayInit.TMin = 0;
    rayInit.TMax = 1;
    rayInit.Origin = float3(1, 1, 1);
    rayInit.Direction = float3(1, 1, 1);
    const RayDesc ray = rayInit;
    Payload pInit;
    pInit.value = 0.0;
    const Payload p = pInit;
    // Anyhit shader could modify payload
    const dx::HitObject obj = dx::HitObject::TraceRay(gScene, 0, 0xff, 0, 0, 0, ray, p);
    // this modifies obj
    obj.SetShaderTableIndex(42);
    // Invoked shader could modifiy payload
    dx::HitObject::Invoke(obj, p);
    output[0] = p.value;
}

-T lib_6_9

See https://godbolt.org/z/fexT48588

Actual Behavior

This compiles without any issues / warning.

Environment

  • DXC version: dxcompiler.dll: 1.9 - 1.8.2505.32 (b106a96); dxil.dll: 1.9(1.8.2505.32)

Metadata

Metadata

Assignees

Labels

bugBug, regression, crashneeds-triageAwaiting triage

Type

No type

Projects

Status

Triaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions