@@ -202,13 +202,8 @@ uvec4 f32tof16( vec4 f4 )
202202}
203203#endif
204204
205- #ifndef GL_ES // double is not supported on GLES
206- double asdouble (uint lowbits , uint highbits )
207- {
208- return packDouble2x32 ( uvec2 ( lowbits , highbits ) );
209- }
210- #endif
211-
205+ // Use #define as double is not supported on GLES
206+ #define asdouble (lowbits , highbits ) packDouble2x32( uvec2( lowbits, highbits ) )
212207
213208// Floating point functions
214209
@@ -532,15 +527,50 @@ void _TypeConvertStore( out int Dst, in int Src ){ Dst = int( Src ); }
532527void _TypeConvertStore ( out int Dst , in uint Src ){ Dst = int ( Src ); }
533528void _TypeConvertStore ( out int Dst , in float Src ){ Dst = int ( Src ); }
534529
535- int _ToInt ( int x ) { return int (x ); }
536- int _ToInt ( uint x ) { return int (x ); }
537- int _ToInt ( float x ){ return int (x ); }
538- int _ToInt ( bool x ) { return x ? 1 : 0 ; }
530+
531+ int _ToInt ( int x ) { return int (x ); }
532+ int _ToInt ( ivec2 v ) { return int (v .x ); }
533+ int _ToInt ( ivec3 v ) { return int (v .x ); }
534+ int _ToInt ( ivec4 v ) { return int (v .x ); }
535+
536+ int _ToInt ( uint x ) { return int (x ); }
537+ int _ToInt ( uvec2 v ) { return int (v .x ); }
538+ int _ToInt ( uvec3 v ) { return int (v .x ); }
539+ int _ToInt ( uvec4 v ) { return int (v .x ); }
540+
541+ int _ToInt ( float x ) { return int (x ); }
542+ int _ToInt ( vec2 v ) { return int (v .x ); }
543+ int _ToInt ( vec3 v ) { return int (v .x ); }
544+ int _ToInt ( vec4 v ) { return int (v .x ); }
545+
546+ int _ToInt ( bool x ) { return x ? 1 : 0 ;}
547+ int _ToInt ( bvec2 v ) { return v .x ? 1 : 0 ;}
548+ int _ToInt ( bvec3 v ) { return v .x ? 1 : 0 ;}
549+ int _ToInt ( bvec4 v ) { return v .x ? 1 : 0 ;}
550+
551+
539552
540553float _ToFloat ( int x ) { return float (x ); }
554+ float _ToFloat ( ivec2 v ){ return float (v .x ); }
555+ float _ToFloat ( ivec3 v ){ return float (v .x ); }
556+ float _ToFloat ( ivec4 v ){ return float (v .x ); }
557+
541558float _ToFloat ( uint x ) { return float (x ); }
559+ float _ToFloat ( uvec2 v ){ return float (v .x ); }
560+ float _ToFloat ( uvec3 v ){ return float (v .x ); }
561+ float _ToFloat ( uvec4 v ){ return float (v .x ); }
562+
542563float _ToFloat ( float x ){ return float (x ); }
543- float _ToFloat ( bool x ) { return x ? 1.0 : 0.0 ;}
564+ float _ToFloat ( vec2 v ) { return float (v .x ); }
565+ float _ToFloat ( vec3 v ) { return float (v .x ); }
566+ float _ToFloat ( vec4 v ) { return float (v .x ); }
567+
568+ float _ToFloat ( bool x ) { return x ? 1.0 : 0.0 ;}
569+ float _ToFloat ( bvec2 v ){ return v .x ? 1.0 : 0.0 ;}
570+ float _ToFloat ( bvec3 v ){ return v .x ? 1.0 : 0.0 ;}
571+ float _ToFloat ( bvec4 v ){ return v .x ? 1.0 : 0.0 ;}
572+
573+
544574
545575uint _ToUint ( int x ) { return uint (x ); }
546576uint _ToUint ( uint x ) { return uint (x ); }
@@ -796,15 +826,15 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); }
796826// in the second to last component of Coords. (The second component of Coords is unused for 1D shadow lookups.)
797827// For cube array textures, Dsub is specified as a separate parameter
798828// mip
799- #define SampleCmpLevel0Tex1D_3 (Tex , Sampler , Coords , CompareValue ) textureLod(Tex, _ToVec3(( Coords).x, 0.0, CompareValue), 0.0)
829+ #define SampleCmpLevel0Tex1D_3 (Tex , Sampler , Coords , CompareValue ) textureLod(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0)
800830#define SampleCmpLevel0Tex1DArr_3 (Tex , Sampler , Coords , CompareValue ) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0)
801831#define SampleCmpLevel0Tex2D_3 (Tex , Sampler , Coords , CompareValue ) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0)
802832#define SampleCmpLevel0Tex2DArr_3 (Tex , Sampler , Coords , CompareValue ) 0.0 // No textureLod for sampler2DArrayShadow
803833#define SampleCmpLevel0TexCube_3 (Tex , Sampler , Coords , CompareValue ) 0.0 // No textureLod for samplerCubeShadow
804834#define SampleCmpLevel0TexCubeArr_3 (Tex , Sampler , Coords , CompareValue ) 0.0 // No textureLod for samplerCubeArrayShadow
805835
806836// mip
807- #define SampleCmpLevel0Tex1D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureLodOffset(Tex, _ToVec3(( Coords).x, 0.0, CompareValue), 0.0, int(Offset))
837+ #define SampleCmpLevel0Tex1D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureLodOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0, int(Offset))
808838#define SampleCmpLevel0Tex1DArr_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, int(Offset))
809839#define SampleCmpLevel0Tex2D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, ivec2((Offset).xy))
810840#define SampleCmpLevel0Tex2DArr_4 (Tex , Sampler , Coords , CompareValue , Offset ) 0.0 // No textureLodOffset for sampler2DArrayShadow
@@ -818,14 +848,14 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); }
818848# define SampleBias_3 (Tex , Sampler , Coords , Bias ) texture (Tex, _ToVec(Coords), _ToFloat(Bias))
819849# define SampleBias_4 (Tex , Sampler , Coords , Bias , Offset ) textureOffset(Tex, _ToVec(Coords), Offset, _ToFloat(Bias))
820850
821- # define SampleCmpTex1D_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec3(( Coords).x, 0.0, CompareValue))
851+ # define SampleCmpTex1D_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec3( Coords, 0.0, CompareValue))
822852# define SampleCmpTex1DArr_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue))
823853# define SampleCmpTex2D_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue))
824854# define SampleCmpTex2DArr_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue))
825855# define SampleCmpTexCube_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue))
826856# define SampleCmpTexCubeArr_3 (Tex , Sampler , Coords , CompareValue ) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, (Coords).w), _ToFloat(CompareValue))
827857
828- # define SampleCmpTex1D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureOffset(Tex, _ToVec3(( Coords).x, 0.0, CompareValue), int(Offset))
858+ # define SampleCmpTex1D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), int(Offset))
829859# define SampleCmpTex1DArr_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), int(Offset))
830860# define SampleCmpTex2D_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), ivec2((Offset).xy))
831861# define SampleCmpTex2DArr_4 (Tex , Sampler , Coords , CompareValue , Offset ) textureOffset(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue), ivec2((Offset).xy))
@@ -886,7 +916,7 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); }
886916#define LoadTex2DMSArr_3 (Tex , Location , Sample , Offset )texelFetch(Tex, _ToIvec3( (Location).x + (Offset).x, (Location).y + (Offset).y, (Location).z), int(Sample)) // No texelFetchOffset for texture2DMSArray
887917
888918//https://www.opengl.org/sdk/docs/man/html/imageLoad.xhtml
889- #define LoadRWTex1D_1 (Tex , Location ) imageLoad(Tex, _ToIvec(( Location).x) )
919+ #define LoadRWTex1D_1 (Tex , Location ) imageLoad(Tex, _ToInt( Location) )
890920#define LoadRWTex1DArr_1 (Tex , Location ) imageLoad(Tex, _ToIvec((Location).xy) )
891921#define LoadRWTex2D_1 (Tex , Location ) imageLoad(Tex, _ToIvec((Location).xy) )
892922#define LoadRWTex2DArr_1 (Tex , Location ) imageLoad(Tex, _ToIvec((Location).xyz) )
0 commit comments