EEVEE-Next: Skip bake if there's not enough VRAM #113509
|
@ -610,12 +610,21 @@ void Instance::light_bake_irradiance(
|
|||
capture_view.render_world();
|
||||
|
||||
irradiance_cache.bake.surfels_create(probe);
|
||||
|
||||
if (irradiance_cache.bake.should_break()) {
|
||||
return;
|
||||
}
|
||||
|
||||
irradiance_cache.bake.surfels_lights_eval();
|
||||
|
||||
irradiance_cache.bake.clusters_build();
|
||||
irradiance_cache.bake.irradiance_offset();
|
||||
});
|
||||
|
||||
if (irradiance_cache.bake.should_break()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sampling.init(probe);
|
||||
while (!sampling.finished()) {
|
||||
context_wrapper([&]() {
|
||||
|
|
|
@ -947,10 +947,25 @@ void IrradianceBake::surfels_create(const Object &probe_object)
|
|||
capture_info_buf_.read();
|
||||
if (capture_info_buf_.surfel_len == 0) {
|
||||
/* No surfel to allocated. */
|
||||
do_break_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO(fclem): Check for GL limit and abort if the surfel cache doesn't fit the GPU memory. */
|
||||
if (capture_info_buf_.surfel_len > surfels_buf_.size() && GPU_mem_stats_supported()) {
|
||||
|
||||
int total_mem_kb, free_mem_kb;
|
||||
GPU_mem_stats_get(&total_mem_kb, &free_mem_kb);
|
||||
size_t free_mem = size_t(free_mem_kb) * 1024;
|
||||
size_t required_mem = (size_t(capture_info_buf_.surfel_len) - surfels_buf_.size()) *
|
||||
size_t(sizeof(Surfel));
|
||||
if (required_mem > free_mem) {
|
||||
capture_info_buf_.surfel_len = 0u;
|
||||
capture_info_buf_.push_update();
|
||||
inst_.info = "Error: Not enough memory to bake " + std::string(probe_object.id.name) + ".";
|
||||
do_break_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
surfels_buf_.resize(capture_info_buf_.surfel_len);
|
||||
surfels_buf_.clear_to_zero();
|
||||
|
||||
|
|
|
@ -130,12 +130,21 @@ class IrradianceBake {
|
|||
/** True if emission is recorded during the light propagation. */
|
||||
bool capture_emission_ = false;
|
||||
|
||||
/** True if the bake job should stop. */
|
||||
bool do_break_ = false;
|
||||
|
||||
public:
|
||||
IrradianceBake(Instance &inst) : inst_(inst){};
|
||||
|
||||
void init(const Object &probe_object);
|
||||
void sync();
|
||||
|
||||
/** True if the bake job should stop. */
|
||||
bool should_break()
|
||||
{
|
||||
return do_break_;
|
||||
}
|
||||
|
||||
/** Create the views used to rasterize the scene into surfel representation. */
|
||||
void surfel_raster_views_sync(float3 scene_min, float3 scene_max, float4x4 probe_to_world);
|
||||
/** Create a surfel representation of the scene from the probe using the capture pipeline. */
|
||||
|
|
Loading…
Reference in New Issue
While this is nice to check when it is supported, we should also check
GL_MAX_SHADER_STORAGE_BLOCK_SIZE
in any cases.There was no way to query that info, so I made a separate commit to add a
GPU_max_storage_buffer_size
function.