Conversation
|
The pgraph tester has tests for float depth modes (you'll just need to reenable the d24s8 one that can't be run on xemu: https://github.com/abaire/nxdk_pgraph_tests/blob/main/src/tests/depth_format_tests.cpp#L21) |
|
|
||
|
|
||
| def f16_to_float(f): | ||
| if f == 0x0: |
There was a problem hiding this comment.
Nit: if not f: would be more pythonic (here and below)
| depth_img = Image.new("RGB", (width, height)) | ||
| stencil_img = None | ||
|
|
||
| if fmt_depth == 0x2D: |
There was a problem hiding this comment.
Can we use symbolic names for these rather than the raw values?
|
|
||
| assert len(data) == pitch * height | ||
|
|
||
| # FIXME: Does this work? |
There was a problem hiding this comment.
Let's just remove this since it's never invoked.
|
|
||
| for y in range(height): | ||
| for x in range(width): | ||
| pixel_offset = y * pitch + x * fmt.bpp // 8 |
There was a problem hiding this comment.
I don't think python implementations do a superb job of optimizing, I'd extract out some of these values that don't change.
E.g., move the y * pitch out of the x loop, move fmt.bpp // 8 out of the loops entirely
| depth = fmt.convert_float(depth) | ||
|
|
||
| depth_values[x, y] = depth | ||
| stencil_values[x, y] = 255 if stencil != 0 else 0 |
There was a problem hiding this comment.
Nit: I think you can drop the explicit != 0
| depth_max -= depth_min | ||
| depth_scaler = 255 / depth_max if depth_max > 0 else 255 | ||
| depth_pixels = depth_img.load() | ||
| if stencil_img is not None: |
There was a problem hiding this comment.
Nit: I don't think you need to explicitly check against None here, just if stencil_img would be more pythonic since anything falsey is not going to be callable.
|
|
||
| self._save_image(img, no_alpha_path, alpha_path) | ||
|
|
||
| depth_path = "command%d--depth.png" % (self.command_count) |
There was a problem hiding this comment.
Note: Depending on whether this goes in before or after #42 we'll want to expand this path to capture the draw count and depth_offset
Produces an image representation of the depth and stencil buffers. I don't have any games that use float mode or swizzling (to my knowledge), so I'm unable to test those formats.
Z24S8 Depth

Z24S8 Depth/Stencil

Z16
