Exemple #1
0
    def __init__(self, ray_generation_program, exception_program=None, miss_program=None, size=None):
        HasContextMixin.__init__(self, current_context())

        if is_2_string_tuple(ray_generation_program):
            self.ray_generation_program = Program(*ray_generation_program)
        elif isinstance(ray_generation_program, Program):
            self.ray_generation_program = ray_generation_program
        else:
            raise ValueError('Invalid ray generation program given')

        if is_2_string_tuple(exception_program):
            self.exception_program = Program(*exception_program)
        elif isinstance(exception_program, Program) or exception_program is None:
            self.exception_program = exception_program
        else:
            raise ValueError('Invalid exception program given')

        if is_2_string_tuple(miss_program):
            self.miss_program = Program(*miss_program)
        elif isinstance(exception_program, Program) or exception_program is None:
            self.miss_program = miss_program
        else:
            raise ValueError('Invalid exception program given')

        self.size = size
Exemple #2
0
    def __init__(self, builder="NoAccel", traverser="NoAccel", **kwargs):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_accelerator(builder, traverser))
        GraphNodeMixin.__init__(self)

        for key, value in six.iteritems(kwargs):
            self._safe_native.set_property(key, value)
Exemple #3
0
    def __init__(self, buffer_type='io'):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_buffer(convert_buffer_type(buffer_type)))
        BindlessMixin.__init__(self)

        self._numpy_dtype = None
        self._numpy_shape = None
        self._last_dim_dropped = False
Exemple #4
0
    def __init__(self, builder="NoAccel", traverser="NoAccel", **kwargs):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(
            self, self._safe_context._create_accelerator(builder, traverser))
        GraphNodeMixin.__init__(self)

        for key, value in six.iteritems(kwargs):
            self._safe_native.set_property(key, value)
Exemple #5
0
    def __init__(self, bounding_box_program, intersection_program):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self, self._safe_context._create_geometry())
        GraphNodeMixin.__init__(self)

        self._bounding_box_program = None
        self._intersection_program = None

        self.set_bounding_box_program(bounding_box_program)
        self.set_intersection_program(intersection_program)
Exemple #6
0
    def __init__(self, children=None):
        from pyoptix.acceleration import Acceleration
        from pyoptix.geometry_instance import GeometryInstance

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_geometry_group())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [Acceleration, GeometryInstance], children)

        self._acceleration = None
Exemple #7
0
    def __init__(self, children=None):
        from pyoptix.geometry_group import GeometryGroup
        from pyoptix.group import Group
        from pyoptix.selector import Selector

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_transform())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [GeometryGroup, Group, Selector, Transform], children)

        self._transpose = False
Exemple #8
0
    def __init__(self, children=None):
        from pyoptix.acceleration import Acceleration
        from pyoptix.geometry_instance import GeometryInstance

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self,
                                   self._safe_context._create_geometry_group())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [Acceleration, GeometryInstance], children)

        self._acceleration = None
Exemple #9
0
    def __init__(self, children=None):
        from pyoptix.geometry_group import GeometryGroup
        from pyoptix.group import Group
        from pyoptix.transform import Transform

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_selector())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [GeometryGroup, Group, Selector, Transform], children)

        self._visit_program = None
Exemple #10
0
    def __init__(self, buffer_type='io'):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(
            self,
            self._safe_context._create_buffer(
                convert_buffer_type(buffer_type)))
        BindlessMixin.__init__(self)

        self._numpy_dtype = None
        self._numpy_shape = None
        self._last_dim_dropped = False
Exemple #11
0
    def __init__(self, children=None):
        from pyoptix.acceleration import Acceleration
        from pyoptix.geometry_group import GeometryGroup
        from pyoptix.selector import Selector
        from pyoptix.transform import Transform

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_group())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [GeometryGroup, Group, Selector, Transform, Acceleration], children)

        self._acceleration = None
Exemple #12
0
    def __init__(self, children=None):
        from pyoptix.geometry_group import GeometryGroup
        from pyoptix.group import Group
        from pyoptix.transform import Transform

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_selector())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [GeometryGroup, Group, Selector, Transform],
                             children)

        self._visit_program = None
