@@ -27,6 +27,20 @@ __spirv_Sampler __translate_sampler_initializer(uint sampler)
27
27
return __builtin_astype ((ulong )sampler , __spirv_Sampler );
28
28
}
29
29
30
+ #ifdef __IGC_BUILD__
31
+ __attribute__((inline )) float4 __flush_denormals (float4 in )
32
+ {
33
+ //temporary fix, since SKL+ support denormal values we need to flush those values to zero after LOAD instructions.
34
+ //AND r6, r8, 0x807fffff;
35
+ //UCMP.eq p0, r6, r8;
36
+ //(p0) AND r8, r8, 0x80000000;
37
+ int4 floatDenorm = (int4 )0x807fffff ;
38
+ int4 signBit = (int4 )0x80000000 ;
39
+ float4 temp = as_float4 (as_int4 (in ) & floatDenorm );
40
+ return (as_int4 (temp ) == as_int4 (in )) ? as_float4 (as_int4 (in ) & signBit ) : in ;
41
+ }
42
+ #endif
43
+
30
44
// Image Instructions
31
45
32
46
// ImageSampleExplicitLod samples an image using an explicit level of detail.
@@ -403,8 +417,18 @@ float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_
403
417
404
418
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN (ImageSampleExplicitLod , _v4f32_img1d_ro_i32_i32_f32 , _Rfloat4 )(__spirv_SampledImage_1D SampledImage , int Coordinate , int ImageOperands , float Lod )
405
419
{
406
- float floatCoords = convert_float (Coordinate );
407
- return SPIRV_BUILTIN (ImageSampleExplicitLod , _v4f32_img1d_ro_f32_i32_f32 , _Rfloat4 )(SampledImage , floatCoords , ImageOperands , Lod );
420
+ int image_id = (int )__builtin_IB_get_image (SampledImage );
421
+ int sampler_id = (int )__builtin_IB_get_sampler (SampledImage );
422
+ if ((__builtin_IB_get_address_mode (sampler_id ) & 0x07 ) == CLK_ADDRESS_CLAMP_TO_EDGE )
423
+ {
424
+ float floatCoords = convert_float ((Coordinate ));
425
+ return __builtin_IB_OCL_1d_sample_l (image_id , sampler_id , floatCoords , Lod );
426
+ }
427
+ else
428
+ {
429
+ float4 res = __builtin_IB_OCL_1d_ld (image_id , Coordinate , 0 );
430
+ return __flush_denormals (res );
431
+ }
408
432
}
409
433
410
434
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4 (__spirv_SampledImage_1D SampledImage , float Coordinate , int ImageOperands , float Lod )
@@ -991,6 +1015,10 @@ float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_arr
991
1015
992
1016
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY (DIM , COORD_DIM , RET_TYPE , LOAD_TYPE ) \
993
1017
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
1018
+ { \
1019
+ return convert_##RET_TYPE##4(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod)); \
1020
+ } \
1021
+ RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
994
1022
{ \
995
1023
return convert_##RET_TYPE##4(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod)); \
996
1024
}
@@ -1026,31 +1054,63 @@ RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_S
1026
1054
{ \
1027
1055
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, ImageOperands, DefaultLod); \
1028
1056
} \
1057
+ RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands) \
1058
+ { \
1059
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, ImageOperands, DefaultLod); \
1060
+ } \
1029
1061
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate) \
1030
1062
{ \
1031
1063
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1032
1064
} \
1065
+ RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate) \
1066
+ { \
1067
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1068
+ } \
1033
1069
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
1034
1070
{ \
1035
1071
return convert_##RET_TYPE##2(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).xy); \
1036
1072
} \
1073
+ RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
1074
+ { \
1075
+ return convert_##RET_TYPE##2(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).xy); \
1076
+ } \
1037
1077
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands) \
1038
1078
{ \
1039
1079
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, ImageOperands, DefaultLod); \
1040
1080
} \
1081
+ RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands) \
1082
+ { \
1083
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, ImageOperands, DefaultLod); \
1084
+ } \
1041
1085
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate) \
1042
1086
{ \
1043
1087
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1044
1088
} \
1089
+ RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate) \
1090
+ { \
1091
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1092
+ } \
1045
1093
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
1046
1094
{ \
1047
1095
return convert_##RET_TYPE(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).x); \
1048
1096
} \
1097
+ RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
1098
+ { \
1099
+ return convert_##RET_TYPE(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).x); \
1100
+ } \
1049
1101
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands) \
1050
1102
{ \
1051
1103
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, ImageOperands, DefaultLod); \
1052
1104
} \
1105
+ RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate, int ImageOperands) \
1106
+ { \
1107
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, ImageOperands, DefaultLod); \
1108
+ } \
1053
1109
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate) \
1110
+ { \
1111
+ return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1112
+ } \
1113
+ RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, int##COORD_DIM Coordinate) \
1054
1114
{ \
1055
1115
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, DefaultImageOperands, DefaultLod); \
1056
1116
}
@@ -1110,20 +1170,6 @@ DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_HALF(1, )
1110
1170
1111
1171
// Image Read
1112
1172
1113
- #ifdef __IGC_BUILD__
1114
- __attribute__((inline )) float4 __flush_denormals (float4 in )
1115
- {
1116
- //temporary fix, since SKL+ support denormal values we need to flush those values to zero after LOAD instructions.
1117
- //AND r6, r8, 0x807fffff;
1118
- //UCMP.eq p0, r6, r8;
1119
- //(p0) AND r8, r8, 0x80000000;
1120
- int4 floatDenorm = (int4 )0x807fffff ;
1121
- int4 signBit = (int4 )0x80000000 ;
1122
- float4 temp = as_float4 (as_int4 (in ) & floatDenorm );
1123
- return (as_int4 (temp ) == as_int4 (in )) ? as_float4 (as_int4 (in ) & signBit ) : in ;
1124
- }
1125
- #endif
1126
-
1127
1173
#define DEF_IMAGE_READ_2D (ACC_QUAL ) \
1128
1174
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4 (global Img2d_ ##ACC_QUAL * Image , int2 Coordinate ) \
1129
1175
{ \
0 commit comments