samedi 28 février 2015

Compiler error when trying to add constant float3x3 to shader file

I am trying to add this code to my Metal language file:



constant float3x3 rgb2xyz(
float3(0.412453f, 0.212671f, 0.019334f),
float3(0.357580f, 0.715160f, 0.119193f),
float3(0.180423f, 0.072169f, 0.950227f)
);


or this



constant float3x3 rgb2xyz = float3x3(
float3(0.412453f, 0.212671f, 0.019334f),
float3(0.357580f, 0.715160f, 0.119193f),
float3(0.180423f, 0.072169f, 0.950227f)
);


The metal compiler gives me the following error:



No matching constructor for initialization of 'const constant float3x3' (aka 'const constant matrix<float, 3, 3>')


However if I do



typedef struct {
float3x3 matrix;
float3 offset;
float zoom;
} Conversion;

constant Conversion colorConversion = {
.matrix = float3x3(
float3 ( 1.164f, 1.164f, 1.164f ),
float3 ( 0.000f, -0.392f, 2.017f ),
float3 ( 1.596f, -0.813f, 0.000f )
),
.offset = float3 ( -(16.0f/255.0f), -0.5f, -0.5f )
};


I don't get any compile error.


Any ideas what is going wrong? It also works without problems with vector types:



constant float3 bgr2xyzCol1(0.357580f, 0.715160f, 0.119193f);


How would be a good way to define a constant matrix directly in the code?


Aucun commentaire:

Enregistrer un commentaire