progs/gallium/python: Try to fix most regressions.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:08:05 +0000 (15:08 +0900)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:32:23 +0000 (15:32 +0900)
Not enough for retrace to work again though.

progs/gallium/python/retrace/interpreter.py
progs/gallium/python/samples/gs.py
progs/gallium/python/samples/tri.py
progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py
progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py
progs/gallium/python/tests/surface_copy.py
progs/gallium/python/tests/texture_blit.py
progs/gallium/python/tests/texture_render.py
progs/gallium/python/tests/texture_transfer.py

index 1a9618125535768250f054924229e3d7719d1f05..60253cfd1a4b8e0ca9b5568a4b370bb43a457c45 100755 (executable)
@@ -109,6 +109,8 @@ struct_factories = {
     "pipe_vertex_element": gallium.VertexElement,
     "pipe_viewport_state": gallium.Viewport,
     #"pipe_texture": gallium.Texture,
+    'pipe_subresource': gallium.pipe_subresource,
+    'pipe_box': gallium.pipe_box,
 }
 
 
@@ -185,14 +187,8 @@ class Global(Object):
         self.interpreter = interpreter
         self.real = real
         
-    def pipe_winsys_create(self):
-        return Winsys(self.interpreter, gallium.Device())
-
-    def pipe_screen_create(self, winsys=None):
-        if winsys is None:
-            real = gallium.Device()
-        else:
-            real = winsys.real
+    def pipe_screen_create(self):
+        real = gallium.Device()
         return Screen(self.interpreter, real)
     
     def pipe_context_create(self, screen):
@@ -200,59 +196,13 @@ class Global(Object):
         return Context(self.interpreter, context)
 
     
