Skip to content

Commit

Permalink
Texture refactor
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
reduz committed Feb 11, 2020
1 parent 9ffe57a commit 3f335ce
Show file tree
Hide file tree
Showing 287 changed files with 2,832 additions and 2,543 deletions.
4 changes: 2 additions & 2 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SConscript('winmidi/SCsub')

# Graphics drivers
if (env["platform"] != "server"):
SConscript('gles3/SCsub')
SConscript('gles2/SCsub')
# SConscript('gles3/SCsub')
# SConscript('gles2/SCsub')
SConscript('vulkan/SCsub')
SConscript('gl_context/SCsub')
else:
Expand Down
2 changes: 1 addition & 1 deletion drivers/dummy/rasterizer_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "core/rid_owner.h"
#include "core/self_list.h"
#include "scene/resources/mesh.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual_server.h"

class RasterizerSceneDummy : public RasterizerScene {
Expand Down
2 changes: 1 addition & 1 deletion drivers/dummy/texture_loader_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void ResourceFormatDummyTexture::get_recognized_extensions(List<String> *p_exten
}

bool ResourceFormatDummyTexture::handles_type(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Texture");
return ClassDB::is_parent_class(p_type, "Texture2D");
}

String ResourceFormatDummyTexture::get_resource_type(const String &p_path) const {
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles2/rasterizer_canvas_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define RASTERIZERCANVASGLES2_H

#include "rasterizer_storage_gles2.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"

#include "shaders/canvas.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles2/rasterizer_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "rasterizer_canvas_gles2.h"
#include "rasterizer_scene_gles2.h"
#include "rasterizer_storage_gles2.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"

class RasterizerGLES2 : public Rasterizer {

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_USAMPLER2D: {
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture";
pi.hint_string = "Texture2D";
} break;

case ShaderLanguage::TYPE_SAMPLERCUBE: {
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles2/rasterizer_storage_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "core/pool_vector.h"
#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual/shader_language.h"
#include "shader_compiler_gles2.h"
#include "shader_gles2.h"
Expand Down Expand Up @@ -341,7 +341,7 @@ class RasterizerStorageGLES2 : public RasterizerStorage {
}
};

mutable RID_PtrOwner<Texture> texture_owner;
mutable RID_PtrOwner<Texture2D> texture_owner;

Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_canvas_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define RASTERIZERCANVASGLES3_H

#include "rasterizer_storage_gles3.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"

#include "shaders/canvas_shadow.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"

class RasterizerGLES3 : public Rasterizer {

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_storage_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn

pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture";
pi.hint_string = "Texture2D";
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_storage_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define RASTERIZERSTORAGEGLES3_H

#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual/shader_language.h"
#include "shader_compiler_gles3.h"
#include "shader_gles3.h"
Expand Down Expand Up @@ -344,7 +344,7 @@ class RasterizerStorageGLES3 : public RasterizerStorage {
}
};

mutable RID_PtrOwner<Texture> texture_owner;
mutable RID_PtrOwner<Texture2D> texture_owner;

Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const;

Expand Down
6 changes: 3 additions & 3 deletions editor/animation_bezier_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {

draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor);

Ref<Texture> close_icon = get_icon("Close", "EditorIcons");
Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons");

close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep);
close_icon_rect.size = close_icon->get_size();
Expand Down Expand Up @@ -290,7 +290,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
if (node) {
int ofs = 0;

Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");

h = MAX(h, icon->get_height());

Expand Down Expand Up @@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
{ //draw OTHER curves

float scale = timeline->get_zoom_scale();
Ref<Texture> point = get_icon("KeyValue", "EditorIcons");
Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons");
for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) {

_draw_track(E->key(), E->get());
Expand Down
6 changes: 3 additions & 3 deletions editor/animation_bezier_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class AnimationBezierTrackEdit : public Control {

Vector<Rect2> view_rects;

Ref<Texture> bezier_icon;
Ref<Texture> bezier_handle_icon;
Ref<Texture> selected_icon;
Ref<Texture2D> bezier_icon;
Ref<Texture2D> bezier_handle_icon;
Ref<Texture2D> selected_icon;

Rect2 close_icon_rect;

Expand Down
56 changes: 28 additions & 28 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() {

int AnimationTimelineEdit::get_buttons_width() const {

Ref<Texture> interp_mode = get_icon("TrackContinuous", "EditorIcons");
Ref<Texture> interp_type = get_icon("InterpRaw", "EditorIcons");
Ref<Texture> loop_type = get_icon("InterpWrapClamp", "EditorIcons");
Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons");
Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons");
Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons");
Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons");
Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons");
Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");

int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width();
total_w += (down_icon->get_width() + 4 * EDSCALE) * 4;
Expand All @@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const {

int AnimationTimelineEdit::get_name_limit() const {

Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");

int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width());

Expand Down Expand Up @@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
if (l <= 0)
l = 0.001; //avoid crashor

Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");
hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
draw_texture(hsize_icon, hsize_rect.position);

Expand Down Expand Up @@ -1934,7 +1934,7 @@ void AnimationTrackEdit::_notification(int p_what) {

Ref<Font> font = get_font("font", "Label");
Color color = get_color("font_color", "Label");
Ref<Texture> type_icons[6] = {
Ref<Texture2D> type_icons[6] = {
get_icon("KeyValue", "EditorIcons"),
get_icon("KeyXform", "EditorIcons"),
get_icon("KeyCall", "EditorIcons"),
Expand All @@ -1950,15 +1950,15 @@ void AnimationTrackEdit::_notification(int p_what) {

{

Ref<Texture> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox");
Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox");

int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but..

check_rect = Rect2(Point2(ofs, int(get_size().height - check->get_height()) / 2), check->get_size());
draw_texture(check, check_rect.position);
ofs += check->get_width() + hsep;

Ref<Texture> type_icon = type_icons[animation->track_get_type(track)];
Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)];
draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
ofs += type_icon->get_width() + hsep;

Expand Down Expand Up @@ -1987,7 +1987,7 @@ void AnimationTrackEdit::_notification(int p_what) {
}
text_color.a *= 0.7;
} else if (node) {
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");

draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
icon_cache = icon;
Expand Down Expand Up @@ -2049,17 +2049,17 @@ void AnimationTrackEdit::_notification(int p_what) {

{

Ref<Texture> wrap_icon[2] = {
Ref<Texture2D> wrap_icon[2] = {
get_icon("InterpWrapClamp", "EditorIcons"),
get_icon("InterpWrapLoop", "EditorIcons"),
};

Ref<Texture> interp_icon[3] = {
Ref<Texture2D> interp_icon[3] = {
get_icon("InterpRaw", "EditorIcons"),
get_icon("InterpLinear", "EditorIcons"),
get_icon("InterpCubic", "EditorIcons")
};
Ref<Texture> cont_icon[4] = {
Ref<Texture2D> cont_icon[4] = {
get_icon("TrackContinuous", "EditorIcons"),
get_icon("TrackDiscrete", "EditorIcons"),
get_icon("TrackTrigger", "EditorIcons"),
Expand All @@ -2068,7 +2068,7 @@ void AnimationTrackEdit::_notification(int p_what) {

int ofs = get_size().width - timeline->get_buttons_width();

Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");

draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE));

Expand All @@ -2084,7 +2084,7 @@ void AnimationTrackEdit::_notification(int p_what) {
update_mode = Animation::UPDATE_CONTINUOUS;
}

Ref<Texture> update_icon = cont_icon[update_mode];
Ref<Texture2D> update_icon = cont_icon[update_mode];

update_mode_rect.position.x = ofs;
update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2;
Expand All @@ -2105,7 +2105,7 @@ void AnimationTrackEdit::_notification(int p_what) {
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect = Rect2();
} else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
Ref<Texture> bezier_icon = get_icon("EditBezier", "EditorIcons");
Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons");
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2;
bezier_edit_rect.size = bezier_icon->get_size();
Expand All @@ -2126,7 +2126,7 @@ void AnimationTrackEdit::_notification(int p_what) {

Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track);

Ref<Texture> icon = interp_icon[interp_mode];
Ref<Texture2D> icon = interp_icon[interp_mode];

interp_mode_rect.position.x = ofs;
interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
Expand Down Expand Up @@ -2159,7 +2159,7 @@ void AnimationTrackEdit::_notification(int p_what) {

bool loop_wrap = animation->track_get_interpolation_loop_wrap(track);

Ref<Texture> icon = wrap_icon[loop_wrap ? 1 : 0];
Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0];

loop_mode_rect.position.x = ofs;
loop_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
Expand Down Expand Up @@ -2190,7 +2190,7 @@ void AnimationTrackEdit::_notification(int p_what) {
{
//erase

Ref<Texture> icon = get_icon("Remove", "EditorIcons");
Ref<Texture2D> icon = get_icon("Remove", "EditorIcons");

remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2;
remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
Expand Down Expand Up @@ -2271,7 +2271,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
if (p_x < p_clip_left || p_x > p_clip_right)
return;

Ref<Texture> icon_to_draw = p_selected ? selected_icon : type_icon;
Ref<Texture2D> icon_to_draw = p_selected ? selected_icon : type_icon;

// Override type icon for invalid value keys, unless selected.
if (!p_selected && animation->track_get_type(track) == Animation::TYPE_VALUE) {
Expand Down Expand Up @@ -2335,12 +2335,12 @@ void AnimationTrackEdit::draw_bg(int p_clip_left, int p_clip_right) {
void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) {
}

void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos) {
void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) {

draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size()));
}

void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) {
void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) {

int clip_left = timeline->get_name_limit();
int clip_right = get_size().width - timeline->get_buttons_width();
Expand Down Expand Up @@ -2391,7 +2391,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati
track = p_track;
update();

Ref<Texture> type_icons[6] = {
Ref<Texture2D> type_icons[6] = {
get_icon("KeyValue", "EditorIcons"),
get_icon("KeyXform", "EditorIcons"),
get_icon("KeyCall", "EditorIcons"),
Expand All @@ -2413,7 +2413,7 @@ NodePath AnimationTrackEdit::get_path() const {

Size2 AnimationTrackEdit::get_minimum_size() const {

Ref<Texture> texture = get_icon("Object", "EditorIcons");
Ref<Texture2D> texture = get_icon("Object", "EditorIcons");
Ref<Font> font = get_font("font", "Label");
int separation = get_constant("vseparation", "ItemList");

Expand Down Expand Up @@ -3199,7 +3199,7 @@ void AnimationTrackEditGroup::_notification(int p_what) {
}
}

void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node) {
void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node) {
icon = p_type;
node_name = p_name;
node = p_node;
Expand Down Expand Up @@ -4214,7 +4214,7 @@ void AnimationTrackEditor::_update_tracks() {

if (!group_sort.has(base_path)) {
AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup);
Ref<Texture> icon = get_icon("Node", "EditorIcons");
Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
String name = base_path;
String tooltip;
if (root && root->has_node(base_path)) {
Expand Down Expand Up @@ -5273,7 +5273,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}

String text;
Ref<Texture> icon = get_icon("Node", "EditorIcons");
Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
if (node) {
if (has_icon(node->get_class(), "EditorIcons")) {
icon = get_icon(node->get_class(), "EditorIcons");
Expand Down
Loading

0 comments on commit 3f335ce

Please sign in to comment.