tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
568 stars 98 forks source link

IntrinsicTypes.GetVectorType and GetMatrixType wrong access #26

Closed amerkoleci closed 8 years ago

amerkoleci commented 8 years ago

I found out that the type return is wrong, the access should be:

public static TypeSymbol GetVectorType(ScalarType scalarType, int numComponents)
{
    var index = (((int)scalarType - 1) * 4) + numComponents;
    return AllVectorTypes[index - 1];
    //return AllVectorTypes[(((int)scalarType - 1) * 4) + (numComponents - 1)];
}
public static TypeSymbol GetMatrixType(ScalarType scalarType, int numRows, int numCols)
{
    var index = (((int)scalarType - 2) * 16) + (numRows * 4) + (numCols * 4);
    return AllMatrixTypes[index - 1];
    //return AllMatrixTypes[(((int)scalarType - 1) * 16) + (numRows * 4) + numCols];
}
tgjones commented 8 years ago

Thanks! (I have to ask, how did you find that error? I don't think anything in the VS language service exposes it yet, right? That code is still very much in development.)

I've already fixed it, although slightly differently from your code above:

public static TypeSymbol GetVectorType(ScalarType scalarType, int numComponents)
{
    return AllVectorTypes[(((int)scalarType - 1) * 4) + (numComponents - 1)];
}

public static TypeSymbol GetMatrixType(ScalarType scalarType, int numRows, int numCols)
{
    return AllMatrixTypes[(((int)scalarType - 1) * 16) + ((numRows - 1) * 4) + (numCols - 1)];
}
amerkoleci commented 8 years ago

I'm working on GLSL converter, lot of stuff already implemented,managed to generate everything using SyntaxVisitor and entry points by using SemanticModel.

tgjones commented 8 years ago

I'm working on GLSL converter

Awesome! Looking forward to seeing what you come up with.

As you'll have seen, I'm doing a lot of work on SemanticModel and binding right now. I can successfully bind many of the shader in the test suite, but by no means all. I still need to do unary and binary operator resolution, and better function overload resolution, among other things.