-class Winsys(Object):
-    
-    def __init__(self, interpreter, real):
-        self.interpreter = interpreter
-        self.real = real
-
-    def get_name(self):
-        pass
-    
-    def user_buffer_create(self, data, size):
-        # We don't really care to distinguish between user and regular buffers
-        buffer = self.real.buffer_create(size, 
-                                         4, 
-                                         gallium.PIPE_BUFFER_USAGE_CPU_READ |
-                                         gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
-        assert size == len(data)
-        buffer.write(data)
-        return buffer
-    
-    def buffer_create(self, alignment, usage, size):
-        return self.real.buffer_create(size, alignment, usage)
-    
-    def buffer_destroy(self, buffer):
-        pass
-    
-    def buffer_write(self, buffer, data, size):
-        assert size == len(data)
-        buffer.write(data)
-        
-    def fence_finish(self, fence, flags):
-        pass
-    
-    def fence_reference(self, dst, src):
-        pass
-    
-    def flush_frontbuffer(self, surface):
-        pass
-
-    def surface_alloc(self):
-        return None
-    
-    def surface_release(self, surface):
-        pass
-
-
 class Transfer:
 
-    def __init__(self, surface, x, y, w, h):
-        self.surface = surface
-        self.x = x
-        self.y = y
-        self.w = w
-        self.h = h
+    def __init__(self, resource, usage, subresource, box):
+        self.resource = resource
+        self.usage = usage
+        self.subresource = subresource
+        self.box = box
 
 
 class Screen(Object):
@@ -276,18 +226,18 @@ class Screen(Object):
         context = self.real.context_create()
         return Context(self.interpreter, context)
     
-    def is_format_supported(self, format, target, tex_usage, geom_flags):
-        return self.real.is_format_supported(format, target, tex_usage, geom_flags)
+    def is_format_supported(self, format, target, bind, geom_flags):
+        return self.real.is_format_supported(format, target, bind, geom_flags)
     
-    def texture_create(self, templat):
-        return self.real.texture_create(
+    def resource_create(self, templat):
+        return self.real.resource_create(
             format = templat.format,
             width = templat.width,
             height = templat.height,
             depth = templat.depth,
             last_level = templat.last_level,
             target = templat.target,
-            tex_usage = templat.tex_usage,
+            bind = templat.bind,
         )
 
     def texture_destroy(self, texture):
@@ -307,37 +257,9 @@ class Screen(Object):
     def tex_surface_release(self, surface):
         pass
 
-    def surface_write(self, surface, data, stride, size):
-        if surface is None:
-            return
-#        assert surface.nblocksy * stride == size 
-        surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
-
-    def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
-        if texture is None:
-            return None
-        transfer = Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
-        if transfer and usage & gallium.PIPE_TRANSFER_READ:
-            if self.interpreter.options.all:
-                self.interpreter.present(transfer.surface, 'transf_read', x, y, w, h)
-        return transfer
-    
-    def tex_transfer_destroy(self, transfer):
-        self.interpreter.unregister_object(transfer)
-
-    def transfer_write(self, transfer, stride, data, size):
-        if transfer is None:
-            return
-        transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride)
-        if self.interpreter.options.all:
-            self.interpreter.present(transfer.surface, 'transf_write', transfer.x, transfer.y, transfer.w, transfer.h)
-
-    def user_buffer_create(self, data, size):
+    def user_buffer_create(self, data, size, bind):
         # We don't really care to distinguish between user and regular buffers
-        buffer = self.real.buffer_create(size, 
-                                         4, 
-                                         gallium.PIPE_BUFFER_USAGE_CPU_READ |
-                                         gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
+        buffer = self.real.buffer_create(size, bind)
         assert size == len(data)
         buffer.write(data)
         return buffer
@@ -348,10 +270,6 @@ class Screen(Object):
     def buffer_destroy(self, buffer):
         pass
     
-    def buffer_write(self, buffer, data, size, offset=0):
-        assert size == len(data)
-        buffer.write(data)
-        
     def fence_finish(self, fence, flags):
         pass
     
@@ -499,13 +417,23 @@ class Context(Object):
     def set_viewport_state(self, state):
         self.real.set_viewport(state)
 
-    def set_fragment_sampler_textures(self, num_textures, textures):
-        for i in range(num_textures):
-            self.real.set_fragment_sampler_texture(i, textures[i])
+    def create_sampler_view(self, texture, templ):
+        return self.real.create_sampler_view(texture,
+                       format = templ.format,
+                       first_level = templ.first_level,
+                       last_level = templ.last_level,
+                       swizzle_r = templ.swizzle_r,
+                       swizzle_g = templ.swizzle_r,
+                       swizzle_b = templ.swizzle_g,
+                       swizzle_a = templ.swizzle_a)
 
-    def set_vertex_sampler_textures(self, num_textures, textures):
-        for i in range(num_textures):
-            self.real.set_vertex_sampler_texture(i, textures[i])
+    def set_fragment_sampler_views(self, num, views):
+        for i in range(num):
+            self.real.set_fragment_sampler_view(i, views[i])
+
+    def set_vertex_sampler_views(self, num, views):
+        for i in range(num):
+            self.real.set_vertex_sampler_view(i, views[i])
 
     def set_vertex_buffers(self, num_buffers, buffers):
         self.vbufs = buffers[0:num_buffers]
@@ -518,13 +446,21 @@ class Context(Object):
                 buffer_offset = vbuf.buffer_offset,
                 buffer = vbuf.buffer,
             )
+            
+    def create_vertex_elements_state(self, num_elements, elements):
+        return elements[0:num_elements]
 
-    def set_vertex_elements(self, num_elements, elements):
-        self.velems = elements[0:num_elements]
+    def bind_vertex_elements_state(self, state):
+        elements = state
+        num_elements = len(elements)
+        self.velems = elements
         for i in range(num_elements):
             self.real.set_vertex_element(i, elements[i])
         self.real.set_vertex_elements(num_elements)
 
+    def delete_vertex_elements_state(self, state):
+        pass
+
     def dump_vertices(self, start, count):
         if not self.interpreter.verbosity(2):
             return
@@ -630,6 +566,42 @@ class Context(Object):
         #return self.real.is_buffer_referenced(format, buf)
         pass
     
+    def buffer_write(self, buffer, data, size, offset=0):
+        assert size == len(data)
+        self.buffer_write(buffer, data)
+
+    def surface_write(self, surface, data, stride, size):
+        if surface is None:
+            return
+#        assert surface.nblocksy * stride == size 
+        surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
+
+    def get_transfer(self, texture, sr, usage, box):
+        if texture is None:
+            return None
+        transfer = Transfer(texture, sr, usage, box)
+        if transfer and usage & gallium.PIPE_TRANSFER_READ:
+            if self.interpreter.options.all:
+                surface = texture.get_surface(sr.face, sr.level, box.z)
+                self.interpreter.present(transfer.surface, 'transf_read', box.x, box.y, box.w, box.h)
+        return transfer
+    
+    def tex_transfer_destroy(self, transfer):
+        self.interpreter.unregister_object(transfer)
+
+    def transfer_write(self, transfer, data, size):
+        if transfer is None:
+            return
+        self.real.transfer_inline_write(resource, sr, usage, box, data, stride, slice_stride)
+        self.transfertransfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, transfer.stride)
+        if self.interpreter.options.all:
+            box = transfer.box
+            surface = transfer.resource.get_surface(sr.face, sr.level, box.z)
+            self.interpreter.present(transfer.surface, 'transf_write', box.x, box.y, box.w, box.h)
+
+    def transfer_inline_write(self, resource, sr, usage, box, stride, slice_stride, data):
+        self.real.transfer_inline_write(resource, sr, usage, box, data, stride, slice_stride)
+
     def _set_dirty(self):
         if self.interpreter.options.step:
             self._present()
