161 lines
6.3 KiB
Python
161 lines
6.3 KiB
Python
import bpy
|
|
import json
|
|
import os
|
|
|
|
def run_probe():
|
|
info = {}
|
|
|
|
# 1. Blender Version Details
|
|
info["version"] = {
|
|
"version_string": bpy.app.version_string,
|
|
"version": list(bpy.app.version),
|
|
"build_date": bpy.app.build_date.decode('utf-8') if isinstance(bpy.app.build_date, bytes) else str(bpy.app.build_date),
|
|
"build_time": bpy.app.build_time.decode('utf-8') if isinstance(bpy.app.build_time, bytes) else str(bpy.app.build_time),
|
|
"build_hash": bpy.app.build_hash.decode('utf-8') if isinstance(bpy.app.build_hash, bytes) else str(bpy.app.build_hash),
|
|
"build_branch": bpy.app.build_branch.decode('utf-8') if isinstance(bpy.app.build_branch, bytes) else str(bpy.app.build_branch),
|
|
"binary_path": bpy.app.binary_path
|
|
}
|
|
|
|
# 2. Valid Render Engines
|
|
engines = []
|
|
# Test all known potential engine identifiers
|
|
test_engines = ['CYCLES', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH', 'BLENDER_EEVEE_NEXT']
|
|
for eng in test_engines:
|
|
try:
|
|
bpy.context.scene.render.engine = eng
|
|
engines.append({
|
|
"identifier": eng,
|
|
"valid": True,
|
|
"note": "Supported"
|
|
})
|
|
except TypeError as e:
|
|
engines.append({
|
|
"identifier": eng,
|
|
"valid": False,
|
|
"error": str(e)
|
|
})
|
|
info["render_engines"] = engines
|
|
|
|
# Also inspect enum items from rna
|
|
# Note: enum_items on scene.render.bl_rna.properties['engine']
|
|
try:
|
|
engine_enum = bpy.context.scene.render.bl_rna.properties['engine'].enum_items
|
|
info["registered_engine_enum_items"] = [
|
|
{"identifier": item.identifier, "name": item.name, "description": item.description}
|
|
for item in engine_enum
|
|
]
|
|
except Exception as e:
|
|
info["registered_engine_enum_items_error"] = str(e)
|
|
|
|
# 3. USD Import Operator (bpy.ops.wm.usd_import)
|
|
try:
|
|
usd_rna = bpy.ops.wm.usd_import.get_rna_type()
|
|
params = []
|
|
for p in usd_rna.properties:
|
|
if p.identifier == "rna_type":
|
|
continue
|
|
item = {
|
|
"identifier": p.identifier,
|
|
"name": p.name,
|
|
"type": p.type,
|
|
"description": p.description,
|
|
"is_required": p.is_required,
|
|
"is_hidden": p.is_hidden
|
|
}
|
|
if hasattr(p, "default"):
|
|
def_val = p.default
|
|
if isinstance(def_val, bytes):
|
|
item["default"] = def_val.decode('utf-8', errors='replace')
|
|
elif isinstance(def_val, (int, float, str, bool)):
|
|
item["default"] = def_val
|
|
elif hasattr(def_val, '__iter__'):
|
|
item["default"] = list(def_val)
|
|
else:
|
|
item["default"] = str(def_val)
|
|
if p.type == "ENUM":
|
|
item["enum_items"] = [e.identifier for e in p.enum_items]
|
|
params.append(item)
|
|
info["usd_import_parameters"] = params
|
|
except Exception as e:
|
|
info["usd_import_parameters_error"] = str(e)
|
|
|
|
# 4. Cycles and GPU Support
|
|
cycles_info = {}
|
|
try:
|
|
cycles_addon = bpy.context.preferences.addons.get('cycles')
|
|
if cycles_addon:
|
|
cpref = cycles_addon.preferences
|
|
# Available compute device types enum
|
|
comp_prop = cpref.bl_rna.properties.get('compute_device_type')
|
|
if comp_prop:
|
|
cycles_info["available_device_types"] = [item.identifier for item in comp_prop.enum_items]
|
|
|
|
# Query devices for CUDA and OPTIX
|
|
device_query = {}
|
|
for dev_type in ['CUDA', 'OPTIX', 'NONE', 'HIP', 'ONEAPI']:
|
|
try:
|
|
cpref.compute_device_type = dev_type
|
|
cpref.get_devices()
|
|
dev_list = []
|
|
for d in cpref.devices:
|
|
dev_list.append({
|
|
"name": d.name,
|
|
"type": d.type,
|
|
"use": d.use,
|
|
"id": getattr(d, 'id', 'N/A')
|
|
})
|
|
device_query[dev_type] = dev_list
|
|
except Exception as e:
|
|
device_query[dev_type] = f"Error: {e}"
|
|
cycles_info["device_query"] = device_query
|
|
|
|
# Actual test render with OptiX
|
|
cpref.compute_device_type = 'OPTIX'
|
|
cpref.get_devices()
|
|
for d in cpref.devices:
|
|
if d.type == 'OPTIX':
|
|
d.use = True
|
|
else:
|
|
d.use = False
|
|
scene = bpy.context.scene
|
|
scene.render.engine = 'CYCLES'
|
|
scene.cycles.device = 'GPU'
|
|
scene.cycles.samples = 1
|
|
scene.render.resolution_x = 32
|
|
scene.render.resolution_y = 32
|
|
try:
|
|
bpy.ops.render.render(write_still=False)
|
|
cycles_info["optix_render_test"] = "PASS: Successfully rendered 1 sample with Cycles GPU (OptiX)"
|
|
except Exception as e:
|
|
cycles_info["optix_render_test"] = f"FAIL: {e}"
|
|
|
|
# Actual test render with CUDA
|
|
cpref.compute_device_type = 'CUDA'
|
|
cpref.get_devices()
|
|
for d in cpref.devices:
|
|
if d.type == 'CUDA':
|
|
d.use = True
|
|
else:
|
|
d.use = False
|
|
scene.cycles.device = 'GPU'
|
|
scene.cycles.samples = 1
|
|
try:
|
|
bpy.ops.render.render(write_still=False)
|
|
cycles_info["cuda_render_test"] = "PASS: Successfully rendered 1 sample with Cycles GPU (CUDA)"
|
|
except Exception as e:
|
|
cycles_info["cuda_render_test"] = f"FAIL: {e}"
|
|
else:
|
|
cycles_info["error"] = "Cycles addon not loaded"
|
|
except Exception as e:
|
|
cycles_info["error"] = str(e)
|
|
|
|
info["cycles_gpu"] = cycles_info
|
|
|
|
out_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "reports", "blender_probe_data.json")
|
|
with open(out_path, "w", encoding="utf-8") as f:
|
|
json.dump(info, f, indent=2)
|
|
print(f"Probe data written to: {out_path}")
|
|
|
|
if __name__ == "__main__":
|
|
run_probe()
|