shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

Unsupported 1-dimensional matrix types #4395

Open chaoticbob opened 2 weeks ago

chaoticbob commented 2 weeks ago

HLSL has 1-dimensional matrix types that DXC accepts. Metal does not have them.

I think for on ramping it might be just to have them in case someone uses them.

I don't know if they have specific load/store ordering dependencies. But the DXC has SPIR-V opcodes: https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/test/CodeGenSPIRV/binary-op.arith-assign.matrix.hlsl

void main() {

    float1x1 a, b;
    b += a;

    {

        float1x2 c, d;
        d -= c;

        float1x3 e, f;
        f *= e;

        float1x4 g, h;
        h *= h;
    }

    {
        float2x1 c, d;
        d -= c;

        float3x1 e, f;
        f *= e;

        float4x1 g, h;
        h *= h;
    }    
}
chaoticbob commented 2 weeks ago

NOTE: This applies to other types besides float as well.

jkwak-work commented 10 hours ago

On my first attempt, HLSL seems fine but SPIR-V validation errors it out.

error: line 32: Illegal number of components (1) for TypeVector
  %v1float = OpTypeVector %float 1

I will see how to avoid it.