shaderc.lua 24 KB

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