44
55# ################################################################################
66#
7- # This example demonstrates cuda.core.CUDAArray , TextureObject, and SurfaceObject
7+ # This example demonstrates cuda.core.OpaqueArray , TextureObject, and SurfaceObject
88# in combination with GraphicsResource for CUDA/OpenGL interop. It runs a
99# real-time Stable Fluids (Jos Stam) smoke/ink solver entirely on the GPU:
1010# velocity, pressure, and dye fields live in ping-ponged CUDA arrays, are read
107107 ProgramOptions ,
108108 launch ,
109109)
110- from cuda .core .textures import (
110+ from cuda .core .texture import (
111111 AddressMode ,
112112 ArrayFormat ,
113- CUDAArray ,
113+ OpaqueArray ,
114114 FilterMode ,
115115 ReadMode ,
116116 ResourceDescriptor ,
164164# ============================= Helper functions =============================
165165#
166166# The functions below set up CUDA and OpenGL. If you're here to learn about
167- # CUDAArray /TextureObject/SurfaceObject, skip ahead to main() -- the interesting
167+ # OpaqueArray /TextureObject/SurfaceObject, skip ahead to main() -- the interesting
168168# part is there. These helpers exist so that main() reads like a short story
169169# instead of a wall of boilerplate.
170170# ============================================================================
@@ -248,7 +248,7 @@ def create_window():
248248 window = pyglet .window .Window (
249249 WIDTH ,
250250 HEIGHT ,
251- caption = "cuda.core CUDAArray /Texture/Surface - Stable Fluids" ,
251+ caption = "cuda.core OpaqueArray /Texture/Surface - Stable Fluids" ,
252252 vsync = False ,
253253 )
254254 return window , _gl , pyglet
@@ -397,11 +397,11 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
397397
398398# ============================ API MAP (cuda.core) ===========================
399399#
400- # The three helpers below are where every CUDAArray / ResourceDescriptor /
400+ # The three helpers below are where every OpaqueArray / ResourceDescriptor /
401401# TextureDescriptor / TextureObject / SurfaceObject knob in this example is set.
402402# Each visible setting maps to a concrete piece of cuda.core / CUDA behavior:
403403#
404- # CUDAArray .from_descriptor(...) -> allocates a CUDA *array* (opaque, tiled
404+ # OpaqueArray .from_descriptor(...) -> allocates a CUDA *array* (opaque, tiled
405405# layout optimized for 2D texture fetches),
406406# not linear device memory.
407407# ArrayFormat.FLOAT32 -> each channel is a 32-bit float texel.
@@ -414,7 +414,7 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
414414# is what lets each field be sampled and
415415# then written back in the ping-pong.
416416#
417- # ResourceDescriptor.from_array(arr) -> wraps the CUDAArray as the resource a
417+ # ResourceDescriptor.from_array(arr) -> wraps the OpaqueArray as the resource a
418418# TextureObject reads from.
419419# FilterMode.LINEAR -> free HARDWARE bilinear interpolation;
420420# this is what makes semi-Lagrangian
@@ -438,7 +438,7 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
438438
439439def make_velocity_array ():
440440 """Allocate a `float2` velocity CUDA array (channel 0 = vx, channel 1 = vy)."""
441- return CUDAArray .from_descriptor (
441+ return OpaqueArray .from_descriptor (
442442 shape = (WIDTH , HEIGHT ),
443443 format = ArrayFormat .FLOAT32 ,
444444 num_channels = 2 ,
@@ -448,7 +448,7 @@ def make_velocity_array():
448448
449449def make_scalar_array ():
450450 """Allocate a single-channel `float` CUDA array (pressure / divergence / dye)."""
451- return CUDAArray .from_descriptor (
451+ return OpaqueArray .from_descriptor (
452452 shape = (WIDTH , HEIGHT ),
453453 format = ArrayFormat .FLOAT32 ,
454454 num_channels = 1 ,
@@ -464,7 +464,7 @@ def make_color_array():
464464 surface-write machinery as the scalar fields -- only the channel count
465465 (and the surf2Dwrite byte stride, sizeof(float4) = 16) differ.
466466 """
467- return CUDAArray .from_descriptor (
467+ return OpaqueArray .from_descriptor (
468468 shape = (WIDTH , HEIGHT ),
469469 format = ArrayFormat .FLOAT32 ,
470470 num_channels = 4 ,
@@ -876,7 +876,7 @@ def on_draw():
876876 if now - fps_time >= 1.0 :
877877 fps = frame_count / (now - fps_time )
878878 window .set_caption (
879- "cuda.core CUDAArray /Texture/Surface - Stable Fluids"
879+ "cuda.core OpaqueArray /Texture/Surface - Stable Fluids"
880880 f" ({ WIDTH } x{ HEIGHT } , { fps :.0f} FPS,"
881881 f" { PRESSURE_ITERS } pressure iters)"
882882 " | TextureObject[LINEAR|CLAMP|norm|float2]"
0 commit comments