Texture refactor

-Texture renamed to Texture2D
-TextureLayered as base now inherits 2Darray, cubemap and cubemap array
-Removed all references to flags in textures (they will go in the shader)
-Texture3D gone for now (will come back later done properly)
-Create base rasterizer for RenderDevice, RasterizerRD
This commit is contained in:
Juan Linietsky
2019-06-11 15:43:37 -03:00
parent 9ffe57a10e
commit 3f335ce3d4
287 changed files with 2829 additions and 2540 deletions

View File

@ -42,17 +42,16 @@ NoiseTexture::NoiseTexture() {
seamless = false;
as_normalmap = false;
bump_strength = 8.0;
flags = FLAGS_DEFAULT;
noise = Ref<OpenSimplexNoise>();
texture = VS::get_singleton()->texture_create();
_queue_update();
}
NoiseTexture::~NoiseTexture() {
VS::get_singleton()->free(texture);
if (texture.is_valid()) {
VS::get_singleton()->free(texture);
}
if (noise_thread) {
Thread::wait_to_finish(noise_thread);
memdelete(noise_thread);
@ -101,8 +100,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const {
void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) {
data = p_image;
if (data.is_valid()) {
VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags);
VS::get_singleton()->texture_set_data(texture, p_image);
if (texture.is_valid()) {
RID new_texture = VS::get_singleton()->texture_2d_create(p_image);
VS::get_singleton()->texture_replace(texture, new_texture);
} else {
texture = VS::get_singleton()->texture_2d_create(p_image);
}
}
emit_changed();
}
@ -250,13 +253,12 @@ int NoiseTexture::get_height() const {
return size.y;
}
void NoiseTexture::set_flags(uint32_t p_flags) {
flags = p_flags;
VS::get_singleton()->texture_set_flags(texture, flags);
}
RID NoiseTexture::get_rid() const {
if (!texture.is_valid()) {
texture = VS::get_singleton()->texture_2d_placeholder_create();
}
uint32_t NoiseTexture::get_flags() const {
return flags;
return texture;
}
Ref<Image> NoiseTexture::get_data() const {

View File

@ -39,8 +39,8 @@
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
class NoiseTexture : public Texture {
GDCLASS(NoiseTexture, Texture);
class NoiseTexture : public Texture2D {
GDCLASS(NoiseTexture, Texture2D);
private:
Ref<Image> data;
@ -51,7 +51,7 @@ private:
bool update_queued;
bool regen_queued;
RID texture;
mutable RID texture;
uint32_t flags;
Ref<OpenSimplexNoise> noise;
@ -91,10 +91,7 @@ public:
int get_width() const;
int get_height() const;
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
virtual RID get_rid() const { return texture; }
virtual RID get_rid() const;
virtual bool has_alpha() const { return false; }
virtual Ref<Image> get_data() const;