]> git.nega.tv - josh/narcissus/commitdiff
shark: Use consts instead of defines in shaders
authorJosh Simmons <josh@nega.tv>
Sun, 2 Jun 2024 10:14:59 +0000 (12:14 +0200)
committerJosh Simmons <josh@nega.tv>
Sun, 2 Jun 2024 10:14:59 +0000 (12:14 +0200)
title/shark-shaders/shaders/primitive_2d.h
title/shark-shaders/shaders/primitive_2d_bin.comp.glsl

index b8a3d0c161ffb8a1ecd84b2a255288d7152934d2..46df2fd096e497c730d40034ff59ac92db318d6f 100644 (file)
@@ -1,11 +1,11 @@
-#define TILE_SIZE 32
-
-#define MAX_PRIMS (1 << 18)
-#define TILE_BITMAP_L1_WORDS (MAX_PRIMS / 32 / 32)
-#define TILE_BITMAP_L0_WORDS (MAX_PRIMS / 32)
-#define TILE_STRIDE (TILE_BITMAP_L0_WORDS + TILE_BITMAP_L1_WORDS)
-#define TILE_BITMAP_L1_OFFSET 0
-#define TILE_BITMAP_L0_OFFSET TILE_BITMAP_L1_WORDS
+const uint TILE_SIZE = 32;
+
+const uint MAX_PRIMS = 1 << 18;
+const uint TILE_BITMAP_L1_WORDS = (MAX_PRIMS / 32 / 32);
+const uint TILE_BITMAP_L0_WORDS = (MAX_PRIMS / 32);
+const uint TILE_STRIDE = (TILE_BITMAP_L0_WORDS + TILE_BITMAP_L1_WORDS);
+const uint TILE_BITMAP_L1_OFFSET = 0;
+const uint TILE_BITMAP_L0_OFFSET = TILE_BITMAP_L1_WORDS;
 
 struct PrimitiveUniforms {
     uvec2 screen_resolution;
index 6ac6edc538d264e8815fb2a629d60a3a2fffa001..12ddab41202ab410c67ca8593e2edc4e629b5937 100644 (file)
@@ -10,8 +10,8 @@
 
 #include "primitive_2d.h"
 
-#define SUBGROUP_SIZE 64
-#define NUM_PRIMS_WG (SUBGROUP_SIZE * 32)
+const uint SUBGROUP_SIZE = 64;
+const uint NUM_PRIMS_WG = (SUBGROUP_SIZE * 32);
 
 // TODO: Spec constant support for different subgroup sizes.
 layout (local_size_x = SUBGROUP_SIZE, local_size_y = 1, local_size_z = 1) in;