Skip to content

Proposal summarizing implicit resource binding rules in DXC #176

Closed
@bogner

Description

@bogner

We need to document how are implicit resource bindings assigned in DXC. That includes documenting how resource usage is determined, how unused resources are culled, and in which part of the compiler the assignment happens.

For example, DXC assigns the implicit binding in codegen after optimizations based on which resources in Array are accessed:
https://godbolt.org/z/hGYG4rcqb

struct MyBufs {
    RWBuffer<float> Array[4];
};

MyBufs Many : register(u0);
RWBuffer<float> JustOne : register(u0);
RWBuffer<float> SecondOne;

[numthreads(4,1,1)]
void main() {
  Many.Array[2][0] = 1.0; // gets u2
  JustOne[0] = 2.0;       // gets u0
  SecondOne[0] = 3.0;     // gets u1
}

However, when a resource array is a global variable, DXC assumes all values will be used and assigns a slot after the array no matter which values of the array are accessed:
https://godbolt.org/z/sdTPh58hc

RWBuffer<float> JustOne : register(u10);
RWBuffer<float> SecondOne;
RWBuffer<float> ArrayHere[4] : register(u0);

[numthreads(4,1,1)]
void main() {
  ArrayHere[2][0] = 3.0;  // gets u0
  JustOne[0] = 2.0;       // gets u10
  SecondOne[0] = 2.0;     // gets u4 - after the array
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions