~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/gallium/tests/python/tests/surface_copy.py

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
##########################################################################
 
3
 
4
# Copyright 2009 VMware, Inc.
 
5
# All Rights Reserved.
 
6
 
7
# Permission is hereby granted, free of charge, to any person obtaining a
 
8
# copy of this software and associated documentation files (the
 
9
# "Software"), to deal in the Software without restriction, including
 
10
# without limitation the rights to use, copy, modify, merge, publish,
 
11
# distribute, sub license, and/or sell copies of the Software, and to
 
12
# permit persons to whom the Software is furnished to do so, subject to
 
13
# the following conditions:
 
14
 
15
# The above copyright notice and this permission notice (including the
 
16
# next paragraph) shall be included in all copies or substantial portions
 
17
# of the Software.
 
18
 
19
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
20
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
22
# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
 
23
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
24
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
25
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
26
 
27
##########################################################################
 
28
 
 
29
 
 
30
import os
 
31
import random
 
32
 
 
33
from gallium import *
 
34
from base import *
 
35
 
 
36
 
 
37
def lods(*dims):
 
38
    size = max(dims)
 
39
    lods = 0
 
40
    while size:
 
41
        lods += 1
 
42
        size >>= 1
 
43
    return lods
 
44
 
 
45
 
 
46
class TextureTest(TestCase):
 
47
    
 
48
    tags = (
 
49
        'target',
 
50
        'format',
 
51
        'width',
 
52
        'height',
 
53
        'depth',
 
54
        'last_level',
 
55
        'face',
 
56
        'level',
 
57
        'zslice',
 
58
    )
 
59
 
 
60
    def test(self):
 
61
        dev = self.dev
 
62
        ctx = self.ctx
 
63
        
 
64
        target = self.target
 
65
        format = self.format
 
66
        width = self.width
 
67
        height = self.height
 
68
        depth = self.depth
 
69
        last_level = self.last_level
 
70
        face = self.face
 
71
        level = self.level
 
72
        zslice = self.zslice
 
73
 
 
74
        bind = PIPE_BIND_SAMPLER_VIEW
 
75
        geom_flags = 0
 
76
        sample_count = 0
 
77
        if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
 
78
            raise TestSkip
 
79
 
 
80
        if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
 
81
            raise TestSkip
 
82
 
 
83
        #  textures
 
84
        dst_texture = dev.resource_create(
 
85
            target = target,
 
86
            format = format, 
 
87
            width = width, 
 
88
            height = height,
 
89
            depth = depth, 
 
90
            last_level = last_level,
 
91
            bind = bind,
 
92
        )
 
93
 
 
94
        dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice)
 
95
        
 
96
        src_texture = dev.resource_create(
 
97
            target = target,
 
98
            format = format, 
 
99
            width = dst_surface.width, 
 
100
            height = dst_surface.height,
 
101
            depth = 1, 
 
102
            last_level = 0,
 
103
            bind = PIPE_BIND_SAMPLER_VIEW,
 
104
        )
 
105
 
 
106
        src_surface = src_texture.get_surface()
 
107
        
 
108
        w = dst_surface.width
 
109
        h = dst_surface.height
 
110
 
 
111
        stride = util_format_get_stride(format, w)
 
112
        size = util_format_get_nblocksy(format, h) * stride
 
113
        src_raw = os.urandom(size)
 
114
 
 
115
        ctx.surface_write_raw(src_surface, 0, 0, w, h, src_raw, stride)
 
116
 
 
117
        ctx.surface_copy(dst_surface, 0, 0, 
 
118
                         src_surface, 0, 0, w, h)
 
119
    
 
120
        dst_raw = ctx.surface_read_raw(dst_surface, 0, 0, w, h)
 
121
 
 
122
        if dst_raw != src_raw:
 
123
            raise TestFailure
 
124
 
 
125
 
 
126
def main():
 
127
    dev = Device()
 
128
    ctx = dev.context_create()
 
129
    suite = TestSuite()
 
130
    
 
131
    targets = [
 
132
        PIPE_TEXTURE_2D,
 
133
        PIPE_TEXTURE_CUBE,
 
134
        PIPE_TEXTURE_3D,
 
135
    ]
 
136
    
 
137
    sizes = [64, 32, 16, 8, 4, 2, 1]
 
138
    #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
 
139
    #sizes = [64]
 
140
    #sizes = [63]
 
141
    
 
142
    faces = [
 
143
        PIPE_TEX_FACE_POS_X,
 
144
        PIPE_TEX_FACE_NEG_X,
 
145
        PIPE_TEX_FACE_POS_Y,
 
146
        PIPE_TEX_FACE_NEG_Y, 
 
147
        PIPE_TEX_FACE_POS_Z, 
 
148
        PIPE_TEX_FACE_NEG_Z,
 
149
    ]
 
150
 
 
151
    try:
 
152
        n = int(sys.argv[1])
 
153
    except:
 
154
        n = 10000
 
155
    
 
156
    for i in range(n):
 
157
        format = random.choice(formats.keys())
 
158
        if not util_format_is_depth_or_stencil(format):
 
159
            is_depth_or_stencil = util_format_is_depth_or_stencil(format)
 
160
 
 
161
            if is_depth_or_stencil:
 
162
                target = PIPE_TEXTURE_2D
 
163
            else:
 
164
                target = random.choice(targets)
 
165
            
 
166
            size = random.choice(sizes)
 
167
 
 
168
            if target == PIPE_TEXTURE_3D:
 
169
                depth = size
 
170
            else:
 
171
                depth = 1
 
172
 
 
173
            if target == PIPE_TEXTURE_CUBE:
 
174
                face = random.choice(faces)
 
175
            else:
 
176
                face = PIPE_TEX_FACE_POS_X
 
177
 
 
178
            levels = lods(size)
 
179
            last_level = random.randint(0, levels - 1)
 
180
            level = random.randint(0, last_level)
 
181
            zslice = random.randint(0, max(depth >> level, 1) - 1)
 
182
 
 
183
            test = TextureTest(
 
184
                dev = dev,
 
185
                ctx = ctx,
 
186
                target = target,
 
187
                format = format, 
 
188
                width = size,
 
189
                height = size,
 
190
                depth = depth,
 
191
                last_level = last_level,
 
192
                face = face,
 
193
                level = level,
 
194
                zslice = zslice,
 
195
            )
 
196
            suite.add_test(test)
 
197
    suite.run()
 
198
 
 
199
 
 
200
if __name__ == '__main__':
 
201
    main()