From 79af811e3879434b567f774b3e98fcdd8f7f967b Mon Sep 17 00:00:00 2001 From: Luis Uguina Date: Sun, 14 Jun 2020 23:02:28 +1000 Subject: [PATCH] Fix: -renderbucket-size option not applied if configuration file doesn't exist --- src/com/sheepit/client/SettingsLoader.java | 16 +++++++++++++++- .../sheepit/client/hardware/gpu/GPUDevice.java | 12 ++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/com/sheepit/client/SettingsLoader.java b/src/com/sheepit/client/SettingsLoader.java index 445462bd..5280f81c 100644 --- a/src/com/sheepit/client/SettingsLoader.java +++ b/src/com/sheepit/client/SettingsLoader.java @@ -38,6 +38,7 @@ import lombok.Setter; public class SettingsLoader { + final private int MIN_RENDERBUCKET_SIZE = 32; private String path; private String login; @@ -376,7 +377,7 @@ public void merge(Configuration config) { config.setGPUDevice(device); // If the user has indicated a render bucket size at least 32x32 px, overwrite the config file value - if (config.getRenderbucketSize() >= 32) { + if (config.getRenderbucketSize() >= MIN_RENDERBUCKET_SIZE) { config.getGPUDevice().setRenderbucketSize(config.getRenderbucketSize()); // Update size } else { @@ -394,6 +395,19 @@ public void merge(Configuration config) { config.setRenderbucketSize(config.getGPUDevice().getRenderbucketSize()); } } + else if (config.getGPUDevice() != null) { + // The order of conditions is important to ensure the priority or app arguments, then the config file and finally the recommended size (if none + // specified or already in config file). + if (config.getRenderbucketSize() >= MIN_RENDERBUCKET_SIZE) { + config.getGPUDevice().setRenderbucketSize(config.getRenderbucketSize()); + } + else if (renderbucketSize != null) { + config.getGPUDevice().setRenderbucketSize(Integer.parseInt(renderbucketSize)); + } + else { + config.getGPUDevice().setRenderbucketSize(config.getGPUDevice().getRecommendedBucketSize()); + } + } if (config.getNbCores() == -1 && cores != null) { config.setNbCores(Integer.valueOf(cores)); diff --git a/src/com/sheepit/client/hardware/gpu/GPUDevice.java b/src/com/sheepit/client/hardware/gpu/GPUDevice.java index 58d1513a..7fe84be4 100644 --- a/src/com/sheepit/client/hardware/gpu/GPUDevice.java +++ b/src/com/sheepit/client/hardware/gpu/GPUDevice.java @@ -88,8 +88,13 @@ public void setOldId(String id) { public int getRenderbucketSize() { return this.renderBucketSize; } + + public int getRecommendedBucketSize() { + this.setRenderbucketSize(null); + return this.renderBucketSize; + } - public void setRenderbucketSize(int proposedRenderbucketSize) { + public void setRenderbucketSize(Integer proposedRenderbucketSize) { int renderBucketSize = 32; GPULister gpu; @@ -108,7 +113,10 @@ else if (type.equals("OPENCL")) { return; } - if (proposedRenderbucketSize >= 32) { + if (proposedRenderbucketSize == null) { + renderBucketSize = gpu.getRecommendedRenderBucketSize(getMemory()); + } + else if (proposedRenderbucketSize >= 32) { if (proposedRenderbucketSize <= gpu.getMaximumRenderBucketSize(getMemory())) { renderBucketSize = proposedRenderbucketSize; }