Implement GPU backend detection for Blender compatibility
- Added functionality to detect GPU backends (HIP and NVIDIA) during runner registration, enhancing compatibility for Blender versions below 4.x. - Introduced a new method, DetectAndStoreGPUBackends, to download the latest Blender and run a detection script, storing the results for future rendering decisions. - Updated rendering logic to force CPU rendering when HIP is detected on systems with Blender < 4.x, ensuring stability and compatibility. - Enhanced the Context structure to include flags for GPU detection status, improving error handling and rendering decisions based on GPU availability.
This commit is contained in:
@@ -442,3 +442,32 @@ func (m *ManagerClient) DownloadBlender(version string) (io.ReadCloser, error) {
|
||||
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
// blenderVersionsResponse is the response from GET /api/blender/versions.
|
||||
type blenderVersionsResponse struct {
|
||||
Versions []struct {
|
||||
Full string `json:"full"`
|
||||
} `json:"versions"`
|
||||
}
|
||||
|
||||
// GetLatestBlenderVersion returns the latest Blender version string (e.g. "4.2.3") from the manager.
|
||||
// Uses the flat versions list which is newest-first.
|
||||
func (m *ManagerClient) GetLatestBlenderVersion() (string, error) {
|
||||
resp, err := m.Request("GET", "/api/blender/versions", nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to fetch blender versions: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return "", fmt.Errorf("blender versions returned status %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
var out blenderVersionsResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
|
||||
return "", fmt.Errorf("failed to decode blender versions: %w", err)
|
||||
}
|
||||
if len(out.Versions) == 0 {
|
||||
return "", fmt.Errorf("no blender versions available")
|
||||
}
|
||||
return out.Versions[0].Full, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user