test_glsl_caps.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. from panda3d import core
  2. Shader = core.Shader
  3. Stage = core.Shader.Stage
  4. def compile_and_get_caps(stage, code):
  5. registry = core.ShaderCompilerRegistry.get_global_ptr()
  6. compiler = registry.get_compiler_for_language(Shader.SL_GLSL)
  7. stream = core.StringStream(code.encode('ascii'))
  8. module = compiler.compile_now(stage, stream, 'test-shader')
  9. assert module
  10. assert module.stage == stage
  11. # Mask out this bit, every shader should have it
  12. assert (module.used_capabilities & Shader.C_basic_shader) != 0
  13. return module.used_capabilities & ~Shader.C_basic_shader
  14. def test_legacy_glsl_caps_basic_vertex():
  15. assert compile_and_get_caps(Stage.VERTEX, """
  16. #version 120
  17. void main() {
  18. gl_Position = vec4(0.0);
  19. }
  20. """) == 0
  21. def test_legacy_glsl_caps_basic_fragment():
  22. assert compile_and_get_caps(Stage.VERTEX, """
  23. #version 120
  24. void main() {
  25. gl_FragColor = vec4(0.0);
  26. }
  27. """) == 0
  28. def test_legacy_glsl_caps_unified_model():
  29. assert compile_and_get_caps(Stage.VERTEX, """
  30. #version 130
  31. void main() {
  32. gl_Position = vec4(0.0);
  33. }
  34. """) == Shader.C_unified_model
  35. # Optional extension doesn't trigger it
  36. assert compile_and_get_caps(Stage.VERTEX, """
  37. #version 120
  38. #extension GL_EXT_gpu_shader4 : enable
  39. void main() {
  40. gl_Position = vec4(0.0);
  41. }
  42. """) == 0
  43. # Required extension does
  44. assert compile_and_get_caps(Stage.VERTEX, """
  45. #version 120
  46. #extension GL_EXT_gpu_shader4 : require
  47. void main() {
  48. gl_Position = vec4(0.0);
  49. }
  50. """) == Shader.C_unified_model
  51. # Extension under #if doesn't either
  52. assert compile_and_get_caps(Stage.VERTEX, """
  53. #version 120
  54. #if foobar
  55. #extension GL_EXT_gpu_shader4 : require
  56. #endif
  57. void main() {
  58. gl_Position = vec4(0.0);
  59. }
  60. """) == 0
  61. def test_glsl_caps_basic_vertex():
  62. assert compile_and_get_caps(Stage.VERTEX, """
  63. #version 330
  64. void main() {
  65. gl_Position = vec4(0.0);
  66. }
  67. """) == 0
  68. def test_glsl_caps_basic_fragment():
  69. assert compile_and_get_caps(Stage.FRAGMENT, """
  70. #version 330
  71. out vec4 p3d_FragColor;
  72. void main() {
  73. p3d_FragColor = vec4(1.0);
  74. }
  75. """) == 0
  76. def test_glsl_caps_vertex_texture():
  77. assert compile_and_get_caps(Stage.VERTEX, """
  78. #version 330
  79. uniform sampler2D tex;
  80. void main() {
  81. gl_Position = textureLod(tex, vec2(0.0), 0);
  82. }
  83. """) == Shader.C_vertex_texture
  84. def test_glsl_caps_point_coord():
  85. assert compile_and_get_caps(Stage.FRAGMENT, """
  86. #version 330
  87. out vec4 p3d_FragColor;
  88. void main() {
  89. p3d_FragColor = vec4(gl_PointCoord, 0.0, 1.0);
  90. }
  91. """) == Shader.C_point_coord
  92. def test_glsl_caps_standard_derivatives():
  93. assert compile_and_get_caps(Stage.FRAGMENT, """
  94. #version 330
  95. out vec4 p3d_FragColor;
  96. void main() {
  97. p3d_FragColor = vec4(fwidth(gl_FragCoord.x), 0.0, 0.0, 1.0);
  98. }
  99. """) == Shader.C_standard_derivatives
  100. def test_glsl_caps_shadow_samplers():
  101. assert compile_and_get_caps(Stage.FRAGMENT, """
  102. #version 330
  103. uniform sampler2DShadow a;
  104. void main() {
  105. gl_FragColor = vec4(texture(a, vec3(0.0, 0.0, 0.0)));
  106. }
  107. """) == Shader.C_shadow_samplers
  108. def test_glsl_caps_non_square_matrices():
  109. assert compile_and_get_caps(Stage.VERTEX, """
  110. #version 330
  111. uniform mat3x4 a;
  112. void main() {
  113. gl_Position = a * vec3(1.0);
  114. }
  115. """) == Shader.C_non_square_matrices
  116. def test_glsl_caps_unified_model_uint_uniform():
  117. assert compile_and_get_caps(Stage.VERTEX, """
  118. #version 330
  119. uniform uint a;
  120. void main() {
  121. gl_Position = vec4(float(a));
  122. }
  123. """) == Shader.C_unified_model
  124. def test_glsl_caps_unified_model_int_varying():
  125. assert compile_and_get_caps(Stage.FRAGMENT, """
  126. #version 330
  127. flat in int a;
  128. void main() {
  129. gl_FragColor = vec4(float(a), 0.0, 0.0, 1.0);
  130. }
  131. """) == Shader.C_unified_model
  132. def test_glsl_caps_unified_model_round():
  133. # DO NOT match unified model for regular round()
  134. assert compile_and_get_caps(Stage.VERTEX, """
  135. #version 330
  136. uniform float a;
  137. void main() {
  138. gl_Position = vec4(round(a));
  139. }
  140. """) == 0
  141. # DO match it for roundEven()
  142. assert compile_and_get_caps(Stage.VERTEX, """
  143. #version 330
  144. uniform float a;
  145. void main() {
  146. gl_Position = vec4(roundEven(a));
  147. }
  148. """) == Shader.C_unified_model
  149. def test_glsl_caps_noperspective_interpolation():
  150. assert compile_and_get_caps(Stage.FRAGMENT, """
  151. #version 330
  152. noperspective in vec4 a;
  153. void main() {
  154. gl_FragColor = a;
  155. }
  156. """) == Shader.C_noperspective_interpolation
  157. def test_glsl_caps_texture_array():
  158. assert compile_and_get_caps(Stage.FRAGMENT, """
  159. #version 330
  160. uniform sampler2DArray a;
  161. void main() {
  162. gl_FragColor = texture(a, vec3(0.0));
  163. }
  164. """) == Shader.C_texture_array
  165. def test_glsl_caps_texture_lod():
  166. assert compile_and_get_caps(Stage.FRAGMENT, """
  167. #version 330
  168. uniform sampler2D a;
  169. void main() {
  170. gl_FragColor = textureLod(a, vec2(0.0), 0);
  171. }
  172. """) == Shader.C_texture_lod
  173. def test_glsl_caps_texture_query_size():
  174. # This can be emulated, should NOT have the cap
  175. assert compile_and_get_caps(Stage.FRAGMENT, """
  176. #version 330
  177. uniform sampler1D a;
  178. uniform sampler1D b[2];
  179. struct C {
  180. sampler1D member[2];
  181. };
  182. uniform C c;
  183. struct D {
  184. sampler1D member;
  185. };
  186. uniform D d[2];
  187. void main() {
  188. gl_FragColor = vec4(textureSize(a, 0),
  189. textureSize(b[1], 0),
  190. textureSize(c.member[1], 0),
  191. textureSize(d[1].member, 0));
  192. }
  193. """) == 0
  194. # This can NOT be emulated (at the moment), non-zero LOD level
  195. assert compile_and_get_caps(Stage.FRAGMENT, """
  196. #version 330
  197. uniform sampler2D a;
  198. uniform float i;
  199. void main() {
  200. gl_FragColor = vec4(vec2(textureSize(a, 1)), 0.0, 1.0);
  201. }
  202. """) == Shader.C_texture_query_size
  203. # This can NOT be emulated, non-constant LOD level
  204. assert compile_and_get_caps(Stage.FRAGMENT, """
  205. #version 330
  206. uniform sampler2D a;
  207. uniform float i;
  208. void main() {
  209. gl_FragColor = vec4(vec2(textureSize(a, int(i))), 0.0, 1.0);
  210. }
  211. """) == Shader.C_texture_query_size
  212. # There's no point emulating this for dynamically indexed textures
  213. assert compile_and_get_caps(Stage.FRAGMENT, """
  214. #version 400
  215. uniform sampler2D a[2];
  216. uniform float i;
  217. void main() {
  218. gl_FragColor = vec4(vec2(textureSize(a[int(i)], 0)), 0.0, 1.0);
  219. }
  220. """) == Shader.C_dynamic_indexing | Shader.C_texture_query_size
  221. def test_glsl_caps_sampler_cube_shadow():
  222. # Can be emulated, so does not get the cap for now
  223. assert compile_and_get_caps(Stage.FRAGMENT, """
  224. #version 330
  225. uniform samplerCubeShadow a;
  226. void main() {
  227. gl_FragColor = vec4(texture(a, vec4(0.0)), 0.0, 0.0, 1.0);
  228. }
  229. """) == Shader.C_shadow_samplers# | Shader.C_sampler_cube_shadow
  230. def test_glsl_caps_vertex_id():
  231. assert compile_and_get_caps(Stage.VERTEX, """
  232. #version 330
  233. void main() {
  234. gl_Position = vec4(float(gl_VertexID), 0.0, 0.0, 1.0);
  235. }
  236. """) == Shader.C_vertex_id
  237. def test_glsl_caps_draw_buffers():
  238. assert compile_and_get_caps(Stage.FRAGMENT, """
  239. #version 330
  240. layout(location=0) out vec4 a;
  241. layout(location=1) out vec4 b;
  242. void main() {
  243. a = vec4(1.0, 0.0, 0.0, 1.0);
  244. b = vec4(0.0, 1.0, 0.0, 1.0);
  245. }
  246. """) == Shader.C_draw_buffers
  247. def test_glsl_caps_clip_distance():
  248. assert compile_and_get_caps(Stage.VERTEX, """
  249. #version 330
  250. void main() {
  251. gl_Position = vec4(0.0);
  252. gl_ClipDistance[0] = 0.0;
  253. }
  254. """) == Shader.C_clip_distance
  255. def test_glsl_caps_instance_id():
  256. assert compile_and_get_caps(Stage.VERTEX, """
  257. #version 330
  258. void main() {
  259. gl_Position = vec4(float(gl_InstanceID), 0.0, 0.0, 1.0);
  260. }
  261. """) == Shader.C_instance_id
  262. def test_glsl_caps_geometry_shader():
  263. assert compile_and_get_caps(Stage.GEOMETRY, """
  264. #version 330
  265. layout(triangles) in;
  266. layout(triangle_strip, max_vertices=3) out;
  267. void main() {
  268. gl_Position = gl_in[0].gl_Position;
  269. EmitVertex();
  270. gl_Position = gl_in[1].gl_Position;
  271. EmitVertex();
  272. gl_Position = gl_in[2].gl_Position;
  273. EmitVertex();
  274. EndPrimitive();
  275. }
  276. """) == Shader.C_geometry_shader
  277. def test_glsl_caps_primitive_id():
  278. assert compile_and_get_caps(Stage.FRAGMENT, """
  279. #version 330
  280. void main() {
  281. gl_FragColor = vec4(float(gl_PrimitiveID), 0.0, 0.0, 1.0);
  282. }
  283. """) == Shader.C_primitive_id
  284. def test_glsl_caps_bit_encoding():
  285. assert compile_and_get_caps(Stage.VERTEX, """
  286. #version 330
  287. uniform uint a;
  288. void main() {
  289. gl_Position = vec4(uintBitsToFloat(a));
  290. }
  291. """) == Shader.C_unified_model | Shader.C_bit_encoding
  292. def test_glsl_caps_texture_query_lod():
  293. assert compile_and_get_caps(Stage.FRAGMENT, """
  294. #version 400
  295. uniform sampler2D a;
  296. void main() {
  297. gl_FragColor = vec4(textureQueryLod(a, vec2(0.0)), 0.0, 1.0);
  298. }
  299. """) == Shader.C_texture_query_lod
  300. def test_glsl_caps_texture_gather_red():
  301. assert compile_and_get_caps(Stage.FRAGMENT, """
  302. #version 400
  303. uniform sampler2D a;
  304. void main() {
  305. gl_FragColor = textureGather(a, vec2(0.0)) + textureGather(a, vec2(0.0), 0);
  306. }
  307. """) == Shader.C_texture_gather_red
  308. def test_glsl_caps_texture_gather_any():
  309. assert compile_and_get_caps(Stage.FRAGMENT, """
  310. #version 400
  311. uniform sampler2D a;
  312. void main() {
  313. gl_FragColor = textureGather(a, vec2(0.0), 1);
  314. }
  315. """) == Shader.C_texture_gather_any
  316. def test_glsl_caps_extended_arithmetic():
  317. assert compile_and_get_caps(Stage.FRAGMENT, """
  318. #version 400
  319. uniform uint a;
  320. uniform uint b;
  321. void main() {
  322. uint c;
  323. uint d = uaddCarry(a, b, c);
  324. gl_FragColor = vec4(a, b, c, d);
  325. }
  326. """) == Shader.C_unified_model | Shader.C_extended_arithmetic
  327. def test_glsl_caps_double():
  328. assert compile_and_get_caps(Stage.VERTEX, """
  329. #version 400
  330. uniform double a;
  331. void main() {
  332. gl_Position = vec4(float(a), 0.0, 0.0, 1.0);
  333. }
  334. """) == Shader.C_double
  335. def test_glsl_caps_cube_map_array():
  336. assert compile_and_get_caps(Stage.FRAGMENT, """
  337. #version 400
  338. uniform samplerCubeArray a;
  339. void main() {
  340. gl_FragColor = texture(a, vec4(0.0));
  341. }
  342. """) == Shader.C_texture_array | Shader.C_cube_map_array
  343. def test_glsl_caps_geometry_shader_instancing():
  344. assert compile_and_get_caps(Stage.GEOMETRY, """
  345. #version 400
  346. layout(triangles, invocations=2) in;
  347. layout(triangle_strip, max_vertices=3) out;
  348. void main() {
  349. gl_Position = gl_in[0].gl_Position;
  350. EmitVertex();
  351. gl_Position = gl_in[1].gl_Position;
  352. EmitVertex();
  353. gl_Position = gl_in[2].gl_Position;
  354. EmitVertex();
  355. EndPrimitive();
  356. }
  357. """) == Shader.C_geometry_shader | Shader.C_geometry_shader_instancing
  358. def test_glsl_caps_tessellation_shader():
  359. assert compile_and_get_caps(Stage.TESS_CONTROL, """
  360. #version 400 core
  361. layout (vertices = 3) out;
  362. void main() {
  363. gl_TessLevelOuter[0] = 1;
  364. gl_TessLevelOuter[1] = 1;
  365. gl_TessLevelOuter[2] = 1;
  366. gl_TessLevelInner[0] = 1;
  367. }
  368. """) == Shader.C_tessellation_shader
  369. assert compile_and_get_caps(Stage.TESS_EVALUATION, """
  370. #version 400 core
  371. layout(triangles, equal_spacing, ccw) in;
  372. void main() {
  373. gl_Position = vec4(0.0);
  374. }
  375. """) == Shader.C_tessellation_shader
  376. def test_glsl_caps_sample_variables():
  377. assert compile_and_get_caps(Stage.FRAGMENT, """
  378. #version 330
  379. #extension GL_ARB_sample_shading : require
  380. void main() {
  381. gl_FragColor = vec4(float(gl_SampleID), 0.0, 0.0, 1.0);
  382. }
  383. """) == Shader.C_sample_variables
  384. def test_glsl_caps_multisample_interpolation():
  385. assert compile_and_get_caps(Stage.FRAGMENT, """
  386. #version 400
  387. sample in vec4 a;
  388. out vec4 p3d_FragColor;
  389. void main() {
  390. p3d_FragColor = a;
  391. }
  392. """) == Shader.C_multisample_interpolation
  393. def test_glsl_caps_dynamic_indexing():
  394. assert compile_and_get_caps(Stage.FRAGMENT, """
  395. #version 400
  396. uniform int a;
  397. uniform sampler2D b[3];
  398. out vec4 p3d_FragColor;
  399. void main() {
  400. p3d_FragColor = texture(b[a], vec2(0.0));
  401. }
  402. """) == Shader.C_dynamic_indexing
  403. # NOT dynamic indexing
  404. assert compile_and_get_caps(Stage.FRAGMENT, """
  405. #version 330
  406. const int a = 2;
  407. uniform sampler2D b[3];
  408. out vec4 p3d_FragColor;
  409. void main() {
  410. p3d_FragColor = texture(b[a], vec2(0.0));
  411. }
  412. """) == 0
  413. # Such a simple loop MUST be unrolled!
  414. assert compile_and_get_caps(Stage.FRAGMENT, """
  415. #version 330
  416. #define COUNT 3
  417. struct LightSource {
  418. sampler2D shadowMap;
  419. };
  420. uniform LightSource source[COUNT];
  421. out vec4 p3d_FragColor;
  422. void main() {
  423. vec4 result = vec4(0);
  424. for (int i = 0; i < COUNT; ++i) {
  425. result += texture(source[i].shadowMap, vec2(0.0));
  426. }
  427. p3d_FragColor = result;
  428. }
  429. """) == 0
  430. # This one need not be unrolled.
  431. assert compile_and_get_caps(Stage.FRAGMENT, """
  432. #version 400
  433. #define COUNT 3
  434. struct LightSource {
  435. sampler2D shadowMap;
  436. };
  437. uniform LightSource source[COUNT];
  438. out vec4 p3d_FragColor;
  439. void main() {
  440. vec4 result = vec4(0);
  441. for (int i = 0; i < COUNT; ++i) {
  442. result += texture(source[i].shadowMap, vec2(0.0));
  443. }
  444. p3d_FragColor = result;
  445. }
  446. """) == Shader.C_dynamic_indexing
  447. # This one need not be unrolled either.
  448. assert compile_and_get_caps(Stage.FRAGMENT, """
  449. #version 330
  450. #extension GL_ARB_gpu_shader5 : require
  451. #define COUNT 3
  452. struct LightSource {
  453. sampler2D shadowMap;
  454. };
  455. uniform LightSource source[COUNT];
  456. out vec4 p3d_FragColor;
  457. void main() {
  458. vec4 result = vec4(0);
  459. for (int i = 0; i < COUNT; ++i) {
  460. result += texture(source[i].shadowMap, vec2(0.0));
  461. }
  462. p3d_FragColor = result;
  463. }
  464. """) == Shader.C_dynamic_indexing
  465. def test_glsl_caps_atomic_counters():
  466. assert compile_and_get_caps(Stage.VERTEX, """
  467. #version 420
  468. uniform atomic_uint a;
  469. void main() {
  470. gl_Position = vec4(float(atomicCounter(a)));
  471. }
  472. """) == Shader.C_unified_model | Shader.C_atomic_counters
  473. def test_glsl_caps_image_load_store():
  474. assert compile_and_get_caps(Stage.FRAGMENT, """
  475. #version 420
  476. layout(rgba8) uniform readonly image2D a;
  477. out vec4 p3d_FragColor;
  478. void main() {
  479. p3d_FragColor = imageLoad(a, ivec2(0, 0));
  480. }
  481. """) == Shader.C_image_load_store
  482. def test_glsl_caps_image_buffer():
  483. assert compile_and_get_caps(Stage.FRAGMENT, """
  484. #version 420
  485. layout(rgba8) uniform readonly imageBuffer a;
  486. out vec4 p3d_FragColor;
  487. void main() {
  488. p3d_FragColor = imageLoad(a, 0);
  489. }
  490. """) == Shader.C_image_load_store | Shader.C_texture_buffer
  491. def test_glsl_caps_image_atomic():
  492. assert compile_and_get_caps(Stage.FRAGMENT, """
  493. #version 420
  494. layout(r32i) uniform iimage1D a;
  495. out vec4 p3d_FragColor;
  496. void main() {
  497. imageAtomicExchange(a, 0, 0);
  498. p3d_FragColor = vec4(0.0);
  499. }
  500. """) == Shader.C_image_load_store | Shader.C_image_atomic
  501. def test_glsl_caps_image_query_size():
  502. # Can be emulated
  503. assert compile_and_get_caps(Stage.FRAGMENT, """
  504. #version 420
  505. #extension GL_ARB_shader_image_size : require
  506. uniform writeonly image2D a;
  507. out vec4 p3d_FragColor;
  508. void main() {
  509. p3d_FragColor = vec4(vec2(imageSize(a)), 0.0, 1.0);
  510. }
  511. """) == 0
  512. # Can NOT be emulated (dynamically indexed)
  513. assert compile_and_get_caps(Stage.FRAGMENT, """
  514. #version 420
  515. #extension GL_ARB_shader_image_size : require
  516. uniform writeonly image2D a[2];
  517. uniform int i;
  518. out vec4 p3d_FragColor;
  519. void main() {
  520. p3d_FragColor = vec4(vec2(imageSize(a[i])), 0.0, 1.0);
  521. }
  522. """) == Shader.C_dynamic_indexing | Shader.C_image_query_size
  523. def test_glsl_caps_texture_query_levels():
  524. # Can be emulated
  525. assert compile_and_get_caps(Stage.FRAGMENT, """
  526. #version 430
  527. uniform sampler2D a;
  528. out vec4 p3d_FragColor;
  529. void main() {
  530. p3d_FragColor = vec4(float(textureQueryLevels(a)), 0.0, 0.0, 1.0);
  531. }
  532. """) == 0
  533. # Can NOT be emulated (dynamically indexed)
  534. assert compile_and_get_caps(Stage.FRAGMENT, """
  535. #version 430
  536. uniform sampler2D a[2];
  537. uniform int i;
  538. out vec4 p3d_FragColor;
  539. void main() {
  540. p3d_FragColor = vec4(float(textureQueryLevels(a[i])), 0.0, 0.0, 1.0);
  541. }
  542. """) == Shader.C_dynamic_indexing | Shader.C_texture_query_levels
  543. def test_glsl_caps_storage_buffer():
  544. assert compile_and_get_caps(Stage.VERTEX, """
  545. #version 430
  546. buffer A {
  547. vec4 pos;
  548. } a;
  549. void main() {
  550. gl_Position = a.pos;
  551. }
  552. """) == Shader.C_storage_buffer
  553. # Don't trigger for a regular UBO
  554. assert compile_and_get_caps(Stage.VERTEX, """
  555. #version 430
  556. uniform A {
  557. vec4 pos;
  558. } a;
  559. void main() {
  560. gl_Position = a.pos;
  561. }
  562. """) == 0
  563. def test_glsl_caps_compute_shader():
  564. assert compile_and_get_caps(Stage.COMPUTE, """
  565. #version 430
  566. layout(local_size_x=16, local_size_y=16) in;
  567. void main() {
  568. }
  569. """) == Shader.C_compute_shader
  570. def test_glsl_caps_enhanced_layouts():
  571. assert compile_and_get_caps(Stage.VERTEX, """
  572. #version 450
  573. layout(location=0, component=1) out float a;
  574. void main() {
  575. gl_Position = vec4(0.0);
  576. a = 0.0;
  577. }
  578. """) == Shader.C_enhanced_layouts
  579. def test_glsl_caps_cull_distance():
  580. assert compile_and_get_caps(Stage.VERTEX, """
  581. #version 450
  582. void main() {
  583. gl_Position = vec4(0.0);
  584. gl_CullDistance[0] = 0.0;
  585. }
  586. """) == Shader.C_cull_distance
  587. def test_glsl_caps_derivative_control():
  588. assert compile_and_get_caps(Stage.FRAGMENT, """
  589. #version 450
  590. out vec4 p3d_FragColor;
  591. void main() {
  592. p3d_FragColor = vec4(fwidthFine(gl_FragCoord.x), 0.0, 0.0, 1.0);
  593. }
  594. """) == Shader.C_standard_derivatives | Shader.C_derivative_control
  595. def test_glsl_caps_texture_query_samples():
  596. assert compile_and_get_caps(Stage.FRAGMENT, """
  597. #version 450
  598. uniform sampler2DMS a;
  599. out vec4 p3d_FragColor;
  600. void main() {
  601. p3d_FragColor = vec4(float(textureSamples(a)), 0.0, 0.0, 1.0);
  602. }
  603. """) == Shader.C_texture_query_samples