Skip to content

Matrix Intrinsic Test Requirements #388

@kmpeng

Description

@kmpeng

In Test\Feature\HLSLLib, create a test file <intrinsic>.matrix.test that uses float and int (32-bit) types to test the following matrix size varieties:

  • A matrix where rows > columns (e.g. 3x2)
  • A matrix where columns > rows (e.g. 2x4)
  • A 1-dimensional matrix (e.g. 3x1)
  • Max size matrix (e.g. 4x4)

A .test file should contain:

  • a source portion; if multiple .test files can use the same source, it can go in its own file and be referenced in the run portion of each .test file instead.
#--- source.hlsl

StructuredBuffer<float> In : register(t0);
RWStructuredBuffer<float> Out2x2 : register(u1);

[numthreads(1,1,1)]
void main() {
  float2x2 Mat2x2 = float2x2(In[0], In[1], In[2], In[3]);
  float2x2 Result2x2 = degrees(Mat2x2);
  
  const uint COLS = 2;
  for(uint i = 0; i < 4; i++) {
    uint row = i / COLS;
    uint col = i % COLS;
    Out2x2[i] = Result2x2[row][col];
  }
}
  • a yaml portion; if multiple .test files can use the same YAML, it can go in its own file and be referenced in the run portion of each .test file instead.
//--- pipeline.yaml

---
Shaders:
  - Stage: Compute
    Entry: main
    DispatchSize: [1, 1, 1]
Buffers:
  - Name: In
    Format: Float32
    Stride: 4
    Data: [ 0.0, 1.5708, 3.14159, 6.28318 ]
  - Name: Out2x2
    Format: Float32
    Stride: 4
    FillSize: 16
  - Name: ExpectedOut2x2 # The result we expect
    Format: Float32
    Stride: 4
    Data: [ 0.0, 90.0, 180.0, 360.0 ]
Results:  # A test might have more than 1 result.
  - Result: Test1
    Rule: BufferFuzzy # there is also a BufferExact rule
    ULPT: 1
    Actual: Out2x2
    Expected: ExpectedOut2x2
DescriptorSets:
  - Resources:
    - Name: In
      Kind: StructuredBuffer
      DirectXBinding:
        Register: 0
        Space: 0
      VulkanBinding:
        Binding: 0
    - Name: Out2x2
      Kind: RWStructuredBuffer
      DirectXBinding:
        Register: 1
        Space: 0
      VulkanBinding:
        Binding: 1
...
#--- end
  • A run portion; this will be unique to each .test file.
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions