Skip to content

Commit ad30c7f

Browse files
authored
clean vulkan shader common extension (#5952)
* clean vulkan shader common extension * macro suffix makes glslang unhappy
1 parent bf13c30 commit ad30c7f

File tree

415 files changed

+9
-3072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

415 files changed

+9
-3072
lines changed

src/convert_ycbcr.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int w = 0;
2518
layout (constant_id = 1) const int h = 0;
2619
layout (constant_id = 2) const int outw = 0;

src/gpu.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -4932,11 +4932,11 @@ int compile_spirv_module(const char* comp_data, int comp_data_size, const Option
49324932
char defstr[256];
49334933
if (def.type == 1)
49344934
{
4935-
sprintf(defstr, "%uu", def.u8);
4935+
sprintf(defstr, "%u", def.u8);
49364936
}
49374937
if (def.type == 2)
49384938
{
4939-
sprintf(defstr, "%uu", def.u32);
4939+
sprintf(defstr, "%u", def.u32);
49404940
}
49414941
if (def.type == 3)
49424942
{
@@ -4951,7 +4951,7 @@ int compile_spirv_module(const char* comp_data, int comp_data_size, const Option
49514951
else
49524952
{
49534953
uint32_t u32 = def.u64 > UINT_MAX ? UINT_MAX : (uint32_t)def.u64;
4954-
sprintf(defstr, "%uu", u32);
4954+
sprintf(defstr, "%u", u32);
49554955
}
49564956
}
49574957
if (def.type == 5)
@@ -4969,18 +4969,18 @@ int compile_spirv_module(const char* comp_data, int comp_data_size, const Option
49694969

49704970
if (def.type == 0)
49714971
{
4972-
define_macro_data += std::string("#define __ncnn_") + key + " \"" + def.s + "\"\n";
4972+
define_macro_data += std::string("#define ncnn_") + key + " \"" + def.s + "\"\n";
49734973
}
49744974
else
49754975
{
49764976
char defstr[256];
49774977
if (def.type == 1)
49784978
{
4979-
sprintf(defstr, "%uu", def.u8);
4979+
sprintf(defstr, "%u", def.u8);
49804980
}
49814981
if (def.type == 2)
49824982
{
4983-
sprintf(defstr, "%uu", def.u32);
4983+
sprintf(defstr, "%u", def.u32);
49844984
}
49854985
if (def.type == 3)
49864986
{
@@ -4995,15 +4995,15 @@ int compile_spirv_module(const char* comp_data, int comp_data_size, const Option
49954995
else
49964996
{
49974997
uint32_t u32 = def.u64 > UINT_MAX ? UINT_MAX : (uint32_t)def.u64;
4998-
sprintf(defstr, "%uu", u32);
4998+
sprintf(defstr, "%u", u32);
49994999
}
50005000
}
50015001
if (def.type == 5)
50025002
{
50035003
sprintf(defstr, "%e", def.f32);
50045004
}
50055005

5006-
define_macro_data += std::string("#define __ncnn_") + key + " " + defstr + "\n";
5006+
define_macro_data += std::string("#define ncnn_") + key + " " + defstr + "\n";
50075007
}
50085008
}
50095009

@@ -5016,7 +5016,7 @@ int compile_spirv_module(const char* comp_data, int comp_data_size, const Option
50165016
if (opt.use_fp16_storage)
50175017
{
50185018
custom_exts += "#extension GL_EXT_shader_16bit_storage: require\n";
5019-
// custom_exts += "struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };\n";
5019+
custom_exts += "struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };\n";
50205020
}
50215021
if (opt.use_fp16_arithmetic)
50225022
{

src/layer/vulkan/shader/absval_pack8.comp

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
19-
#endif
20-
2117
#define shape_constant_id_offset 0
2218
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2319
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/batchnorm.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/batchnorm_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/batchnorm_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
#define shape_constant_id_offset 0
2618
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2719
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/binaryop.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int op_type = 0;
2518
layout (constant_id = 1) const int with_scalar = 0;
2619
layout (constant_id = 2) const float const_b = 0;

src/layer/vulkan/shader/binaryop_broadcast.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int op_type = 0;
2518

2619
#define shape_constant_id_offset 1

src/layer/vulkan/shader/binaryop_broadcast_pack1to4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int op_type = 0;
2518

2619
#define shape_constant_id_offset 1

src/layer/vulkan/shader/binaryop_broadcast_pack1to8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
layout (constant_id = 0) const int op_type = 0;
2618

2719
#define shape_constant_id_offset 1

src/layer/vulkan/shader/binaryop_broadcast_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int op_type = 0;
2518

2619
#define shape_constant_id_offset 1

src/layer/vulkan/shader/binaryop_broadcast_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
layout (constant_id = 0) const int op_type = 0;
2618

2719
#define shape_constant_id_offset 1

src/layer/vulkan/shader/binaryop_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const int op_type = 0;
2518
layout (constant_id = 1) const int with_scalar = 0;
2619
layout (constant_id = 2) const float const_b = 0;

src/layer/vulkan/shader/binaryop_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
layout (constant_id = 0) const int op_type = 0;
2618
layout (constant_id = 1) const int with_scalar = 0;
2719
layout (constant_id = 2) const float const_b = 0;

src/layer/vulkan/shader/cast_fp16_to_fp32.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/cast_fp16_to_fp32_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/cast_fp16_to_fp32_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
#define shape_constant_id_offset 0
2618
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2719
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/cast_fp32_to_fp16.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/cast_fp32_to_fp16_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
#define shape_constant_id_offset 0
2518
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2619
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/cast_fp32_to_fp16_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
#define shape_constant_id_offset 0
2618
layout (constant_id = shape_constant_id_offset + 0) const int dims = 0;
2719
layout (constant_id = shape_constant_id_offset + 1) const int w = 0;

src/layer/vulkan/shader/celu.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const float alpha = 0;
2518

2619
#define shape_constant_id_offset 1

src/layer/vulkan/shader/celu_pack4.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const float alpha = 0;
2518

2619
#define shape_constant_id_offset 1

src/layer/vulkan/shader/celu_pack8.comp

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
struct sfpvec8 { f16vec4 abcd; f16vec4 efgh; };
20-
#endif
21-
#if NCNN_fp16_arithmetic
22-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
23-
#endif
24-
2517
layout (constant_id = 0) const float alpha = 0;
2618

2719
#define shape_constant_id_offset 1

src/layer/vulkan/shader/clip.comp

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#version 450
1616

17-
#if NCNN_fp16_storage
18-
#extension GL_EXT_shader_16bit_storage: require
19-
#endif
20-
#if NCNN_fp16_arithmetic
21-
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
22-
#endif
23-
2417
layout (constant_id = 0) const float const_min = 0;
2518
layout (constant_id = 1) const float const_max = 0;
2619

0 commit comments

Comments
 (0)