diff options
Diffstat (limited to 'progs/gallium')
-rwxr-xr-x | progs/gallium/python/retrace/interpreter.py | 184 | ||||
-rw-r--r-- | progs/gallium/python/samples/gs.py | 8 | ||||
-rw-r--r-- | progs/gallium/python/samples/tri.py | 8 | ||||
-rw-r--r-- | progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py | 4 | ||||
-rw-r--r-- | progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py | 4 | ||||
-rwxr-xr-x | progs/gallium/python/tests/surface_copy.py | 14 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_blit.py | 28 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_render.py | 16 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_transfer.py | 8 |
9 files changed, 123 insertions, 151 deletions
diff --git a/progs/gallium/python/retrace/interpreter.py b/progs/gallium/python/retrace/interpreter.py index 1a961812553..60253cfd1a4 100755 --- a/progs/gallium/python/retrace/interpreter.py +++ b/progs/gallium/python/retrace/interpreter.py @@ -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() diff --git a/progs/gallium/python/samples/gs.py b/progs/gallium/python/samples/gs.py index 5c22269b183..936c0b3f33a 100644 --- a/progs/gallium/python/samples/gs.py +++ b/progs/gallium/python/samples/gs.py @@ -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 diff --git a/progs/gallium/python/samples/tri.py b/progs/gallium/python/samples/tri.py index 8cc272db812..fed929d4200 100644 --- a/progs/gallium/python/samples/tri.py +++ b/progs/gallium/python/samples/tri.py @@ -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 diff --git a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py b/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py index b758b4c6221..ef65a9c5a1b 100644 --- a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py +++ b/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py @@ -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 diff --git a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py b/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py index bd838cc282b..05e40dbd5f1 100644 --- a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py +++ b/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py @@ -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 diff --git a/progs/gallium/python/tests/surface_copy.py b/progs/gallium/python/tests/surface_copy.py index 3eefa690bdd..8d841644035 100755 --- a/progs/gallium/python/tests/surface_copy.py +++ b/progs/gallium/python/tests/surface_copy.py @@ -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() diff --git a/progs/gallium/python/tests/texture_blit.py b/progs/gallium/python/tests/texture_blit.py index a68c0819313..77f006ea04e 100755 --- a/progs/gallium/python/tests/texture_blit.py +++ b/progs/gallium/python/tests/texture_blit.py @@ -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() diff --git a/progs/gallium/python/tests/texture_render.py b/progs/gallium/python/tests/texture_render.py index 12def7ec72c..23f3d2a57de 100755 --- a/progs/gallium/python/tests/texture_render.py +++ b/progs/gallium/python/tests/texture_render.py @@ -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() diff --git a/progs/gallium/python/tests/texture_transfer.py b/progs/gallium/python/tests/texture_transfer.py index 639d3d362c1..4aa3d6c709b 100755 --- a/progs/gallium/python/tests/texture_transfer.py +++ b/progs/gallium/python/tests/texture_transfer.py @@ -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) |