# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/texture/_surface.pyx

from __future__ import annotations


class SurfaceObject:
    """A bindless surface handle for kernel-side typed load/store.

    Wraps ``cuSurfObjectCreate``. Unlike a :class:`TextureObject`, a surface
    has no sampling state (no filtering, no addressing modes, no normalization);
    kernels read and write through it using integer pixel coordinates.

    The backing :class:`OpaqueArray` must have been created with
    ``is_surface_load_store=True`` and is kept alive for the lifetime of this
    object to prevent dangling handles.

    Construct via :meth:`cuda.core.Device.create_surface_object`. Passes to
    kernels as a 64-bit handle (via the ``handle`` property).

    .. versionadded:: 1.1.0
    """

    def close(self):
        """Release this object's reference to the underlying ``CUsurfObject``.

        Destruction (``cuSurfObjectDestroy``) and release of the backing array
        happen via the handle's deleter when the last reference is dropped.
        Idempotent.
        """

    def __init__(self, *args, **kwargs):
        ...

    @property
    def handle(self):
        """The underlying ``CUsurfObject`` as an integer (64-bit kernel arg)."""

    @property
    def resource(self):
        """The :class:`ResourceDescriptor` this surface was built from."""

    @property
    def device(self):
        ...

    def __enter__(self):
        ...

    def __exit__(self, exc_type, exc, tb):
        ...

    def __repr__(self):
        ...

def _create_surface_object(resource):
    """Create a :class:`SurfaceObject` on the current device.

    Backs :meth:`cuda.core.Device.create_surface_object`. ``resource`` must be a
    :class:`ResourceDescriptor` wrapping an :class:`OpaqueArray` allocated with
    ``is_surface_load_store=True``; linear/pitch2d resources are not valid
    surface backings.
    """