11
11
12
12
# Rendering constants for Vulkan compatibility
13
13
class RenderingConstants :
14
- """Centralized rendering constants for consistent visual appearance."""
14
+ """
15
+ Centralized rendering constants for consistent visual appearance across GPU backends.
16
+
17
+ These constants ensure consistent rendering between Vulkan and OpenGL backends,
18
+ particularly for geometry-based rendering on Vulkan where traditional point/line
19
+ primitives have limitations.
20
+
21
+ Vulkan Compatibility Notes:
22
+ - Point sizes are used for triangle geometry (rectangles/cubes)
23
+ - Line widths apply to POLYLINE_UNIFORM_COLOR shader uniforms
24
+ - Dash patterns create actual geometry gaps rather than shader effects
25
+ """
15
26
16
27
# Point sizes for Vulkan geometry-based rendering
17
28
VULKAN_POINT_2D_SIZE = 0.06 # Size of 2D point rectangles
@@ -27,12 +38,32 @@ class RenderingConstants:
27
38
28
39
@classmethod
29
40
def dash_pattern_length (cls ):
30
- """Total length of one dash pattern (dash + gap)."""
41
+ """
42
+ Calculate total length of one complete dash pattern.
43
+
44
+ Returns:
45
+ float: Combined length of dash + gap for pattern calculations
46
+ """
31
47
return cls .DASH_LENGTH + cls .GAP_LENGTH
32
48
33
49
# GPU Backend detection cache
34
50
class BackendCache :
35
- """Cache GPU backend detection to avoid repeated expensive queries."""
51
+ """
52
+ Performance cache for GPU backend detection to avoid repeated expensive queries.
53
+
54
+ The gpu.platform.backend_type_get() call is expensive and happens frequently
55
+ during rendering operations. This cache stores the result after the first call
56
+ and provides fast subsequent access.
57
+
58
+ Thread Safety:
59
+ This cache is designed for single-threaded use within Blender's main thread.
60
+
61
+ Usage:
62
+ if BackendCache.is_vulkan():
63
+ # Use Vulkan-specific rendering path
64
+ else:
65
+ # Use OpenGL fallback
66
+ """
36
67
_backend_type = None
37
68
_is_vulkan = None
38
69
0 commit comments