Fix crash on import.

This commit is contained in:
Juan Linietsky 2019-06-26 15:11:52 -03:00
parent e3905f9af3
commit 24b16f3bf0
7 changed files with 58 additions and 27 deletions

View file

@ -213,6 +213,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT));

View file

@ -872,6 +872,7 @@ public:
bool update_when_visible; bool update_when_visible;
//VS::MaterialBlendMode blend_mode; //VS::MaterialBlendMode blend_mode;
int light_mask; int light_mask;
int z_final;
Vector<Command *> commands; Vector<Command *> commands;
mutable bool custom_rect; mutable bool custom_rect;
mutable bool rect_dirty; mutable bool rect_dirty;
@ -1032,6 +1033,7 @@ public:
distance_field = false; distance_field = false;
light_masked = false; light_masked = false;
update_when_visible = false; update_when_visible = false;
z_final = 0;
} }
virtual ~Item() { virtual ~Item() {
clear(); clear();

View file

@ -512,9 +512,10 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
push_constant.specular_shininess = 0xFFFFFFFF; push_constant.specular_shininess = 0xFFFFFFFF;
push_constant.color_texture_pixel_size[0] = 0; push_constant.color_texture_pixel_size[0] = 0;
push_constant.color_texture_pixel_size[1] = 0; push_constant.color_texture_pixel_size[1] = 0;
push_constant.pad[0] = 0;
push_constant.pad[1] = 0; push_constant.pad[1] = 0;
push_constant.pad[2] = 0; push_constant.pad[2] = 0;
push_constant.pad[3] = 0;
PipelineVariants *pipeline_variants = &shader.pipeline_variants; PipelineVariants *pipeline_variants = &shader.pipeline_variants;
@ -760,7 +761,9 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
_bind_texture_binding(primitive->texture_binding.binding_id, p_draw_list); _bind_texture_binding(primitive->texture_binding.binding_id, p_draw_list);
} }
for (uint32_t j = 0; j < primitive->point_count; j++) { RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[MIN(3, primitive->point_count) - 1]);
for (uint32_t j = 0; j < MIN(3, primitive->point_count); j++) {
push_constant.points[j * 2 + 0] = primitive->points[j].x; push_constant.points[j * 2 + 0] = primitive->points[j].x;
push_constant.points[j * 2 + 1] = primitive->points[j].y; push_constant.points[j * 2 + 1] = primitive->points[j].y;
push_constant.uvs[j * 2 + 0] = primitive->uvs[j].x; push_constant.uvs[j * 2 + 0] = primitive->uvs[j].x;
@ -770,11 +773,24 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
push_constant.colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b); push_constant.colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b);
} }
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant)); RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant));
RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[primitive->point_count - 1]);
RD::get_singleton()->draw_list_draw(p_draw_list, true); RD::get_singleton()->draw_list_draw(p_draw_list, true);
if (primitive->point_count == 4) {
for (uint32_t j = 1; j < 3; j++) {
//second half of triangle
push_constant.points[j * 2 + 0] = primitive->points[j + 1].x;
push_constant.points[j * 2 + 1] = primitive->points[j + 1].y;
push_constant.uvs[j * 2 + 0] = primitive->uvs[j + 1].x;
push_constant.uvs[j * 2 + 1] = primitive->uvs[j + 1].y;
Color col = primitive->colors[j + 1] * p_modulate;
push_constant.colors[j * 2 + 0] = (uint32_t(Math::make_half_float(col.g)) << 16) | Math::make_half_float(col.r);
push_constant.colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b);
}
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant));
RD::get_singleton()->draw_list_draw(p_draw_list, true);
}
} break; } break;
#if 0 #if 0
@ -1364,7 +1380,7 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) {
RD::AttachmentFormat af; RD::AttachmentFormat af;
af.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; af.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
af.samples = RD::TEXTURE_SAMPLES_1; af.samples = RD::TEXTURE_SAMPLES_1;
af.usage_flags = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; af.usage_flags = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_RETRIEVE_BIT;
Vector<RD::AttachmentFormat> formats; Vector<RD::AttachmentFormat> formats;
formats.push_back(af); formats.push_back(af);
shader.framebuffer_formats[RENDER_TARGET_FORMAT_8_BIT_INT] = RD::get_singleton()->framebuffer_format_create(formats); shader.framebuffer_formats[RENDER_TARGET_FORMAT_8_BIT_INT] = RD::get_singleton()->framebuffer_format_create(formats);

View file

@ -179,6 +179,23 @@ class RasterizerCanvasRD : public RasterizerCanvas {
/**** MATERIALS ****/ /**** MATERIALS ****/
/*******************/ /*******************/
/******************/
/**** LIGHTING ****/
/******************/
enum {
LIGHT_GRID_WIDTH = 16,
LIGHT_GRID_HEIGHT = 16,
MAX_LIGHTS = 128
};
struct {
RID grid_texture;
RID grid_buffer;
PoolVector<uint8_t> grid_texture_data;
PoolVector<uint8_t> grid_buffer_data;
} lighting;
/***************/ /***************/
/**** STATE ****/ /**** STATE ****/
/***************/ /***************/
@ -213,16 +230,17 @@ class RasterizerCanvasRD : public RasterizerCanvas {
float ninepatch_margins[4]; float ninepatch_margins[4];
float dst_rect[4]; float dst_rect[4];
float src_rect[4]; float src_rect[4];
float color_texture_pixel_size[2]; float pad[2];
uint32_t pad[6];
}; };
//primitive //primitive
struct { struct {
float points[8]; // vec2 points[4] float points[6]; // vec2 points[4]
uint32_t colors[8]; // colors encoded as half float uvs[6]; // vec2 points[4]
float uvs[8]; // vec2 points[4] uint32_t colors[6]; // colors encoded as half
}; };
}; };
float color_texture_pixel_size[2];
uint32_t lights[4];
}; };
struct SkeletonUniform { struct SkeletonUniform {

View file

@ -59,20 +59,11 @@ void main() {
vertex = draw_data.points[1]; vertex = draw_data.points[1];
uv = draw_data.uvs[1]; uv = draw_data.uvs[1];
color = vec4(unpackHalf2x16(draw_data.colors[2]),unpackHalf2x16(draw_data.colors[3])); color = vec4(unpackHalf2x16(draw_data.colors[2]),unpackHalf2x16(draw_data.colors[3]));
} else if (gl_VertexIndex==2) { } else {
vertex = draw_data.points[2]; vertex = draw_data.points[2];
uv = draw_data.uvs[2]; uv = draw_data.uvs[2];
color = vec4(unpackHalf2x16(draw_data.colors[4]),unpackHalf2x16(draw_data.colors[5])); color = vec4(unpackHalf2x16(draw_data.colors[4]),unpackHalf2x16(draw_data.colors[5]));
} else {
vertex = draw_data.points[3];
uv = draw_data.uvs[3];
color = vec4(unpackHalf2x16(draw_data.colors[6]),unpackHalf2x16(draw_data.colors[7]));
} }
// this does not
// vec2 vertex = draw_data.points[gl_VertexIndex];
// vec2 uv = draw_data.uvs[gl_VertexIndex];
// vec4 color = vec4(unpackHalf2x16(draw_data.colors[gl_VertexIndex*2+0]),unpackHalf2x16(draw_data.colors[gl_VertexIndex*2+1]));
uvec4 bone_indices = uvec4(0,0,0,0); uvec4 bone_indices = uvec4(0,0,0,0);
vec4 bone_weights = vec4(0,0,0,0); vec4 bone_weights = vec4(0,0,0,0);

View file

@ -21,6 +21,8 @@
#define FLAGS_NINEPATCH_H_MODE_SHIFT 16 #define FLAGS_NINEPATCH_H_MODE_SHIFT 16
#define FLAGS_NINEPATCH_V_MODE_SHIFT 18 #define FLAGS_NINEPATCH_V_MODE_SHIFT 18
#define FLAGS_LIGHT_COUNT_SHIFT 20
layout(push_constant, binding = 0, std430) uniform DrawData { layout(push_constant, binding = 0, std430) uniform DrawData {
vec2 world_x; vec2 world_x;
vec2 world_y; vec2 world_y;
@ -28,17 +30,19 @@ layout(push_constant, binding = 0, std430) uniform DrawData {
uint flags; uint flags;
uint specular_shininess; uint specular_shininess;
#ifdef USE_PRIMITIVE #ifdef USE_PRIMITIVE
vec2 points[4]; vec2 points[3];
uint colors[8]; vec2 uvs[3];
vec2 uvs[4]; uint colors[6];
#else #else
vec4 modulation; vec4 modulation;
vec4 ninepatch_margins; vec4 ninepatch_margins;
vec4 dst_rect; //for built-in rect and UV vec4 dst_rect; //for built-in rect and UV
vec4 src_rect; vec4 src_rect;
vec2 color_texture_pixel_size; vec2 pad;
uint pad[6];
#endif #endif
vec2 color_texture_pixel_size;
uint lights[4];
} draw_data; } draw_data;

View file

@ -54,7 +54,6 @@ public:
Vector2 ysort_pos; Vector2 ysort_pos;
VS::CanvasItemTextureFilter texture_filter; VS::CanvasItemTextureFilter texture_filter;
VS::CanvasItemTextureRepeat texture_repeat; VS::CanvasItemTextureRepeat texture_repeat;
int z_final;
Vector<Item *> child_items; Vector<Item *> child_items;