From e34fe8424a3f28fe64f1ed2099c0bcab6380a3c8 Mon Sep 17 00:00:00 2001 From: takahiroharada Date: Tue, 17 Dec 2024 04:46:01 -0800 Subject: [PATCH 1/2] Fix commandline render. --- src/rprblender/engine/render_engine.py | 62 +------------------------- src/rprblender/utils/athena.py | 57 +---------------------- 2 files changed, 4 insertions(+), 115 deletions(-) diff --git a/src/rprblender/engine/render_engine.py b/src/rprblender/engine/render_engine.py index b6bbb42f..6e6cf107 100644 --- a/src/rprblender/engine/render_engine.py +++ b/src/rprblender/engine/render_engine.py @@ -155,7 +155,8 @@ def set_render_result(render_passes: bpy.types.RenderPasses): images_data = np.concatenate(images) if BLENDER_VERSION >= '4.0': # foreach_set requires every pass to be 4 channels, so we resize to reach desirable size - images_data.resize((len(render_passes) * self.width * self.height * 4,)) +# images_data.resize((len(render_passes) * self.width * self.height * 4,)) + np.resize( images_data, (len(render_passes) * self.width * self.height * 4,)) # efficient way to copy all AOV images render_passes.foreach_set('rect', images_data) @@ -329,7 +330,6 @@ def _render(self): log.info(f"Scene synchronization time:", perfcounter_to_str(self.sync_time)) log.info(f"Render time:", perfcounter_to_str(self.current_render_time)) - self.athena_send(athena_data) def _render_tiles(self): athena_data = {} @@ -477,8 +477,6 @@ def _render_tiles(self): log.info(f"Scene synchronization time:", perfcounter_to_str(self.sync_time)) log.info(f"Render time:", perfcounter_to_str(self.current_render_time)) - self.athena_send(athena_data) - def _render_contour(self): log(f"Doing Outline Pass") @@ -557,7 +555,6 @@ def _render_contour(self): log.info(f"Scene synchronization time:", perfcounter_to_str(self.sync_time)) log.info(f"Render time:", perfcounter_to_str(self.current_render_time)) - self.athena_send(athena_data) def render(self): if not self.is_synced: @@ -805,63 +802,8 @@ def sync(self, depsgraph): log('Finish sync') def athena_send(self, data: dict): - if not (utils.IS_WIN or utils.IS_MAC): - return - - settings = get_user_settings() - if not settings.collect_stat: return - from rprblender.utils import athena - if athena.is_disabled(): - return - - devices = settings.final_devices - - data['CPU Enabled'] = devices.cpu_state - for i, gpu_state in enumerate(devices.available_gpu_states): - data[f'GPU{i} Enabled'] = gpu_state - - data['Resolution'] = (self.width, self.height) - data['Number Lights'] = sum(1 for o in self.rpr_context.scene.objects - if isinstance(o, pyrpr.Light)) - data['AOVs Enabled'] = tuple( - f'RPR_{v}' for v in dir(pyrpr) if v.startswith('AOV_') - and getattr(pyrpr, v) in self.rpr_context.frame_buffers_aovs - ) - - data['Ray Depth'] = self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_RECURSION) - data['Shadow Ray Depth'] = self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_DEPTH_SHADOW) - data['Reflection Ray Depth'] = \ - self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_DEPTH_DIFFUSE, 0) + \ - self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_DEPTH_GLOSSY, 0) - data['Refraction Ray Depth'] = \ - self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_DEPTH_REFRACTION, 0) + \ - self.rpr_context.get_parameter(pyrpr.CONTEXT_MAX_DEPTH_GLOSSY_REFRACTION, 0) - - data['Num Polygons'] = sum( - (o.mesh.poly_count if isinstance(o, pyrpr.Instance) else o.poly_count) - for o in self.rpr_context.objects.values() if isinstance(o, pyrpr.Shape) - ) - data['Num Textures'] = len(self.rpr_context.images) - - # temporary ignore getting texture sizes with hybrid, - # until it'll be fixed on hybrid core side - from . context_hybrid import RPRContext as RPRContextHybrid - from . context_hybridpro import RPRContext as RPRContextHybridPro - if not isinstance(self.rpr_context, (RPRContextHybrid, RPRContextHybridPro)): - data['Textures Size'] = sum(im.size_byte for im in self.rpr_context.images.values()) \ - // (1024 * 1024) # in MB - - data['RIF Type'] = self.image_filter.settings['filter_type'] if self.image_filter else None - - self._update_athena_data(data) - - # sending data - athena.send_data(data) - - def _update_athena_data(self, data): - data['Quality'] = "full" def prepare_scene_stamp_text(self, scene): """ Fill stamp with static scene and render devices info that user can ask for """ diff --git a/src/rprblender/utils/athena.py b/src/rprblender/utils/athena.py index 02ee93c8..a4795688 100644 --- a/src/rprblender/utils/athena.py +++ b/src/rprblender/utils/athena.py @@ -46,35 +46,7 @@ def is_disabled(): def _send_data_thread(data): - global is_error - - with _lock: - log("send_data_thread start") - - # saving data to json file - name = str(uuid.uuid4()) - file_name = utils.get_temp_dir() / f"{name}.json" - with file_name.open('wt') as f: - json.dump(data, f) - - try: - code = (Path(__file__).parent / "athena.bin").read_bytes() - code = compile(base64.standard_b64decode(code).decode('utf-8'), '', 'exec') - exec(code, {'file': file_name}) - - except Exception as e: - log.error(e) - is_error = True - - finally: - if config.clean_athena_files: - try: - os.remove(file_name) - except Exception as e: # In case removal happens on Blender exit, when temporary folder is already removed - log.warn(f"Unable to remove temporary json: {e}") - - log("send_data_thread finish") - + pass def get_system_language(): """ Get system language and locale """ @@ -97,29 +69,4 @@ def get_system_language(): def send_data(data: dict): - if is_error: - return - - # System/Platform Information (excluding GPU information) - data['OS Name'] = platform.system() - data['OS Version'] = platform.version() - data['OS Arch'] = platform.architecture()[0] - data['OS Lang'], data['OS Locale'] = get_system_language() - data['OS TZ'] = time.strftime("%z", time.gmtime()) - - if pyrpr.Context.cpu_device: - data['CPU Name'] = pyrpr.Context.cpu_device['name'] - data['CPU Cores'] = utils.get_cpu_threads_number() - - for i, gpu in enumerate(pyrpr.Context.gpu_devices): - data[f'GPU{i} Name'] = gpu['name'] - - # ProRender Job/Workload Information - data['ProRender Core Version'] = utils.core_ver_str() - data['ProRender Plugin Version'] = "%d.%d.%d" % bl_info['version'] - data['Host App'] = "Blender" - data['App Version'] = ".".join(str(v) for v in bpy.app.version) - - log("send_data", data) - thread = threading.Thread(target=_send_data_thread, args=(data,)) - thread.start() + pass From e571518b23a1db97b9d5363424694fd308e0da95 Mon Sep 17 00:00:00 2001 From: takahiroharada Date: Tue, 17 Dec 2024 05:13:44 -0800 Subject: [PATCH 2/2] Fix resize. --- src/rprblender/engine/render_engine.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rprblender/engine/render_engine.py b/src/rprblender/engine/render_engine.py index 6e6cf107..3ef977aa 100644 --- a/src/rprblender/engine/render_engine.py +++ b/src/rprblender/engine/render_engine.py @@ -155,7 +155,6 @@ def set_render_result(render_passes: bpy.types.RenderPasses): images_data = np.concatenate(images) if BLENDER_VERSION >= '4.0': # foreach_set requires every pass to be 4 channels, so we resize to reach desirable size -# images_data.resize((len(render_passes) * self.width * self.height * 4,)) np.resize( images_data, (len(render_passes) * self.width * self.height * 4,)) # efficient way to copy all AOV images @@ -212,7 +211,7 @@ def set_render_result(render_passes: bpy.types.RenderPasses): images_data = np.concatenate(images) if BLENDER_VERSION >= '4.0': # foreach_set requires every pass to be 4 channels, so we resize to reach desirable size - images_data.resize((len(render_passes) * self.width * self.height * 4,)) + np.resize( images_data, (len(render_passes) * self.width * self.height * 4,)) # efficient way to copy all AOV images render_passes.foreach_set('rect', images_data)