index 5c22269b183f7b41742f93728a1a3c6ab2c5b3f6..936c0b3f33a764921bd6b32501bd442db975b499 100644 (file)
@@ -133,15 +133,15 @@ def test(dev):
     ctx.set_clip(clip)
 
     # framebuffer
-    cbuf = dev.texture_create(
+    cbuf = dev.resource_create(
         PIPE_FORMAT_B8G8R8X8_UNORM,
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET,
+        bind=PIPE_BIND_RENDER_TARGET,
     ).get_surface()
-    zbuf = dev.texture_create(
+    zbuf = dev.resource_create(
         PIPE_FORMAT_Z32_UNORM,
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL,
+        bind=PIPE_BIND_DEPTH_STENCIL,
     ).get_surface()
     fb = Framebuffer()
     fb.width = width
index 8cc272db812fa6b2f972ea35678e92e1b97b0827..fed929d4200147db0793e20cc7332f28396ecd07 100644 (file)
@@ -134,15 +134,15 @@ def test(dev):
     ctx.set_clip(clip)
 
     # framebuffer
-    cbuf = dev.texture_create(
+    cbuf = dev.resource_create(
         PIPE_FORMAT_B8G8R8X8_UNORM, 
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET,
+        bind=PIPE_BIND_RENDER_TARGET,
     ).get_surface()
-    zbuf = dev.texture_create(
+    zbuf = dev.resource_create(
         PIPE_FORMAT_Z32_UNORM,
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL,
+        bind=PIPE_BIND_DEPTH_STENCIL,
     ).get_surface()
     fb = Framebuffer()
     fb.width = width
index b758b4c6221af3063f437b5d6d15f75aa22a2f5f..ef65a9c5a1b860a19570c1ef7b65e48c861f5994 100644 (file)
@@ -112,10 +112,10 @@ def test(dev, name):
     ctx.set_clip(clip)
 
     # framebuffer
-    cbuf = dev.texture_create(
+    cbuf = dev.resource_create(
         PIPE_FORMAT_B8G8R8X8_UNORM,
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET,
+        bind=PIPE_BIND_RENDER_TARGET,
     ).get_surface()
     fb = Framebuffer()
     fb.width = width
index bd838cc282bbee68976e22631ed4caacaab02ac8..05e40dbd5f1304fa9d1b41fee5c4019036f8b947 100644 (file)
@@ -113,10 +113,10 @@ def test(dev, name):
     ctx.set_clip(clip)
 
     # framebuffer
-    cbuf = dev.texture_create(
+    cbuf = dev.resource_create(
         PIPE_FORMAT_B8G8R8X8_UNORM,
         width, height,
-        tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET,
+        bind=PIPE_BIND_RENDER_TARGET,
     ).get_surface()
     fb = Framebuffer()
     fb.width = width
index 3eefa690bddb505244335bd241a8f630f0e23276..8d841644035d6ba6311981292755fd9543f63110 100755 (executable)
@@ -71,35 +71,35 @@ class TextureTest(TestCase):
         level = self.level
         zslice = self.zslice
         
-        tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+        bind = PIPE_BIND_SAMPLER_VIEW
         geom_flags = 0
-        if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+        if not dev.is_format_supported(format, target, bind, geom_flags):
             raise TestSkip
 
-        if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+        if not dev.is_format_supported(format, target, bind, geom_flags):
             raise TestSkip
 
         #  textures
-        dst_texture = dev.texture_create(
+        dst_texture = dev.resource_create(
             target = target,
             format = format, 
             width = width, 
             height = height,
             depth = depth, 
             last_level = last_level,
-            tex_usage = tex_usage,
+            bind = bind,
         )
 
         dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice)
         
-        src_texture = dev.texture_create(
+        src_texture = dev.resource_create(
             target = target,
             format = format, 
             width = dst_surface.width, 
             height = dst_surface.height,
             depth = 1, 
             last_level = 0,
-            tex_usage = PIPE_TEXTURE_USAGE_SAMPLER,
+            bind = PIPE_BIND_SAMPLER_VIEW,
         )
 
         src_surface = src_texture.get_surface()
index a68c081931345bad672132b191e9f6a173a820a9..77f006ea04e00842893901d630e634f0fd6140bb 100755 (executable)
@@ -131,14 +131,14 @@ class TextureColorSampleTest(TestCase):
         minz = 0.0
         maxz = 1.0
         
-        tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+        bind = PIPE_BIND_SAMPLER_VIEW
         geom_flags = 0
         if width != height:
             geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
         if not is_pot(width) or not is_pot(height) or not is_pot(depth):
             geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
         
-        if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+        if not dev.is_format_supported(format, target, bind, geom_flags):
             raise TestSkip
         
         # disabled blending/masking
@@ -174,14 +174,14 @@ class TextureColorSampleTest(TestCase):
         ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
-        texture = dev.texture_create(
+        texture = dev.resource_create(
             target = target,
             format = format, 
             width = width, 
             height = height,
             depth = depth, 
             last_level = last_level,
-            tex_usage = tex_usage,
+            bind = bind,
         )
         
         expected_rgba = FloatArray(height*width*4) 
@@ -225,11 +225,11 @@ class TextureColorSampleTest(TestCase):
         ctx.set_clip(clip)
 
         #  framebuffer 
-        cbuf_tex = dev.texture_create(
+        cbuf_tex = dev.resource_create(
             PIPE_FORMAT_B8G8R8A8_UNORM, 
             width, 
             height,
-            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+            bind = PIPE_BIND_RENDER_TARGET,
         )
 
         cbuf = cbuf_tex.get_surface()
@@ -349,14 +349,14 @@ class TextureDepthSampleTest(TestCase):
         minz = 0.0
         maxz = 1.0
         
-        tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+        bind = PIPE_BIND_SAMPLER_VIEW
         geom_flags = 0
         if width != height:
             geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
         if not is_pot(width) or not is_pot(height) or not is_pot(depth):
             geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
         
-        if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+        if not dev.is_format_supported(format, target, bind, geom_flags):
             raise TestSkip
         
         # disabled blending/masking
@@ -411,14 +411,14 @@ class TextureDepthSampleTest(TestCase):
         ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
-        texture = dev.texture_create(
+        texture = dev.resource_create(
             target = target,
             format = format, 
             width = width, 
             height = height,
             depth = depth, 
             last_level = last_level,
-            tex_usage = tex_usage,
+            bind = bind,
         )
         
         expected_rgba = FloatArray(height*width*4) 
@@ -446,18 +446,18 @@ class TextureDepthSampleTest(TestCase):
         ctx.set_clip(clip)
 
         #  framebuffer 
-        cbuf_tex = dev.texture_create(
+        cbuf_tex = dev.resource_create(
             PIPE_FORMAT_B8G8R8A8_UNORM, 
             width, 
             height,
-            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+            bind = PIPE_BIND_RENDER_TARGET,
         )
 
-        zsbuf_tex = dev.texture_create(
+        zsbuf_tex = dev.resource_create(
             PIPE_FORMAT_X8Z24_UNORM, 
             width, 
             height,
-            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+            bind = PIPE_BIND_RENDER_TARGET,
         )
 
         cbuf = cbuf_tex.get_surface()
index 12def7ec72cc0b39ab2fc1b2ada09af184c2d5f1..23f3d2a57de887540267b12f9846a8110b845fb9 100755 (executable)
@@ -68,40 +68,40 @@ class TextureTest(TestCase):
         zslice = self.zslice
         
         #  textures
-        dst_texture = dev.texture_create(
+        dst_texture = dev.resource_create(
             target = target,
             format = format, 
             width = width, 
             height = height,
             depth = depth, 
             last_level = last_level,
-            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+            bind = PIPE_BIND_RENDER_TARGET,
         )
         if dst_texture is None:
             raise TestSkip
 
         dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice)
         
-        ref_texture = dev.texture_create(
+        ref_texture = dev.resource_create(
             target = target,
             format = format, 
             width = dst_surface.width, 
             height = dst_surface.height,
             depth = 1, 
             last_level = 0,
-            tex_usage = PIPE_TEXTURE_USAGE_SAMPLER,
+            bind = PIPE_BIND_SAMPLER_VIEW,
         )
 
         ref_surface = ref_texture.get_surface()
         
-        src_texture = dev.texture_create(
+        src_texture = dev.resource_create(
             target = target,
             format = PIPE_FORMAT_B8G8R8A8_UNORM, 
             width = dst_surface.width, 
             height = dst_surface.height,
             depth = 1, 
             last_level = 0,
-            tex_usage = PIPE_TEXTURE_USAGE_SAMPLER,
+            bind = PIPE_BIND_SAMPLER_VIEW,
         )
 
         src_surface = src_texture.get_surface()
@@ -148,11 +148,11 @@ class TextureTest(TestCase):
         ctx.set_fragment_sampler_texture(0, src_texture)
 
         #  framebuffer 
-        cbuf_tex = dev.texture_create(
+        cbuf_tex = dev.resource_create(
             PIPE_FORMAT_B8G8R8A8_UNORM, 
             width, 
             height,
-            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+            bind = PIPE_BIND_RENDER_TARGET,
         )
 
         fb = Framebuffer()
index 639d3d362c17f66ab53d5db5c435c148beeb0b7e..4aa3d6c709bd8a39e3b89008e1558952a852a03e 100755 (executable)
@@ -72,20 +72,20 @@ class TextureTest(TestCase):
         level = self.level
         zslice = self.zslice
         
-        tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+        bind = PIPE_BIND_SAMPLER_VIEW
         geom_flags = 0
-        if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+        if not dev.is_format_supported(format, target, bind, geom_flags):
             raise TestSkip
         
         #  textures
-        texture = dev.texture_create(
+        texture = dev.resource_create(
             target = target,
             format = format, 
             width = width, 
             height = height,
             depth = depth, 
             last_level = last_level,
-            tex_usage = tex_usage,
+            bind = bind,
         )
         
         surface = texture.get_surface(face, level, zslice)