From ac3ac3ddff777ad4fd0ebcf9243137891fe29c0f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 13 Sep 2020 12:58:47 +0200 Subject: [PATCH] shader: introduce a crude setting for adjusting the maximum workgroup size Both the Vulkan and OpenGL ES spec allow implementations to limit workgroups to 128 threads. Add a LG_WG_FACTOR setting for easy switching between 128 and 256 threads, with 256 being kept as the default setting. Manually tested that LG_WG_FACTOR = 0 (128 threads) works as expected. Signed-off-by: Elias Naur --- piet-gpu/shader/backdrop.comp | 2 +- piet-gpu/shader/coarse.comp | 2 +- piet-gpu/shader/elements.spv | Bin 52964 -> 52988 bytes piet-gpu/shader/setup.h | 9 +++++++-- piet-gpu/shader/tile_alloc.comp | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/piet-gpu/shader/backdrop.comp b/piet-gpu/shader/backdrop.comp index afe4d62..beba683 100644 --- a/piet-gpu/shader/backdrop.comp +++ b/piet-gpu/shader/backdrop.comp @@ -15,7 +15,7 @@ #include "setup.h" -#define LG_BACKDROP_WG 8 +#define LG_BACKDROP_WG (7 + LG_WG_FACTOR) #define BACKDROP_WG (1 << LG_BACKDROP_WG) layout(local_size_x = BACKDROP_WG, local_size_y = 1) in; diff --git a/piet-gpu/shader/coarse.comp b/piet-gpu/shader/coarse.comp index 56b3c07..57cbc8b 100644 --- a/piet-gpu/shader/coarse.comp +++ b/piet-gpu/shader/coarse.comp @@ -41,7 +41,7 @@ layout(set = 0, binding = 4) buffer PtclBuf { #include "tile.h" #include "ptcl.h" -#define LG_N_PART_READ 8 +#define LG_N_PART_READ (7 + LG_WG_FACTOR) #define N_PART_READ (1 << LG_N_PART_READ) shared uint sh_elements[N_TILE]; diff --git a/piet-gpu/shader/elements.spv b/piet-gpu/shader/elements.spv index 5bd0650bf9e65af7056d2d68ac333bd7d2dc744a..54c5cc0f645353bfc360465a3037aa6a2ef29745 100644 GIT binary patch delta 982 zcmZ9K%}Z2K7{=f0ovTK=7}||SkOXN$;6_9gLTK$jAToj0z@#EYM8ZfoD@BCCh3TYy zX_7XL*UWDrZPBt_+n`;m_6Gf)%RT7GaJbLMd*1V$_ss92e_HhG{i>!KGtX-IeJj`h zX~?~-H5-2XsDE@|&;m=?JNQU?H2u&l;wu;U2l!wno5ha&wF*D55NVX`?4qKKrnPFhXzRYb@0a7A={(lb*; z$APAZj*r0=(Q)-tJjdlLp7>cu-#vjNu2s75`+RU`kGXLl`xv=Bg3RFf{g zn`qMGBKr(hlfQ8jan-m(wxUUYLD^!tNpFLtouBj$T>AM*@4}@ko~A19CcO`Klhz+f zT;4O19Dn+a delta 1011 zcmZ9KTT4`76o%J0j!lHYTvrH5P$2}}h=f7)2l@vxfyRJoND)ym70#6rfppPfI%jq? z+a0E|Agzo3LAOD7U3C)$1wGGZzET-B`#r30?e|-2em9F>o5k*8NAH@5LX`P^nD73! zq24S?@Wa)K>Y<37&#dD2;Ul%tQS97*u);6JV|aCJY<#F)WY5exlAv%HO%cmr<4#HR`o zMob(SMoj!9+=z+W&v=RJ8&AH63*IY5wr@wXzutpz5u<@v0bd56Sw5tUk9sw22ZxNo8_qIh6CEq!70pJV2u1j zE>Uh%y*pqvLpUwD-Xz{#up#xFoP2;!lPPAw=XrZZ?-%M`0{@KZ9|zahA0q99deouH z2gtaUBagrbc&qEX1hsVcIk4ISHR%iq{32(q@3I4_8 zdM60>7Hmk*`FE42CA^ScI#k>*_6LA8Y-?e*rnX Bmze+n diff --git a/piet-gpu/shader/setup.h b/piet-gpu/shader/setup.h index 6c778ca..6bdde03 100644 --- a/piet-gpu/shader/setup.h +++ b/piet-gpu/shader/setup.h @@ -3,6 +3,11 @@ // Much of this will be made dynamic in various ways, but for now it's easiest // to hardcode and keep all in one place. +// A LG_WG_FACTOR of n scales workgroup sizes by 2^n. Use 0 for a +// maximum workgroup size of 128, or 1 for a maximum size of 256. +#define LG_WG_FACTOR 1 +#define WG_FACTOR (1<