Skip to content

[DirectX backend] flatten multi-dimensional array into a one-dimensional array. #89646

Closed
@python3kgae

Description

@python3kgae

DXIL requires array to be 1D only in https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#arrays

Need a pass in DirectX backend to flatten multi-dimensional array into a one-dimensional array.

Not limited to group shared. static global variable or local variable need to be flattened as well.

groupshared float a[10][16];
static float b[16][4];

Buffer<float> B;
float foo(int x, int y) {
  float l[16][4];
  for (int i=0;i<16;++i)
     for (int j=0;j<4;++j)
        l[i][j] = B[i] + B[j];
  return l[x][y];
}

The groupshared variable ‘a’, static global variable ‘b’, and local variable ‘l’ all need to be flattened into a one-dimensional array.

AC:

  • A new IR path is created that transforms arrays into 1D arrays
    • Collect all multi-dimensional array variable as candidates.
    • Create one-dimensional array to replace the original array.
    • Update debug info.
  • Tests are created and are passing

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions