From 2e85d1d1f59ac85d0d0d5607a4dfab2c54d3e3ae Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Tue, 14 Jan 2020 18:48:18 +0100
Subject: [PATCH] Remove TextureAccess

---
 pystencils/interpolation_astnodes.py | 35 ++--------------------------
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/pystencils/interpolation_astnodes.py b/pystencils/interpolation_astnodes.py
index b14e07be1..7ef2f2586 100644
--- a/pystencils/interpolation_astnodes.py
+++ b/pystencils/interpolation_astnodes.py
@@ -230,10 +230,10 @@ class InterpolatorAccess(TypedSymbol):
         field = self.field
 
         default_int_type = create_type('int64')
-        use_textures = isinstance(self, TextureAccess)
+        use_textures = isinstance(self.interpolator, TextureCachedField)
         if use_textures:
             def absolute_access(x, _):
-                return self.texture.at((o for o in x))
+                return self.symbol.interpolator.at((o for o in x))
         else:
             absolute_access = field.absolute_access
 
@@ -407,12 +407,6 @@ class TextureCachedField:
         obj = cls(interpolator.field, interpolator.address_mode, interpolation_mode=interpolator.interpolation_mode)
         return obj
 
-    def at(self, offset):
-        return TextureAccess(self.symbol, *offset)
-
-    def __getitem__(self, offset):
-        return TextureAccess(self.symbol, *offset)
-
     def __str__(self):
         return '%s_texture_%s' % (self.field.name, self.reproducible_hash)
 
@@ -436,30 +430,6 @@ class TextureCachedField:
         return _hash(str(self._hashable_contents).encode()).hexdigest()
 
 
-class TextureAccess(InterpolatorAccess):
-    def __new__(cls, texture_symbol, *offsets, **kwargs):
-        obj = TextureAccess.__xnew_cached_(cls, texture_symbol, *offsets, **kwargs)
-        return obj
-
-    def __new_stage2__(self, symbol, *offsets):
-        obj = super().__xnew__(self, symbol, *offsets)
-        obj.required_global_declarations = symbol.interpolator.required_global_declarations
-        obj.required_global_declarations[0]._symbols_defined.add(obj)
-        return obj
-
-    def __str__(self):
-        return '%s_texture(%s)' % (self.interpolator.field.name, ', '.join(str(o) for o in self.offsets))
-
-    @property
-    def texture(self):
-        return self.interpolator
-
-    # noinspection SpellCheckingInspection
-    __xnew__ = staticmethod(__new_stage2__)
-    # noinspection SpellCheckingInspection
-    __xnew_cached_ = staticmethod(cacheit(__new_stage2__))
-
-
 class TextureDeclaration(Node):
     """
     A global declaration of a texture. Visible both for device and host code.
@@ -534,4 +504,3 @@ def dtype_supports_textures(dtype):
         return dtype().itemsize <= 4
 
     return dtype.itemsize <= 4
-
-- 
GitLab