Sculpt: Add multires version of current performance benchmarks

This commit modifies the `performance/api/sculpt.py` test to add a new
set of tests that run with the multires modifier present. New tests
have `multires_` prepended to the brush name to group them separately
from the existing mesh tests.

Part of #130772

Pull Request: https://projects.blender.org/blender/blender/pulls/132822
This commit is contained in:
Sean Kim
2025-01-08 21:32:57 +01:00
committed by Sean Kim
parent 5ec2547ab0
commit a3f523fd61

View File

@@ -3,6 +3,13 @@
# SPDX-License-Identifier: Apache-2.0
import api
import enum
import pathlib
class SculptMode(enum.IntEnum):
MESH = 1
MULTIRES = 2
def set_view3d_context_override(context_override):
@@ -26,7 +33,7 @@ def set_view3d_context_override(context_override):
context_override["region"] = region
def prepare_sculpt_scene(context):
def prepare_sculpt_scene(context: any, mode: SculptMode):
import bpy
"""
Prepare a clean state of the scene suitable for benchmarking
@@ -48,7 +55,10 @@ def prepare_sculpt_scene(context):
group.interface.new_socket("Geometry", in_out='OUTPUT', socket_type='NodeSocketGeometry')
group_output_node = group.nodes.new('NodeGroupOutput')
size = 1500
if mode == SculptMode.MULTIRES:
size = 150
else:
size = 1500
grid_node = group.nodes.new('GeometryNodeMeshGrid')
grid_node.inputs["Size X"].default_value = 2.0
@@ -70,6 +80,9 @@ def prepare_sculpt_scene(context):
# Move the plane to the sculpt mode.
bpy.ops.object.mode_set(mode='SCULPT')
if mode == SculptMode.MULTIRES:
bpy.ops.object.subdivision_set(level=3)
def generate_stroke(context):
"""
@@ -107,7 +120,7 @@ def generate_stroke(context):
return stroke
def _run(args):
def _run(args: dict):
import bpy
import time
context = bpy.context
@@ -115,7 +128,7 @@ def _run(args):
# Create an undo stack explicitly. This isn't created by default in background mode.
bpy.ops.ed.undo_push()
prepare_sculpt_scene(context)
prepare_sculpt_scene(context, args['mode'])
context_override = context.copy()
set_view3d_context_override(context_override)
@@ -131,17 +144,22 @@ def _run(args):
class SculptBrushTest(api.Test):
def __init__(self, filepath):
def __init__(self, filepath: pathlib.Path, mode: SculptMode):
self.filepath = filepath
self.mode = mode
def name(self):
return self.filepath.stem
# To preserve historical data, avoid adding the prefix for the mesh tests.
if self.mode == SculptMode.MESH:
return self.filepath.stem
return "{}_{}".format(self.mode.name.lower(), self.filepath.stem)
def category(self):
return "sculpt"
def run(self, env, device_id):
args = {}
def run(self, env, _device_id):
args = {"mode": self.mode.value}
result, _ = env.run_in_blender(_run, args, [self.filepath])
@@ -150,4 +168,4 @@ class SculptBrushTest(api.Test):
def generate(env):
filepaths = env.find_blend_files('sculpt/*')
return [SculptBrushTest(filepath) for filepath in filepaths]
return [SculptBrushTest(filepath, mode) for filepath in filepaths for mode in SculptMode]