Exemple #13
0
    def __init__(self, children=None):
        from pyoptix.geometry_group import GeometryGroup
        from pyoptix.group import Group
        from pyoptix.selector import Selector

        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self,
                                   self._safe_context._create_transform())
        GraphNodeMixin.__init__(self)
        ParentMixin.__init__(self, [GeometryGroup, Group, Selector, Transform],
                             children)

        self._transpose = False
Exemple #14
0
    def get_or_create(cls, file_path, function_name):
        file_path = Compiler.get_abs_program_path(file_path)
        cache_key = (file_path, function_name)
        context = current_context()

        if cache_key not in context.program_cache:
            # create new if it does not exist in cache
            context.program_cache[cache_key] = cls(file_path, function_name)
        elif not Compiler.is_ptx(file_path) and Program.dynamic_programs:
            # check if the source file was changed. it is compiled if it was changed
            ptx_path, is_compiled = Compiler.compile(file_path)

            # recreate program object if it was changed
            if is_compiled:
                context.program_cache[cache_key] = cls(ptx_path, function_name)

        return context.program_cache[cache_key]
Exemple #15
0
    def get_or_create(cls, file_path, function_name):
        file_path = Compiler.get_abs_program_path(file_path)
        cache_key = (file_path, function_name)
        context = current_context()

        if cache_key not in context.program_cache:
            # create new if it does not exist in cache
            context.program_cache[cache_key] = cls(file_path, function_name)
        elif not Compiler.is_ptx(file_path) and Program.dynamic_programs:
            # check if the source file was changed. it is compiled if it was changed
            ptx_path, is_compiled = Compiler.compile(file_path)

            # recreate program object if it was changed
            if is_compiled:
                context.program_cache[cache_key] = cls(ptx_path, function_name)

        return context.program_cache[cache_key]
Exemple #16
0
    def __init__(self, file_path, function_name, output_ptx_name=None):
        HasContextMixin.__init__(self, current_context())
        self._function_name = function_name

        file_path = Compiler.get_abs_program_path(file_path)

        if Compiler.is_ptx(file_path):
            self._ptx_path = file_path
        else:
            # if not ptx, compile to ptx
            self._ptx_path, _ = Compiler.compile(file_path, output_ptx_name)

        # Create program object from compiled file
        ScopedObject.__init__(self, self._safe_context._create_program_from_file(self._ptx_path, self._function_name))
        BindlessMixin.__init__(self)

        self._safe_context.program_cache[(file_path, function_name)] = self
Exemple #17
0
    def __init__(self, ray_generation_program, exception_program=None, size=None):
        HasContextMixin.__init__(self, current_context())

        if is_2_string_tuple(ray_generation_program):
            self.ray_generation_program = Program(*ray_generation_program)
        elif isinstance(ray_generation_program, Program):
            self.ray_generation_program = ray_generation_program
        else:
            raise ValueError('Invalid ray generation program given')

        if is_2_string_tuple(exception_program):
            self.exception_program = Program(*exception_program)
        elif isinstance(exception_program, Program) or exception_program is None:
            self.exception_program = exception_program
        else:
            raise ValueError('Invalid exception program given')

        self.size = size
Exemple #18
0
    def __init__(self, closest_hit=None, any_hit=None):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self, self._safe_context._create_material())
        GraphNodeMixin.__init__(self)

        self._closest_hit_programs = {}
        self._any_hit_programs = {}

        if closest_hit is None:
            closest_hit = {}
        if any_hit is None:
            any_hit = {}

        for index, program in six.iteritems(closest_hit):
            self.set_closest_hit_program(index, program)

        for index, program in six.iteritems(any_hit):
            self.set_any_hit_program(index, program)
