2
0

shaderc.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. --
  2. -- Copyright 2010-2025 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. --
  5. group "tools/shaderc"
  6. local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer")
  7. local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp")
  8. local GLSLANG = path.join(BGFX_DIR, "3rdparty/glslang")
  9. local SPIRV_CROSS = path.join(BGFX_DIR, "3rdparty/spirv-cross")
  10. local SPIRV_HEADERS = path.join(BGFX_DIR, "3rdparty/spirv-headers")
  11. local SPIRV_TOOLS = path.join(BGFX_DIR, "3rdparty/spirv-tools")
  12. project "spirv-opt"
  13. kind "StaticLib"
  14. includedirs {
  15. SPIRV_TOOLS,
  16. path.join(SPIRV_TOOLS, "include"),
  17. path.join(SPIRV_TOOLS, "include/generated"),
  18. path.join(SPIRV_TOOLS, "source"),
  19. path.join(SPIRV_HEADERS, "include"),
  20. }
  21. files {
  22. path.join(SPIRV_TOOLS, "source/opt/**.cpp"),
  23. path.join(SPIRV_TOOLS, "source/opt/**.h"),
  24. path.join(SPIRV_TOOLS, "source/reduce/**.cpp"),
  25. path.join(SPIRV_TOOLS, "source/reduce/**.h"),
  26. path.join(SPIRV_TOOLS, "source/val/**.cpp"),
  27. path.join(SPIRV_TOOLS, "source/val/**.h"),
  28. -- libspirv
  29. path.join(SPIRV_TOOLS, "source/assembly_grammar.cpp"),
  30. path.join(SPIRV_TOOLS, "source/assembly_grammar.h"),
  31. path.join(SPIRV_TOOLS, "source/binary.cpp"),
  32. path.join(SPIRV_TOOLS, "source/binary.h"),
  33. path.join(SPIRV_TOOLS, "source/cfa.h"),
  34. path.join(SPIRV_TOOLS, "source/diagnostic.cpp"),
  35. path.join(SPIRV_TOOLS, "source/diagnostic.h"),
  36. path.join(SPIRV_TOOLS, "source/disassemble.cpp"),
  37. path.join(SPIRV_TOOLS, "source/disassemble.h"),
  38. path.join(SPIRV_TOOLS, "source/enum_set.h"),
  39. path.join(SPIRV_TOOLS, "source/ext_inst.cpp"),
  40. path.join(SPIRV_TOOLS, "source/ext_inst.h"),
  41. path.join(SPIRV_TOOLS, "source/extensions.cpp"),
  42. path.join(SPIRV_TOOLS, "source/extensions.h"),
  43. path.join(SPIRV_TOOLS, "source/instruction.h"),
  44. path.join(SPIRV_TOOLS, "source/latest_version_glsl_std_450_header.h"),
  45. path.join(SPIRV_TOOLS, "source/latest_version_opencl_std_header.h"),
  46. path.join(SPIRV_TOOLS, "source/latest_version_spirv_header.h"),
  47. path.join(SPIRV_TOOLS, "source/libspirv.cpp"),
  48. path.join(SPIRV_TOOLS, "source/macro.h"),
  49. path.join(SPIRV_TOOLS, "source/name_mapper.cpp"),
  50. path.join(SPIRV_TOOLS, "source/name_mapper.h"),
  51. path.join(SPIRV_TOOLS, "source/opcode.cpp"),
  52. path.join(SPIRV_TOOLS, "source/opcode.h"),
  53. path.join(SPIRV_TOOLS, "source/operand.cpp"),
  54. path.join(SPIRV_TOOLS, "source/operand.h"),
  55. path.join(SPIRV_TOOLS, "source/parsed_operand.cpp"),
  56. path.join(SPIRV_TOOLS, "source/parsed_operand.h"),
  57. path.join(SPIRV_TOOLS, "source/print.cpp"),
  58. path.join(SPIRV_TOOLS, "source/print.h"),
  59. path.join(SPIRV_TOOLS, "source/software_version.cpp"),
  60. path.join(SPIRV_TOOLS, "source/spirv_constant.h"),
  61. path.join(SPIRV_TOOLS, "source/spirv_definition.h"),
  62. path.join(SPIRV_TOOLS, "source/spirv_endian.cpp"),
  63. path.join(SPIRV_TOOLS, "source/spirv_endian.h"),
  64. path.join(SPIRV_TOOLS, "source/spirv_optimizer_options.cpp"),
  65. path.join(SPIRV_TOOLS, "source/spirv_reducer_options.cpp"),
  66. path.join(SPIRV_TOOLS, "source/spirv_target_env.cpp"),
  67. path.join(SPIRV_TOOLS, "source/spirv_target_env.h"),
  68. path.join(SPIRV_TOOLS, "source/spirv_validator_options.cpp"),
  69. path.join(SPIRV_TOOLS, "source/spirv_validator_options.h"),
  70. path.join(SPIRV_TOOLS, "source/table.cpp"),
  71. path.join(SPIRV_TOOLS, "source/table.h"),
  72. path.join(SPIRV_TOOLS, "source/table2.cpp"),
  73. path.join(SPIRV_TOOLS, "source/table2.h"),
  74. path.join(SPIRV_TOOLS, "source/text.cpp"),
  75. path.join(SPIRV_TOOLS, "source/text.h"),
  76. path.join(SPIRV_TOOLS, "source/text_handler.cpp"),
  77. path.join(SPIRV_TOOLS, "source/text_handler.h"),
  78. path.join(SPIRV_TOOLS, "source/to_string.cpp"),
  79. path.join(SPIRV_TOOLS, "source/to_string.h"),
  80. path.join(SPIRV_TOOLS, "source/util/bit_vector.cpp"),
  81. path.join(SPIRV_TOOLS, "source/util/bit_vector.h"),
  82. path.join(SPIRV_TOOLS, "source/util/bitutils.h"),
  83. path.join(SPIRV_TOOLS, "source/util/hex_float.h"),
  84. path.join(SPIRV_TOOLS, "source/util/parse_number.cpp"),
  85. path.join(SPIRV_TOOLS, "source/util/parse_number.h"),
  86. path.join(SPIRV_TOOLS, "source/util/string_utils.cpp"),
  87. path.join(SPIRV_TOOLS, "source/util/string_utils.h"),
  88. path.join(SPIRV_TOOLS, "source/util/timer.h"),
  89. }
  90. configuration { "vs*" }
  91. buildoptions {
  92. "/wd4127", -- warning C4127: conditional expression is constant
  93. "/wd4267", -- warning C4267: 'argument': conversion from '' to '', possible loss of data
  94. "/wd4389", -- warning C4389: '==': signed/unsigned mismatch
  95. "/wd4702", -- warning C4702: unreachable code
  96. "/wd4706", -- warning C4706: assignment within conditional expression
  97. }
  98. configuration { "mingw* or linux* or osx*" }
  99. buildoptions {
  100. "-Wno-switch",
  101. }
  102. configuration { "mingw* or linux-gcc-*" }
  103. buildoptions {
  104. "-Wno-misleading-indentation",
  105. }
  106. configuration {}
  107. project "spirv-cross"
  108. kind "StaticLib"
  109. defines {
  110. "SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS",
  111. }
  112. includedirs {
  113. path.join(SPIRV_CROSS, "include"),
  114. }
  115. files {
  116. path.join(SPIRV_CROSS, "spirv.hpp"),
  117. path.join(SPIRV_CROSS, "spirv_cfg.cpp"),
  118. path.join(SPIRV_CROSS, "spirv_cfg.hpp"),
  119. path.join(SPIRV_CROSS, "spirv_common.hpp"),
  120. path.join(SPIRV_CROSS, "spirv_cpp.cpp"),
  121. path.join(SPIRV_CROSS, "spirv_cpp.hpp"),
  122. path.join(SPIRV_CROSS, "spirv_cross.cpp"),
  123. path.join(SPIRV_CROSS, "spirv_cross.hpp"),
  124. path.join(SPIRV_CROSS, "spirv_cross_parsed_ir.cpp"),
  125. path.join(SPIRV_CROSS, "spirv_cross_parsed_ir.hpp"),
  126. path.join(SPIRV_CROSS, "spirv_cross_util.cpp"),
  127. path.join(SPIRV_CROSS, "spirv_cross_util.hpp"),
  128. path.join(SPIRV_CROSS, "spirv_glsl.cpp"),
  129. path.join(SPIRV_CROSS, "spirv_glsl.hpp"),
  130. path.join(SPIRV_CROSS, "spirv_hlsl.cpp"),
  131. path.join(SPIRV_CROSS, "spirv_hlsl.hpp"),
  132. path.join(SPIRV_CROSS, "spirv_msl.cpp"),
  133. path.join(SPIRV_CROSS, "spirv_msl.hpp"),
  134. path.join(SPIRV_CROSS, "spirv_parser.cpp"),
  135. path.join(SPIRV_CROSS, "spirv_parser.hpp"),
  136. path.join(SPIRV_CROSS, "spirv_reflect.cpp"),
  137. path.join(SPIRV_CROSS, "spirv_reflect.hpp"),
  138. }
  139. configuration { "vs*" }
  140. buildoptions {
  141. "/wd4018", -- warning C4018: '<': signed/unsigned mismatch
  142. "/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
  143. "/wd4706", -- warning C4706: assignment within conditional expression
  144. "/wd4715", -- warning C4715: '': not all control paths return a value
  145. }
  146. configuration { "mingw* or linux* or osx*" }
  147. buildoptions {
  148. "-Wno-type-limits",
  149. }
  150. configuration {}
  151. project "glslang"
  152. kind "StaticLib"
  153. defines {
  154. "ENABLE_OPT=1", -- spirv-tools
  155. "ENABLE_HLSL=1",
  156. }
  157. includedirs {
  158. GLSLANG,
  159. path.join(GLSLANG, ".."),
  160. path.join(SPIRV_TOOLS, "include"),
  161. path.join(SPIRV_TOOLS, "source"),
  162. }
  163. files {
  164. path.join(GLSLANG, "glslang/**.cpp"),
  165. path.join(GLSLANG, "glslang/**.h"),
  166. path.join(GLSLANG, "hlsl/**.cpp"),
  167. path.join(GLSLANG, "hlsl/**.h"),
  168. path.join(GLSLANG, "SPIRV/**.cpp"),
  169. path.join(GLSLANG, "SPIRV/**.h"),
  170. path.join(GLSLANG, "OGLCompilersDLL/**.cpp"),
  171. path.join(GLSLANG, "OGLCompilersDLL/**.h"),
  172. }
  173. configuration { "windows" }
  174. removefiles {
  175. path.join(GLSLANG, "glslang/OSDependent/Unix/**.cpp"),
  176. path.join(GLSLANG, "glslang/OSDependent/Unix/**.h"),
  177. }
  178. configuration { "not windows" }
  179. removefiles {
  180. path.join(GLSLANG, "glslang/OSDependent/Windows/**.cpp"),
  181. path.join(GLSLANG, "glslang/OSDependent/Windows/**.h"),
  182. }
  183. configuration { "vs*" }
  184. buildoptions {
  185. "/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition
  186. "/wd4065", -- warning C4065: switch statement contains 'default' but no 'case' labels
  187. "/wd4100", -- warning C4100: 'inclusionDepth' : unreferenced formal parameter
  188. "/wd4127", -- warning C4127: conditional expression is constant
  189. "/wd4189", -- warning C4189: 'isFloat': local variable is initialized but not referenced
  190. "/wd4244", -- warning C4244: '=': conversion from 'int' to 'char', possible loss of data
  191. "/wd4310", -- warning C4310: cast truncates constant value
  192. "/wd4389", -- warning C4389: '==': signed/unsigned mismatch
  193. "/wd4456", -- warning C4456: declaration of 'feature' hides previous local declaration
  194. "/wd4457", -- warning C4457: declaration of 'token' hides function parameter
  195. "/wd4458", -- warning C4458: declaration of 'language' hides class member
  196. "/wd4702", -- warning C4702: unreachable code
  197. "/wd4715", -- warning C4715: 'spv::Builder::makeFpConstant': not all control paths return a value
  198. "/wd4838", -- warning C4838: conversion from 'spv::GroupOperation' to 'unsigned int' requires a narrowing conversion
  199. }
  200. configuration { "mingw-gcc or linux-gcc" }
  201. buildoptions {
  202. "-Wno-logical-op",
  203. "-Wno-maybe-uninitialized",
  204. }
  205. configuration { "mingw* or linux* or osx*" }
  206. buildoptions {
  207. "-fno-strict-aliasing", -- glslang has bugs if strict aliasing is used.
  208. "-Wno-ignored-qualifiers",
  209. "-Wno-implicit-fallthrough",
  210. "-Wno-missing-field-initializers",
  211. "-Wno-reorder",
  212. "-Wno-return-type",
  213. "-Wno-shadow",
  214. "-Wno-sign-compare",
  215. "-Wno-switch",
  216. "-Wno-undef",
  217. "-Wno-unknown-pragmas",
  218. "-Wno-unused-function",
  219. "-Wno-unused-parameter",
  220. "-Wno-unused-variable",
  221. }
  222. configuration { "osx*" }
  223. buildoptions {
  224. "-Wno-c++11-extensions",
  225. "-Wno-unused-const-variable",
  226. "-Wno-deprecated-register",
  227. }
  228. configuration { "linux-gcc-*" }
  229. buildoptions {
  230. "-Wno-unused-but-set-variable",
  231. }
  232. configuration {}
  233. project "glsl-optimizer"
  234. kind "StaticLib"
  235. includedirs {
  236. path.join(GLSL_OPTIMIZER, "src"),
  237. path.join(GLSL_OPTIMIZER, "include"),
  238. path.join(GLSL_OPTIMIZER, "src/mesa"),
  239. path.join(GLSL_OPTIMIZER, "src/mapi"),
  240. path.join(GLSL_OPTIMIZER, "src/glsl"),
  241. }
  242. files {
  243. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.h"),
  244. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-lex.c"),
  245. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-parse.c"),
  246. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-parse.h"),
  247. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/pp.c"),
  248. path.join(GLSL_OPTIMIZER, "src/glsl/ast.h"),
  249. path.join(GLSL_OPTIMIZER, "src/glsl/ast_array_index.cpp"),
  250. path.join(GLSL_OPTIMIZER, "src/glsl/ast_expr.cpp"),
  251. path.join(GLSL_OPTIMIZER, "src/glsl/ast_function.cpp"),
  252. path.join(GLSL_OPTIMIZER, "src/glsl/ast_to_hir.cpp"),
  253. path.join(GLSL_OPTIMIZER, "src/glsl/ast_type.cpp"),
  254. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_functions.cpp"),
  255. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_type_macros.h"),
  256. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_types.cpp"),
  257. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_variables.cpp"),
  258. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_lexer.cpp"),
  259. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_optimizer.cpp"),
  260. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_optimizer.h"),
  261. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser.cpp"),
  262. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser.h"),
  263. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser_extras.cpp"),
  264. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser_extras.h"),
  265. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_symbol_table.cpp"),
  266. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_symbol_table.h"),
  267. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_types.cpp"),
  268. path.join(GLSL_OPTIMIZER, "src/glsl/glsl_types.h"),
  269. path.join(GLSL_OPTIMIZER, "src/glsl/hir_field_selection.cpp"),
  270. path.join(GLSL_OPTIMIZER, "src/glsl/ir.cpp"),
  271. path.join(GLSL_OPTIMIZER, "src/glsl/ir.h"),
  272. path.join(GLSL_OPTIMIZER, "src/glsl/ir_basic_block.cpp"),
  273. path.join(GLSL_OPTIMIZER, "src/glsl/ir_basic_block.h"),
  274. path.join(GLSL_OPTIMIZER, "src/glsl/ir_builder.cpp"),
  275. path.join(GLSL_OPTIMIZER, "src/glsl/ir_builder.h"),
  276. path.join(GLSL_OPTIMIZER, "src/glsl/ir_clone.cpp"),
  277. path.join(GLSL_OPTIMIZER, "src/glsl/ir_constant_expression.cpp"),
  278. path.join(GLSL_OPTIMIZER, "src/glsl/ir_equals.cpp"),
  279. path.join(GLSL_OPTIMIZER, "src/glsl/ir_expression_flattening.cpp"),
  280. path.join(GLSL_OPTIMIZER, "src/glsl/ir_expression_flattening.h"),
  281. path.join(GLSL_OPTIMIZER, "src/glsl/ir_function.cpp"),
  282. path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_can_inline.cpp"),
  283. path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_detect_recursion.cpp"),
  284. path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_inlining.h"),
  285. path.join(GLSL_OPTIMIZER, "src/glsl/ir_hierarchical_visitor.cpp"),
  286. path.join(GLSL_OPTIMIZER, "src/glsl/ir_hierarchical_visitor.h"),
  287. path.join(GLSL_OPTIMIZER, "src/glsl/ir_hv_accept.cpp"),
  288. path.join(GLSL_OPTIMIZER, "src/glsl/ir_import_prototypes.cpp"),
  289. path.join(GLSL_OPTIMIZER, "src/glsl/ir_optimization.h"),
  290. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_glsl_visitor.cpp"),
  291. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_glsl_visitor.h"),
  292. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_metal_visitor.cpp"),
  293. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_metal_visitor.h"),
  294. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_visitor.cpp"),
  295. path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_visitor.h"),
  296. path.join(GLSL_OPTIMIZER, "src/glsl/ir_rvalue_visitor.cpp"),
  297. path.join(GLSL_OPTIMIZER, "src/glsl/ir_rvalue_visitor.h"),
  298. path.join(GLSL_OPTIMIZER, "src/glsl/ir_stats.cpp"),
  299. path.join(GLSL_OPTIMIZER, "src/glsl/ir_stats.h"),
  300. path.join(GLSL_OPTIMIZER, "src/glsl/ir_uniform.h"),
  301. path.join(GLSL_OPTIMIZER, "src/glsl/ir_unused_structs.cpp"),
  302. path.join(GLSL_OPTIMIZER, "src/glsl/ir_unused_structs.h"),
  303. path.join(GLSL_OPTIMIZER, "src/glsl/ir_validate.cpp"),
  304. path.join(GLSL_OPTIMIZER, "src/glsl/ir_variable_refcount.cpp"),
  305. path.join(GLSL_OPTIMIZER, "src/glsl/ir_variable_refcount.h"),
  306. path.join(GLSL_OPTIMIZER, "src/glsl/ir_visitor.h"),
  307. path.join(GLSL_OPTIMIZER, "src/glsl/link_atomics.cpp"),
  308. path.join(GLSL_OPTIMIZER, "src/glsl/link_functions.cpp"),
  309. path.join(GLSL_OPTIMIZER, "src/glsl/link_interface_blocks.cpp"),
  310. path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_block_active_visitor.cpp"),
  311. path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_block_active_visitor.h"),
  312. path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_blocks.cpp"),
  313. path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_initializers.cpp"),
  314. path.join(GLSL_OPTIMIZER, "src/glsl/link_uniforms.cpp"),
  315. path.join(GLSL_OPTIMIZER, "src/glsl/link_varyings.cpp"),
  316. path.join(GLSL_OPTIMIZER, "src/glsl/link_varyings.h"),
  317. path.join(GLSL_OPTIMIZER, "src/glsl/linker.cpp"),
  318. path.join(GLSL_OPTIMIZER, "src/glsl/linker.h"),
  319. path.join(GLSL_OPTIMIZER, "src/glsl/list.h"),
  320. path.join(GLSL_OPTIMIZER, "src/glsl/loop_analysis.cpp"),
  321. path.join(GLSL_OPTIMIZER, "src/glsl/loop_analysis.h"),
  322. path.join(GLSL_OPTIMIZER, "src/glsl/loop_controls.cpp"),
  323. path.join(GLSL_OPTIMIZER, "src/glsl/loop_unroll.cpp"),
  324. path.join(GLSL_OPTIMIZER, "src/glsl/lower_clip_distance.cpp"),
  325. path.join(GLSL_OPTIMIZER, "src/glsl/lower_discard.cpp"),
  326. path.join(GLSL_OPTIMIZER, "src/glsl/lower_discard_flow.cpp"),
  327. path.join(GLSL_OPTIMIZER, "src/glsl/lower_if_to_cond_assign.cpp"),
  328. path.join(GLSL_OPTIMIZER, "src/glsl/lower_instructions.cpp"),
  329. path.join(GLSL_OPTIMIZER, "src/glsl/lower_jumps.cpp"),
  330. path.join(GLSL_OPTIMIZER, "src/glsl/lower_mat_op_to_vec.cpp"),
  331. path.join(GLSL_OPTIMIZER, "src/glsl/lower_named_interface_blocks.cpp"),
  332. path.join(GLSL_OPTIMIZER, "src/glsl/lower_noise.cpp"),
  333. path.join(GLSL_OPTIMIZER, "src/glsl/lower_offset_array.cpp"),
  334. path.join(GLSL_OPTIMIZER, "src/glsl/lower_output_reads.cpp"),
  335. path.join(GLSL_OPTIMIZER, "src/glsl/lower_packed_varyings.cpp"),
  336. path.join(GLSL_OPTIMIZER, "src/glsl/lower_packing_builtins.cpp"),
  337. path.join(GLSL_OPTIMIZER, "src/glsl/lower_ubo_reference.cpp"),
  338. path.join(GLSL_OPTIMIZER, "src/glsl/lower_variable_index_to_cond_assign.cpp"),
  339. path.join(GLSL_OPTIMIZER, "src/glsl/lower_vec_index_to_cond_assign.cpp"),
  340. path.join(GLSL_OPTIMIZER, "src/glsl/lower_vec_index_to_swizzle.cpp"),
  341. path.join(GLSL_OPTIMIZER, "src/glsl/lower_vector.cpp"),
  342. path.join(GLSL_OPTIMIZER, "src/glsl/lower_vector_insert.cpp"),
  343. path.join(GLSL_OPTIMIZER, "src/glsl/lower_vertex_id.cpp"),
  344. path.join(GLSL_OPTIMIZER, "src/glsl/opt_algebraic.cpp"),
  345. path.join(GLSL_OPTIMIZER, "src/glsl/opt_array_splitting.cpp"),
  346. path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_folding.cpp"),
  347. path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_propagation.cpp"),
  348. path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_variable.cpp"),
  349. path.join(GLSL_OPTIMIZER, "src/glsl/opt_copy_propagation.cpp"),
  350. path.join(GLSL_OPTIMIZER, "src/glsl/opt_copy_propagation_elements.cpp"),
  351. path.join(GLSL_OPTIMIZER, "src/glsl/opt_cse.cpp"),
  352. path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_builtin_variables.cpp"),
  353. path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_builtin_varyings.cpp"),
  354. path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_code.cpp"),
  355. path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_code_local.cpp"),
  356. path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_functions.cpp"),
  357. path.join(GLSL_OPTIMIZER, "src/glsl/opt_flatten_nested_if_blocks.cpp"),
  358. path.join(GLSL_OPTIMIZER, "src/glsl/opt_flip_matrices.cpp"),
  359. path.join(GLSL_OPTIMIZER, "src/glsl/opt_function_inlining.cpp"),
  360. path.join(GLSL_OPTIMIZER, "src/glsl/opt_if_simplification.cpp"),
  361. path.join(GLSL_OPTIMIZER, "src/glsl/opt_minmax.cpp"),
  362. path.join(GLSL_OPTIMIZER, "src/glsl/opt_noop_swizzle.cpp"),
  363. path.join(GLSL_OPTIMIZER, "src/glsl/opt_rebalance_tree.cpp"),
  364. path.join(GLSL_OPTIMIZER, "src/glsl/opt_redundant_jumps.cpp"),
  365. path.join(GLSL_OPTIMIZER, "src/glsl/opt_structure_splitting.cpp"),
  366. path.join(GLSL_OPTIMIZER, "src/glsl/opt_swizzle_swizzle.cpp"),
  367. path.join(GLSL_OPTIMIZER, "src/glsl/opt_tree_grafting.cpp"),
  368. path.join(GLSL_OPTIMIZER, "src/glsl/opt_vectorize.cpp"),
  369. path.join(GLSL_OPTIMIZER, "src/glsl/program.h"),
  370. path.join(GLSL_OPTIMIZER, "src/glsl/s_expression.cpp"),
  371. path.join(GLSL_OPTIMIZER, "src/glsl/s_expression.h"),
  372. path.join(GLSL_OPTIMIZER, "src/glsl/standalone_scaffolding.cpp"),
  373. path.join(GLSL_OPTIMIZER, "src/glsl/standalone_scaffolding.h"),
  374. path.join(GLSL_OPTIMIZER, "src/glsl/strtod.c"),
  375. path.join(GLSL_OPTIMIZER, "src/glsl/strtod.h"),
  376. path.join(GLSL_OPTIMIZER, "src/mesa/main/compiler.h"),
  377. path.join(GLSL_OPTIMIZER, "src/mesa/main/config.h"),
  378. path.join(GLSL_OPTIMIZER, "src/mesa/main/context.h"),
  379. path.join(GLSL_OPTIMIZER, "src/mesa/main/core.h"),
  380. path.join(GLSL_OPTIMIZER, "src/mesa/main/dd.h"),
  381. path.join(GLSL_OPTIMIZER, "src/mesa/main/errors.h"),
  382. path.join(GLSL_OPTIMIZER, "src/mesa/main/glheader.h"),
  383. path.join(GLSL_OPTIMIZER, "src/mesa/main/glminimal.h"),
  384. path.join(GLSL_OPTIMIZER, "src/mesa/main/imports.c"),
  385. path.join(GLSL_OPTIMIZER, "src/mesa/main/imports.h"),
  386. path.join(GLSL_OPTIMIZER, "src/mesa/main/macros.h"),
  387. path.join(GLSL_OPTIMIZER, "src/mesa/main/mtypes.h"),
  388. path.join(GLSL_OPTIMIZER, "src/mesa/main/simple_list.h"),
  389. path.join(GLSL_OPTIMIZER, "src/mesa/program/hash_table.h"),
  390. path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_hash_table.c"),
  391. path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_instruction.h"),
  392. path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_parameter.h"),
  393. path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_statevars.h"),
  394. path.join(GLSL_OPTIMIZER, "src/mesa/program/symbol_table.c"),
  395. path.join(GLSL_OPTIMIZER, "src/mesa/program/symbol_table.h"),
  396. path.join(GLSL_OPTIMIZER, "src/util/hash_table.c"),
  397. path.join(GLSL_OPTIMIZER, "src/util/hash_table.h"),
  398. path.join(GLSL_OPTIMIZER, "src/util/macros.h"),
  399. path.join(GLSL_OPTIMIZER, "src/util/ralloc.c"),
  400. path.join(GLSL_OPTIMIZER, "src/util/ralloc.h"),
  401. }
  402. removefiles {
  403. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
  404. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
  405. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
  406. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
  407. path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
  408. path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
  409. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
  410. }
  411. removeflags {
  412. "FloatFast", -- clang 17 has issues errors originating in glsl-optimizer when float optimizations are enabled
  413. }
  414. configuration { "Release" }
  415. flags {
  416. "Optimize",
  417. }
  418. removeflags {
  419. -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
  420. "OptimizeSpeed",
  421. }
  422. configuration { "vs*" }
  423. includedirs {
  424. path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
  425. }
  426. defines { -- glsl-optimizer
  427. "__STDC__",
  428. "__STDC_VERSION__=199901L",
  429. "strdup=_strdup",
  430. "alloca=_alloca",
  431. "isascii=__isascii",
  432. }
  433. buildoptions {
  434. "/wd4100", -- error C4100: '' : unreferenced formal parameter
  435. "/wd4127", -- warning C4127: conditional expression is constant
  436. "/wd4132", -- warning C4132: 'deleted_key_value': const object should be initialized
  437. "/wd4189", -- warning C4189: 'interface_type': local variable is initialized but not referenced
  438. "/wd4204", -- warning C4204: nonstandard extension used: non-constant aggregate initializer
  439. "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
  440. "/wd4389", -- warning C4389: '!=': signed/unsigned mismatch
  441. "/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
  442. "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
  443. "/wd4702", -- warning C4702: unreachable code
  444. "/wd4706", -- warning C4706: assignment within conditional expression
  445. "/wd4996", -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
  446. }
  447. configuration { "mingw* or linux* or osx*" }
  448. buildoptions {
  449. "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used.
  450. "-Wno-implicit-fallthrough",
  451. "-Wno-parentheses",
  452. "-Wno-sign-compare",
  453. "-Wno-unused-function",
  454. "-Wno-unused-parameter",
  455. }
  456. removebuildoptions {
  457. "-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it.
  458. }
  459. configuration { "osx*" }
  460. buildoptions {
  461. "-Wno-deprecated-register",
  462. }
  463. configuration { "mingw* or linux-gcc-*" }
  464. buildoptions {
  465. "-Wno-misleading-indentation",
  466. }
  467. configuration {}
  468. project "fcpp"
  469. kind "StaticLib"
  470. defines { -- fcpp
  471. "NINCLUDE=64",
  472. "NWORK=65536",
  473. "NBUFF=65536",
  474. "OLD_PREPROCESSOR=0",
  475. -- "MSG_PREFIX=\"Preprocessor: \"",
  476. }
  477. files {
  478. path.join(FCPP_DIR, "**.h"),
  479. path.join(FCPP_DIR, "cpp1.c"),
  480. path.join(FCPP_DIR, "cpp2.c"),
  481. path.join(FCPP_DIR, "cpp3.c"),
  482. path.join(FCPP_DIR, "cpp4.c"),
  483. path.join(FCPP_DIR, "cpp5.c"),
  484. path.join(FCPP_DIR, "cpp6.c"),
  485. path.join(FCPP_DIR, "cpp6.c"),
  486. }
  487. configuration { "vs*" }
  488. buildoptions {
  489. "/wd4055", -- warning C4055: 'type cast': from data pointer 'void *' to function pointer 'void (__cdecl *)(char *,void *)'
  490. "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
  491. "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
  492. "/wd4706", -- warning C4706: assignment within conditional expression
  493. }
  494. configuration { "not vs*" }
  495. buildoptions {
  496. "-Wno-implicit-fallthrough",
  497. "-Wno-incompatible-pointer-types",
  498. "-Wno-parentheses-equality",
  499. }
  500. configuration {}
  501. project "shaderc"
  502. kind "ConsoleApp"
  503. includedirs {
  504. path.join(BIMG_DIR, "include"),
  505. path.join(BGFX_DIR, "include"),
  506. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  507. FCPP_DIR,
  508. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Public"),
  509. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Include"),
  510. path.join(BGFX_DIR, "3rdparty/glslang"),
  511. path.join(GLSL_OPTIMIZER, "include"),
  512. path.join(GLSL_OPTIMIZER, "src/glsl"),
  513. SPIRV_CROSS,
  514. path.join(SPIRV_TOOLS, "include"),
  515. }
  516. links {
  517. "fcpp",
  518. "glslang",
  519. "glsl-optimizer",
  520. "spirv-opt",
  521. "spirv-cross",
  522. }
  523. using_bx()
  524. files {
  525. path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
  526. path.join(BGFX_DIR, "tools/shaderc/**.h"),
  527. path.join(BGFX_DIR, "src/vertexlayout.**"),
  528. path.join(BGFX_DIR, "src/shader**"),
  529. }
  530. configuration { "mingw-*" }
  531. targetextension ".exe"
  532. configuration { "osx*" }
  533. links {
  534. "Cocoa.framework",
  535. }
  536. configuration { "vs*" }
  537. includedirs {
  538. path.join(GLSL_OPTIMIZER, "include/c99"),
  539. }
  540. configuration { "vs20* or mingw*" }
  541. links {
  542. "psapi",
  543. }
  544. configuration { "osx* or linux*" }
  545. links {
  546. "pthread",
  547. }
  548. configuration {}
  549. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
  550. path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then
  551. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
  552. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then
  553. removefiles {
  554. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"),
  555. }
  556. end
  557. dofile(path.join(BGFX_DIR, "../bgfx-gnm/scripts/shaderc.lua") )
  558. end
  559. strip()
  560. group "tools"