Skip to content

Commit

Permalink
Merge pull request #698 from GPUOpen-LibrariesAndSDKs/feature/BLD-0-f…
Browse files Browse the repository at this point in the history
…ix-commandline

Feature/bld 0 fix commandline
  • Loading branch information
takahiroharada authored Dec 17, 2024
2 parents 325eb7f + e571518 commit 3b47cbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 116 deletions.
63 changes: 2 additions & 61 deletions src/rprblender/engine/render_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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)
Expand Down Expand Up @@ -211,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)
Expand Down Expand Up @@ -329,7 +329,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 = {}
Expand Down Expand Up @@ -477,8 +476,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")

Expand Down Expand Up @@ -557,7 +554,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:
Expand Down Expand Up @@ -805,63 +801,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 """
Expand Down
57 changes: 2 additions & 55 deletions src/rprblender/utils/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'), '<string>', '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 """
Expand All @@ -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

0 comments on commit 3b47cbe

Please sign in to comment.