Exemple #19
0
    def __init__(self,
                 buffer,
                 wrap_mode=None,
                 indexing_mode=None,
                 read_mode=None,
                 filter_mode=None,
                 max_anisotropy=1):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(
            self, self._safe_context._create_texture_sampler())
        BindlessMixin.__init__(self)

        self._buffer = None
        self._filtering_mode_minification = None
        self._filtering_mode_magnification = None
        self._filtering_mode_mipmapping = None

        if indexing_mode is not None:
            self.set_indexing_mode(indexing_mode)

        if wrap_mode is not None:
            self.set_wrap_mode(0, wrap_mode)
            self.set_wrap_mode(1, wrap_mode)
            self.set_wrap_mode(2, wrap_mode)

        if read_mode is not None:
            self.set_read_mode(read_mode)

        if filter_mode is not None:
            if OPTIX_VERSION >= 3090 and buffer.get_mip_level_count() > 1:
                self.set_filtering_modes(filter_mode, filter_mode, filter_mode)
            else:
                self.set_filtering_modes(filter_mode, filter_mode,
                                         FilterMode.none)

        self._safe_native.set_max_anisotropy(max_anisotropy)

        if OPTIX_VERSION < 3090:
            # required with OptiX < 3.9.0
            self._safe_native.set_mip_level_count(1)
            self._safe_native.set_array_size(1)

        self.set_buffer(0, 0, buffer)
Exemple #20
0
    def __init__(self, file_path, function_name, output_ptx_name=None):
        HasContextMixin.__init__(self, current_context())
        self._function_name = function_name

        file_path = Compiler.get_abs_program_path(file_path)

        if Compiler.is_ptx(file_path):
            self._ptx_path = file_path
        else:
            # if not ptx, compile to ptx
            self._ptx_path, _ = Compiler.compile(file_path, output_ptx_name)

        # Create program object from compiled file
        ScopedObject.__init__(
            self,
            self._safe_context._create_program_from_file(
                self._ptx_path, self._function_name))
        BindlessMixin.__init__(self)

        self._safe_context.program_cache[(file_path, function_name)] = self
Exemple #21
0
    def __init__(self, geometry=None, materials=None):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self, self._safe_context._create_geometry_instance())
        GraphNodeMixin.__init__(self)

        self._geometry = None
        self._materials = []

        if geometry is not None and isinstance(geometry, Geometry):
            self.set_geometry(geometry)

        if materials is not None:
            # allow single material parameter
            if isinstance(materials, Material):
                materials = [materials]

            if not isinstance(materials, list):
                raise TypeError('materials parameter must be a list')

            self._safe_native.set_material_count(len(materials))
            for idx, material in enumerate(materials):
                self.set_material(idx, material)
Exemple #22
0
    def __init__(self, geometry=None, materials=None):
        HasContextMixin.__init__(self, current_context())
        ScopedObject.__init__(self,
                              self._safe_context._create_geometry_instance())
        GraphNodeMixin.__init__(self)

        self._geometry = None
        self._materials = []

        if geometry is not None and isinstance(geometry, Geometry):
            self.set_geometry(geometry)

        if materials is not None:
            # allow single material parameter
            if isinstance(materials, Material):
                materials = [materials]

            if not isinstance(materials, list):
                raise TypeError('materials parameter must be a list')

            self._safe_native.set_material_count(len(materials))
            for idx, material in enumerate(materials):
                self.set_material(idx, material)
Exemple #23
0
    def __init__(self, buffer, wrap_mode=None, indexing_mode=None,
                 read_mode=None, filter_mode=None, max_anisotropy=1):
        HasContextMixin.__init__(self, current_context())
        DestroyableObject.__init__(self, self._safe_context._create_texture_sampler())
        BindlessMixin.__init__(self)

        self._buffer = None
        self._filtering_mode_minification = None
        self._filtering_mode_magnification = None
        self._filtering_mode_mipmapping = None

        if indexing_mode is not None:
            self.set_indexing_mode(indexing_mode)

        if wrap_mode is not None:
            self.set_wrap_mode(0, wrap_mode)
            self.set_wrap_mode(1, wrap_mode)
            self.set_wrap_mode(2, wrap_mode)

        if read_mode is not None:
            self.set_read_mode(read_mode)

        if filter_mode is not None:
            if OPTIX_VERSION >= 3090 and buffer.get_mip_level_count() > 1:
                self.set_filtering_modes(filter_mode, filter_mode, filter_mode)
            else:
                self.set_filtering_modes(filter_mode, filter_mode, FilterMode.none)

        self._safe_native.set_max_anisotropy(max_anisotropy)

        if OPTIX_VERSION < 3090:
            # required with OptiX < 3.9.0
            self._safe_native.set_mip_level_count(1)
            self._safe_native.set_array_size(1)

        self.set_buffer(0, 0, buffer)