We describe, here, the already converted productions between HLSL and GLSL.

Direct Token Mapping

HLSL GLSL HLSL GLSL
#elseif #elif float2x2 mat2x2
float2 vec2 float2x3 mat2x3
float3 vec3 float2x4 mat2x4
float4 vec4 float3x2 mat3x2
bool2 bvec2 float3x3 mat3x3
bool3 bvec3 float3x4 mat3x4
bool4 bvec4 float4x2 mat4x2
int2 ivec2 float4x3 mat4x3
int3 ivec3 float4x4 mat4x4
int4 ivec4 tex2D texture2D
half2 ivec2
half3 ivec3
half4 ivec4

Others Mappings

Column Major or Row Major?

HLSL and GLSL matrices are both column major, but elements are accessed in this way:

HLSL

float4x4 = // [row][column]
 [0][0], [0][1], [0][2], [0][3]
 [1][0], [1][1], [1][2], [1][3]
 [2][0], [2][1], [2][2], [2][3]
 [3][0], [3][1], [3][2], [3][3]


float2x2 (
    0, 0, // row 1
    2, 2  // row 2) 


int1x1    iMatrix;   // integer matrix with 1 row,  1 column
int4x1    iMatrix;   // integer matrix with 4 rows, 1 column
int1x4    iMatrix;   // integer matrix with 1 row, 4 columns
double3x3 dMatrix;   // double matrix with 3 rows, 3 columns


matrix[0] returns the first row.

GLSL

float4x4 = // [column][row]
 [0][0], [0][1], [0][2], [0][3]
 [1][0], [1][1], [1][2], [1][3]
 [2][0], [2][1], [2][2], [2][3]
 [3][0], [3][1], [3][2], [3][3]


 mat2(float, float,  // first column
     float, float); // second column  


GLSL matrix[0] is the first column.

Semantic Params

There are no Semantic Params in GLSL. The variables that have semantical behavior must be replaced by declared variables. For example:

float4 oColor : Color


must be changed to

gl_FragColor

Intrinsic Functions that are not supported by GLSL

asuint round
clip saturate
cosh sincos
D3DCOLORtoUBYTE4 sinh
determinant tanh
frexp tex1Dbias
GetRenderTargetSampleCount tex1Dgrad
GetRenderTargetSamplePosition tex2Dbias
isfinite tex2Dgrad
isinf tex3Dbias
isnan tex3Dgrad
ldexp texCUBEbias
lerp texCUBEgrad
lit transpose
log10 trunc
modf

HLSL Attributes Reference (Xbox 360)

This attributes are for shaders developed for Xbox360, thus, GLSL does not support them.

branch maxtempreg
call noExpressionOptimizations
flatten predicateBlock
ifAll reduceTempRegUsage
ifAny removeUnusedInputs
isolate sampreg
loop unroll
maxexports unused
maxInstructionCount