python/retrace: Verbosity level.

This commit is contained in:
José Fonseca
2009-02-20 15:14:15 +00:00
parent 204526a6d2
commit e92f3310fa

View File

@@ -85,6 +85,7 @@ def show_image(surface):
root.mainloop() root.mainloop()
verbose = 1
class Struct: class Struct:
@@ -382,12 +383,11 @@ class Context(Object):
_state.ucp = ucp _state.ucp = ucp
self.real.set_clip(_state) self.real.set_clip(_state)
def set_constant_buffer(self, shader, index, state): def dump_constant_buffer(self, buffer):
if state is not None: if verbose < 2:
self.real.set_constant_buffer(shader, index, state.buffer) return
if 1: data = buffer.read()
data = state.buffer.read()
format = '4f' format = '4f'
index = 0 index = 0
for offset in range(0, len(data), struct.calcsize(format)): for offset in range(0, len(data), struct.calcsize(format)):
@@ -395,6 +395,12 @@ class Context(Object):
sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w)) sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w))
index += 1 index += 1
def set_constant_buffer(self, shader, index, state):
if state is not None:
self.real.set_constant_buffer(shader, index, state.buffer)
self.dump_constant_buffer(state.buffer)
def set_framebuffer_state(self, state): def set_framebuffer_state(self, state):
_state = gallium.Framebuffer() _state = gallium.Framebuffer()
_state.width = state.width _state.width = state.width
@@ -444,6 +450,9 @@ class Context(Object):
pass pass
def dump_vertices(self, start, count): def dump_vertices(self, start, count):
if verbose < 2:
return
for index in range(start, start + count): for index in range(start, start + count):
if index >= start + 16: if index >= start + 16:
sys.stdout.write('\t...\n') sys.stdout.write('\t...\n')
@@ -468,6 +477,9 @@ class Context(Object):
sys.stdout.write('\t},\n') sys.stdout.write('\t},\n')
def dump_indices(self, ibuf, isize, start, count): def dump_indices(self, ibuf, isize, start, count):
if verbose < 2:
return
format = { format = {
1: 'B', 1: 'B',
2: 'H', 2: 'H',
@@ -499,12 +511,14 @@ class Context(Object):
self.real.draw_arrays(mode, start, count) self.real.draw_arrays(mode, start, count)
def draw_elements(self, indexBuffer, indexSize, mode, start, count): def draw_elements(self, indexBuffer, indexSize, mode, start, count):
if verbose >= 2:
minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
self.dump_vertices(minindex, maxindex - minindex) self.dump_vertices(minindex, maxindex - minindex)
self.real.draw_elements(indexBuffer, indexSize, mode, start, count) self.real.draw_elements(indexBuffer, indexSize, mode, start, count)
def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count): def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count):
if verbose >= 2:
minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
minindex = min(minindex, minIndex) minindex = min(minindex, minIndex)
maxindex = min(maxindex, maxIndex) maxindex = min(maxindex, maxIndex)
@@ -561,6 +575,7 @@ class Interpreter(parser.TraceDumper):
if (call.klass, call.method) in self.ignore_calls: if (call.klass, call.method) in self.ignore_calls:
return return
if verbose >= 1:
parser.TraceDumper.handle_call(self, call) parser.TraceDumper.handle_call(self, call)
args = [self.interpret_arg(arg) for name, arg in call.args] args = [self.interpret_arg(arg) for name, arg in call.args]