summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2008-07-15 17:57:48 +0900
committerJosé Fonseca <[email protected]>2008-07-15 17:58:48 +0900
commit3392bcaaa823bd791e8d7e4c5a7ce013831899bb (patch)
treebf5846a60766f4b2bb6c87d38fc133e8d83f8009 /src/gallium
parentee470020e17bc4999f3540fbad49fe645a4b914e (diff)
python: Cleanup.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/python/samples/tri.py8
-rw-r--r--src/gallium/state_trackers/python/tests/base.py31
-rw-r--r--src/gallium/state_trackers/python/tests/texture.py14
3 files changed, 23 insertions, 30 deletions
diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py
index e5044a02458..36659229298 100644
--- a/src/gallium/state_trackers/python/samples/tri.py
+++ b/src/gallium/state_trackers/python/samples/tri.py
@@ -143,24 +143,16 @@ def test(dev):
cbuf = dev.texture_create(PIPE_FORMAT_X8R8G8B8_UNORM,
width, height,
usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
- zbuf = dev.texture_create(PIPE_FORMAT_X8Z24_UNORM,
- width, height,
- usage=PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
_cbuf = cbuf.get_surface(usage = PIPE_BUFFER_USAGE_GPU_READ|PIPE_BUFFER_USAGE_GPU_WRITE)
- _zsbuf = zbuf.get_surface(usage = PIPE_BUFFER_USAGE_GPU_READ|PIPE_BUFFER_USAGE_GPU_WRITE)
fb = Framebuffer()
fb.width = width
fb.height = height
fb.num_cbufs = 1
fb.set_cbuf(0, _cbuf)
- fb.set_zsbuf(_zsbuf)
ctx.set_framebuffer(fb)
_cbuf.clear_value = 0x00000000
- _zsbuf.clear_value = 0x00ffffff
ctx.surface_clear(_cbuf, _cbuf.clear_value)
- ctx.surface_clear(_zsbuf, _zsbuf.clear_value)
del _cbuf
- del _zsbuf
# vertex shader
vs = Shader('''
diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py
index 185a59996e6..d5d6114a45d 100644
--- a/src/gallium/state_trackers/python/tests/base.py
+++ b/src/gallium/state_trackers/python/tests/base.py
@@ -37,28 +37,25 @@ for name, value in globals().items():
formats[value] = name
-def make_image(surface):
- pixels = FloatArray(surface.height*surface.width*4)
- surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels)
-
+def make_image(width, height, rgba):
import Image
outimage = Image.new(
mode='RGB',
- size=(surface.width, surface.height),
+ size=(width, height),
color=(0,0,0))
outpixels = outimage.load()
- for y in range(0, surface.height):
- for x in range(0, surface.width):
- offset = (y*surface.width + x)*4
- r, g, b, a = [int(pixels[offset + ch]*255) for ch in range(4)]
+ for y in range(0, height):
+ for x in range(0, width):
+ offset = (y*width + x)*4
+ r, g, b, a = [int(rgba[offset + ch]*255) for ch in range(4)]
outpixels[x, y] = r, g, b
return outimage
-def save_image(filename, surface):
- outimage = make_image(surface)
+def save_image(width, height, rgba, filename):
+ outimage = make_image(width, height, rgba)
outimage.save(filename, "PNG")
-def show_image(*surfaces):
+def show_image(width, height, **rgbas):
import Tkinter as tk
from PIL import Image, ImageTk
@@ -67,15 +64,17 @@ def show_image(*surfaces):
x = 64
y = 64
- for i in range(len(surfaces)):
- surface = surfaces[i]
- outimage = make_image(surface)
+ labels = rgbas.keys()
+ labels.sort()
+ for i in range(len(labels)):
+ label = labels[i]
+ outimage = make_image(width, height, rgbas[label])
if i:
window = tk.Toplevel(root)
else:
window = root
- window.title('Image %u' % (i+1))
+ window.title(label)
image1 = ImageTk.PhotoImage(outimage)
w = image1.width()
h = image1.height()
diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py
index 84ceebb1694..6a5ffb38b95 100644
--- a/src/gallium/state_trackers/python/tests/texture.py
+++ b/src/gallium/state_trackers/python/tests/texture.py
@@ -61,8 +61,8 @@ class TextureTest(Test):
def run(self):
dev = self.dev
- format = PIPE_FORMAT_A8R8G8B8_UNORM
- #format = PIPE_FORMAT_DXT1_RGB
+ #format = PIPE_FORMAT_A8R8G8B8_UNORM
+ format = PIPE_FORMAT_DXT1_RGB
if not dev.is_format_supported(format, PIPE_TEXTURE):
pass
@@ -130,20 +130,21 @@ class TextureTest(Test):
expected_rgba = generate_data(texture.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE))
+ # framebuffer
cbuf_tex = dev.texture_create(PIPE_FORMAT_A8R8G8B8_UNORM,
width,
height,
usage = PIPE_TEXTURE_USAGE_RENDER_TARGET)
- # drawing dest
cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_GPU_WRITE|PIPE_BUFFER_USAGE_GPU_READ)
fb = Framebuffer()
fb.width = width
fb.height = height
fb.num_cbufs = 1
fb.set_cbuf(0, cbuf)
- ctx.surface_clear(cbuf, 0x00000000)
ctx.set_framebuffer(fb)
+ ctx.surface_clear(cbuf, 0x00000000)
+ del fb
# vertex shader
vs = Shader('''
@@ -220,14 +221,15 @@ class TextureTest(Test):
ctx.flush()
+ del ctx
+
rgba = FloatArray(height*width*4)
cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ).get_tile_rgba(x, y, w, h, rgba)
compare_rgba(width, height, rgba, expected_rgba)
- show_image(texture.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ),
- cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ))
+ show_image(width, height, Result=rgba, Expected=expected_rgba)
def main():