Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions warp/_src/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7617,7 +7617,8 @@ def texture_sample_2d_dispatch_func(input_types: Mapping[str, type], return_type
# texture_sample for 2D textures with vec2 coordinates
add_builtin(
"texture_sample",
input_types={"tex": Texture2D, "uv": vec2f, "dtype": Any},
input_types={"tex": Texture2D, "uv": vec2f, "dtype": Any, "load": float},
defaults={"load": 0.0},
value_func=texture_sample_2d_value_func,
export_func=lambda input_types: {k: v for k, v in input_types.items() if k != "dtype"},
dispatch_func=texture_sample_2d_dispatch_func,
Comment on lines 7617 to 7624
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stubs missing load

This PR adds load as an optional argument to texture_sample, but the generated type stubs (warp/__init__.pyi) still only expose the pre-existing overloads without load. That mismatch will cause IDE/typechecker errors for valid calls like wp.texture_sample(..., load=lod). Regenerate/update the stubs to include load: float = 0.0 for all texture_sample overloads (2D/3D, vec and scalar forms).

Expand All @@ -7630,6 +7631,7 @@ def texture_sample_2d_dispatch_func(input_types: Mapping[str, type], return_type
uv: UV coordinates as a :class:`warp.vec2f`. Range is [0, 1] if the texture was created with
``normalized_coords=True`` (default), or [0, width] x [0, height] if ``normalized_coords=False``.
dtype: The return type (``float``, :class:`warp.vec2f`, or :class:`warp.vec4f`).
load: Level of detail for mipmapped textures. Default is 0.0 (no mipmaps).

Returns:
The sampled value of the specified ``dtype``.
Expand All @@ -7641,7 +7643,8 @@ def texture_sample_2d_dispatch_func(input_types: Mapping[str, type], return_type
# texture_sample for 2D textures with separate u, v coordinates
add_builtin(
"texture_sample",
input_types={"tex": Texture2D, "u": float, "v": float, "dtype": Any},
input_types={"tex": Texture2D, "u": float, "v": float, "dtype": Any, "load": float},
defaults={"load": 0.0},
value_func=texture_sample_2d_value_func,
export_func=lambda input_types: {k: v for k, v in input_types.items() if k != "dtype"},
dispatch_func=texture_sample_2d_dispatch_func,
Expand All @@ -7656,6 +7659,7 @@ def texture_sample_2d_dispatch_func(input_types: Mapping[str, type], return_type
v: V coordinate. Range is [0, 1] if the texture was created with
``normalized_coords=True`` (default), or [0, height] if ``normalized_coords=False``.
dtype: The return type (``float``, :class:`warp.vec2f`, or :class:`warp.vec4f`).
load: Level of detail for mipmapped textures. Default is 0.0 (no mipmaps).

Returns:
The sampled value of the specified ``dtype``.
Expand Down Expand Up @@ -7686,7 +7690,8 @@ def texture_sample_3d_dispatch_func(input_types: Mapping[str, type], return_type
# texture_sample for 3D textures with vec3 coordinates
add_builtin(
"texture_sample",
input_types={"tex": Texture3D, "uvw": vec3f, "dtype": Any},
input_types={"tex": Texture3D, "uvw": vec3f, "dtype": Any, "load": float},
defaults={"load": 0.0},
value_func=texture_sample_3d_value_func,
export_func=lambda input_types: {k: v for k, v in input_types.items() if k != "dtype"},
dispatch_func=texture_sample_3d_dispatch_func,
Expand All @@ -7699,6 +7704,7 @@ def texture_sample_3d_dispatch_func(input_types: Mapping[str, type], return_type
uvw: UVW coordinates as a :class:`warp.vec3f`. Range is [0, 1] if the texture was created with
``normalized_coords=True`` (default), or [0, width] x [0, height] x [0, depth] if ``normalized_coords=False``.
dtype: The return type (``float``, :class:`warp.vec2f`, or :class:`warp.vec4f`).
load: Level of detail for mipmapped textures. Default is 0.0 (no mipmaps).

Returns:
The sampled value of the specified ``dtype``.
Expand All @@ -7710,7 +7716,8 @@ def texture_sample_3d_dispatch_func(input_types: Mapping[str, type], return_type
# texture_sample for 3D textures with separate u, v, w coordinates
add_builtin(
"texture_sample",
input_types={"tex": Texture3D, "u": float, "v": float, "w": float, "dtype": Any},
input_types={"tex": Texture3D, "u": float, "v": float, "w": float, "dtype": Any, "load": float},
defaults={"load": 0.0},
value_func=texture_sample_3d_value_func,
export_func=lambda input_types: {k: v for k, v in input_types.items() if k != "dtype"},
dispatch_func=texture_sample_3d_dispatch_func,
Expand All @@ -7727,6 +7734,7 @@ def texture_sample_3d_dispatch_func(input_types: Mapping[str, type], return_type
w: W coordinate. Range is [0, 1] if the texture was created with
``normalized_coords=True`` (default), or [0, depth] if ``normalized_coords=False``.
dtype: The return type (``float``, :class:`warp.vec2f`, or :class:`warp.vec4f`).
load: Level of detail for mipmapped textures. Default is 0.0 (no mipmaps).

Returns:
The sampled value of the specified ``dtype``.
Expand Down
22 changes: 22 additions & 0 deletions warp/_src/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4341,19 +4341,25 @@ def __init__(self):
ctypes.c_int, # num_channels
ctypes.c_int, # dtype (0=uint8, 1=uint16, 2=float32)
ctypes.c_int, # filter_mode
ctypes.c_int, # mip_filter_mode
ctypes.c_int, # address_mode_u
ctypes.c_int, # address_mode_v
ctypes.c_bool, # use_normalized_coords
ctypes.c_int, # num_mip_levels
ctypes.c_void_p, # data
ctypes.POINTER(ctypes.c_int32), # mip_widths
ctypes.POINTER(ctypes.c_int32), # mip_heights
ctypes.POINTER(ctypes.c_uint64), # tex_handle_out
ctypes.POINTER(ctypes.c_uint64), # array_handle_out
ctypes.POINTER(ctypes.c_uint64), # mipmap_handle_out
]
self.core.wp_texture2d_create_device.restype = ctypes.c_bool

self.core.wp_texture2d_destroy_device.argtypes = [
ctypes.c_void_p, # context
ctypes.c_uint64, # tex_handle
ctypes.c_uint64, # array_handle
ctypes.c_uint64, # mipmap_handle
]
self.core.wp_texture2d_destroy_device.restype = None

Expand All @@ -4365,20 +4371,27 @@ def __init__(self):
ctypes.c_int, # num_channels
ctypes.c_int, # dtype (0=uint8, 1=uint16, 2=float32)
ctypes.c_int, # filter_mode
ctypes.c_int, # mip_filter_mode
ctypes.c_int, # address_mode_u
ctypes.c_int, # address_mode_v
ctypes.c_int, # address_mode_w
ctypes.c_bool, # use_normalized_coords
ctypes.c_int, # num_mip_levels
ctypes.c_void_p, # data
ctypes.POINTER(ctypes.c_int32), # mip_widths
ctypes.POINTER(ctypes.c_int32), # mip_heights
ctypes.POINTER(ctypes.c_int32), # mip_depths
ctypes.POINTER(ctypes.c_uint64), # tex_handle_out
ctypes.POINTER(ctypes.c_uint64), # array_handle_out
ctypes.POINTER(ctypes.c_uint64), # mipmap_handle_out
]
self.core.wp_texture3d_create_device.restype = ctypes.c_bool

self.core.wp_texture3d_destroy_device.argtypes = [
ctypes.c_void_p, # context
ctypes.c_uint64, # tex_handle
ctypes.c_uint64, # array_handle
ctypes.c_uint64, # mipmap_handle
]
self.core.wp_texture3d_destroy_device.restype = None

Expand All @@ -4389,10 +4402,14 @@ def __init__(self):
ctypes.c_int, # num_channels
ctypes.c_int, # dtype (0=uint8, 1=uint16, 2=float32)
ctypes.c_int, # filter_mode
ctypes.c_int, # mip_filter_mode
ctypes.c_int, # address_mode_u
ctypes.c_int, # address_mode_v
ctypes.c_bool, # use_normalized_coords
ctypes.c_int, # num_mip_levels
ctypes.c_void_p, # data
ctypes.POINTER(ctypes.c_int32), # mip_widths
ctypes.POINTER(ctypes.c_int32), # mip_heights
ctypes.POINTER(ctypes.c_uint64), # tex_handle_out
]
self.core.wp_texture2d_create_host.restype = ctypes.c_bool
Expand All @@ -4409,11 +4426,16 @@ def __init__(self):
ctypes.c_int, # num_channels
ctypes.c_int, # dtype (0=uint8, 1=uint16, 2=float32)
ctypes.c_int, # filter_mode
ctypes.c_int, # mip_filter_mode
ctypes.c_int, # address_mode_u
ctypes.c_int, # address_mode_v
ctypes.c_int, # address_mode_w
ctypes.c_bool, # use_normalized_coords
ctypes.c_int, # num_mip_levels
ctypes.c_void_p, # data
ctypes.POINTER(ctypes.c_int32), # mip_widths
ctypes.POINTER(ctypes.c_int32), # mip_heights
ctypes.POINTER(ctypes.c_int32), # mip_depths
ctypes.POINTER(ctypes.c_uint64), # tex_handle_out
]
self.core.wp_texture3d_create_host.restype = ctypes.c_bool
Expand Down
Loading