[Bf-extensions-cvs] [9b0ebd39] master: Auto Tile Size: Cleanup
lijenstina
noreply at git.blender.org
Sat Jul 22 18:20:15 CEST 2017
Commit: 9b0ebd3926f2c3556ee183a44c692642eb27b30f
Author: lijenstina
Date: Sat Jul 22 18:19:18 2017 +0200
Branches: master
https://developer.blender.org/rBA9b0ebd3926f2c3556ee183a44c692642eb27b30f
Auto Tile Size: Cleanup
Bumped version to 3.1.2
Pep8 cleanup
Consistent property definitions
Imports as tuples
Update wiki link
No other functional changes
===================================================================
M render_auto_tile_size.py
===================================================================
diff --git a/render_auto_tile_size.py b/render_auto_tile_size.py
index 3625c0e1..9c615337 100644
--- a/render_auto_tile_size.py
+++ b/render_auto_tile_size.py
@@ -20,18 +20,35 @@ bl_info = {
"name": "Auto Tile Size",
"description": "Estimate and set the tile size that will render the fastest",
"author": "Greg Zaal",
- "version": (3, 1, 1),
+ "version": (3, 1, 2),
"blender": (2, 74, 0),
"location": "Render Settings > Performance",
"warning": "",
- "wiki_url": "http://wiki.blender.org/index.php?title=Extensions:2.6/Py/Scripts/Render/Auto_Tile_Size",
+ "wiki_url": "https://wiki.blender.org/index.php?title=Extensions:2.6/Py/"
+ "Scripts/Render/Auto_Tile_Size",
"category": "Render",
}
import bpy
+from bpy.types import (
+ Operator,
+ PropertyGroup,
+ )
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatVectorProperty,
+ IntProperty,
+ IntVectorProperty,
+ StringProperty,
+ PointerProperty,
+ )
from bpy.app.handlers import persistent
-from math import ceil, floor, sqrt
+from math import (
+ ceil, floor,
+ sqrt,
+ )
SUPPORTED_RENDER_ENGINES = {'CYCLES', 'BLENDER_RENDER'}
@@ -50,92 +67,135 @@ def _update_tile_size(self, context):
do_set_tile_size(context)
-class AutoTileSizeSettings(bpy.types.PropertyGroup):
- gpu_choice = bpy.props.EnumProperty(
- name="Target GPU Tile Size",
- items=TILE_SIZES,
- default='256',
- description="Square dimensions of tiles for GPU rendering",
- update=_update_tile_size)
- cpu_choice = bpy.props.EnumProperty(
- name="Target CPU Tile Size",
- items=TILE_SIZES,
- default='32',
- description="Square dimensions of tiles for CPU rendering",
- update=_update_tile_size)
- bi_choice = bpy.props.EnumProperty(
- name="Target CPU Tile Size",
- items=TILE_SIZES,
- default='64',
- description="Square dimensions of tiles",
- update=_update_tile_size)
-
- gpu_custom = bpy.props.IntProperty(
- name="Target Size",
- default=256,
- min=8, # same as blender's own limits
- max=65536,
- description="Custom target tile size for GPU rendering",
- update=_update_tile_size)
- cpu_custom = bpy.props.IntProperty(
- name="Target Size",
- default=32,
- min=8, # same as blender's own limits
- max=65536,
- description="Custom target tile size for CPU rendering",
- update=_update_tile_size)
- bi_custom = bpy.props.IntProperty(
- name="Target Size",
- default=64,
- min=8, # same as blender's own limits
- max=65536,
- description="Custom target tile size",
- update=_update_tile_size)
-
- target_type = bpy.props.EnumProperty(
- name="Target tile size",
- items=(
- ('po2', "Po2", "A choice between powers of 2 (16, 32, 64...)"),
- ('custom', "Custom", "Choose any number as the tile size target")),
- default='po2',
- description="Method of choosing the target tile size",
- update=_update_tile_size)
-
- use_optimal = bpy.props.BoolProperty(
- name="Optimal Tiles",
- default=True,
- description="Try to find a similar tile size for best performance, instead of using exact selected one",
- update=_update_tile_size)
-
- is_enabled = bpy.props.BoolProperty(
- name="Auto Tile Size",
- default=True,
- description="Calculate the best tile size based on factors of the render size and the chosen target",
- update=_update_tile_size)
-
- use_advanced_ui = bpy.props.BoolProperty(
- name="Advanced Settings",
- default=False,
- description="Show extra options for more control over the calculated tile size")
-
- thread_error_correct = bpy.props.BoolProperty(
- name="Fix",
- default=True,
- description="Reduce the tile size so that all your available threads are used",
- update=_update_tile_size)
+class AutoTileSizeSettings(PropertyGroup):
+ gpu_choice = EnumProperty(
+ name="Target GPU Tile Size",
+ items=TILE_SIZES,
+ default='256',
+ description="Square dimensions of tiles for GPU rendering",
+ update=_update_tile_size
+ )
+ cpu_choice = EnumProperty(
+ name="Target CPU Tile Size",
+ items=TILE_SIZES,
+ default='32',
+ description="Square dimensions of tiles for CPU rendering",
+ update=_update_tile_size
+ )
+ bi_choice = EnumProperty(
+ name="Target CPU Tile Size",
+ items=TILE_SIZES,
+ default='64',
+ description="Square dimensions of tiles",
+ update=_update_tile_size
+ )
+ gpu_custom = IntProperty(
+ name="Target Size",
+ default=256,
+ min=8, # same as blender's own limits
+ max=65536,
+ description="Custom target tile size for GPU rendering",
+ update=_update_tile_size
+ )
+ cpu_custom = IntProperty(
+ name="Target Size",
+ default=32,
+ min=8, # same as blender's own limits
+ max=65536,
+ description="Custom target tile size for CPU rendering",
+ update=_update_tile_size
+ )
+ bi_custom = IntProperty(
+ name="Target Size",
+ default=64,
+ min=8, # same as blender's own limits
+ max=65536,
+ description="Custom target tile size",
+ update=_update_tile_size
+ )
+ target_type = EnumProperty(
+ name="Target tile size",
+ items=(
+ ('po2', "Po2", "A choice between powers of 2 (16, 32, 64...)"),
+ ('custom', "Custom", "Choose any number as the tile size target")),
+ default='po2',
+ description="Method of choosing the target tile size",
+ update=_update_tile_size
+ )
+ use_optimal = BoolProperty(
+ name="Optimal Tiles",
+ default=True,
+ description="Try to find a similar tile size for best performance, "
+ "instead of using exact selected one",
+ update=_update_tile_size
+ )
+ is_enabled = BoolProperty(
+ name="Auto Tile Size",
+ default=True,
+ description="Calculate the best tile size based on factors of the "
+ "render size and the chosen target",
+ update=_update_tile_size
+ )
+ use_advanced_ui = BoolProperty(
+ name="Advanced Settings",
+ default=False,
+ description="Show extra options for more control over the calculated tile size"
+ )
+ thread_error_correct = BoolProperty(
+ name="Fix",
+ default=True,
+ description="Reduce the tile size so that all your available threads are used",
+ update=_update_tile_size
+ )
# Internally used props (not for GUI)
- first_run = bpy.props.BoolProperty(default=True, options={'HIDDEN'})
- threads_error = bpy.props.BoolProperty(options={'HIDDEN'})
- num_tiles = bpy.props.IntVectorProperty(default=(0, 0), size=2, options={'HIDDEN'})
- prev_choice = bpy.props.StringProperty(default='', options={'HIDDEN'})
- prev_engine = bpy.props.StringProperty(default='', options={'HIDDEN'})
- prev_device = bpy.props.StringProperty(default='', options={'HIDDEN'})
- prev_res = bpy.props.IntVectorProperty(default=(0, 0), size=2, options={'HIDDEN'})
- prev_border = bpy.props.BoolProperty(default=False, options={'HIDDEN'})
- prev_border_res = bpy.props.FloatVectorProperty(default=(0, 0, 0, 0), size=4, options={'HIDDEN'})
- prev_actual_tile_size = bpy.props.IntVectorProperty(default=(0, 0), size=2, options={'HIDDEN'})
- prev_threads = bpy.props.IntProperty(default=0, options={'HIDDEN'})
+ first_run = BoolProperty(
+ default=True,
+ options={'HIDDEN'}
+ )
+ threads_error = BoolProperty(
+ options={'HIDDEN'}
+ )
+ num_tiles = IntVectorProperty(
+ default=(0, 0),
+ size=2,
+ options={'HIDDEN'}
+ )
+ prev_choice = StringProperty(
+ default='',
+ options={'HIDDEN'}
+ )
+ prev_engine = StringProperty(
+ default='',
+ options={'HIDDEN'}
+ )
+ prev_device = StringProperty(
+ default='',
+ options={'HIDDEN'}
+ )
+ prev_res = IntVectorProperty(
+ default=(0, 0),
+ size=2,
+ options={'HIDDEN'}
+ )
+ prev_border = BoolProperty(
+ default=False,
+ options={'HIDDEN'}
+ )
+ prev_border_res = FloatVectorProperty(
+ default=(0, 0, 0, 0),
+ size=4,
+ options={'HIDDEN'}
+ )
+ prev_actual_tile_size = IntVectorProperty(
+ default=(0, 0),
+ size=2,
+ options={'HIDDEN'}
+ )
+ prev_threads = IntProperty(
+ default=0,
+ options={'HIDDEN'}
+ )
def ats_poll(context):
@@ -202,6 +262,7 @@ def get_actual_res(render):
# floor is implicitly done by int conversion...
return (int(render.resolution_x * rend_percent), int(render.resolution_y * rend_percent))
+
def get_threads(context, device):
render = context.scene.render
engine = render.engine
@@ -214,6 +275,7 @@ def get_threads(context, device):
return threads
+
def max_tile_size(threads, xres, yres):
''' Give the largest tile size that will still use all threads '''
@@ -223,7 +285,7 @@ def max_tile_size(threads, xres, yres):
# lists: num x tiles, num y tiles, squareness, total tiles
perfect_attempts = [] # attempts with correct number of tiles
- attempts = [] # all attempts, even if incorrect number of
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list