Browse Source

Remove GPU readback from NoiseTexture3D.get_format

(cherry picked from commit 60d5571d6cf31c6c6aec8afe71ef295a4b45c5f8)
clayjohn 2 years ago
parent
commit
2c9901af36
2 changed files with 4 additions and 2 deletions
  1. 2 2
      modules/noise/noise_texture_3d.cpp
  2. 2 0
      modules/noise/noise_texture_3d.h

+ 2 - 2
modules/noise/noise_texture_3d.cpp

@@ -112,6 +112,7 @@ void NoiseTexture3D::_set_texture_data(const TypedArray<Image> &p_data) {
 		} else {
 			texture = RS::get_singleton()->texture_3d_create(data[0]->get_format(), data[0]->get_width(), data[0]->get_height(), data.size(), false, data);
 		}
+		format = data[0]->get_format();
 	}
 	emit_changed();
 }
@@ -348,6 +349,5 @@ Vector<Ref<Image>> NoiseTexture3D::get_data() const {
 }
 
 Image::Format NoiseTexture3D::get_format() const {
-	ERR_FAIL_COND_V(!texture.is_valid(), Image::FORMAT_L8);
-	return RS::get_singleton()->texture_3d_get(texture)[0]->get_format();
+	return format;
 }

+ 2 - 0
modules/noise/noise_texture_3d.h

@@ -60,6 +60,8 @@ private:
 	Ref<Gradient> color_ramp;
 	Ref<Noise> noise;
 
+	Image::Format format = Image::FORMAT_L8;
+
 	void _thread_done(const TypedArray<Image> &p_data);
 	static void _thread_function(void *p_ud);