|
@@ -687,6 +687,8 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
|
|
|
|
|
|
state.current_tex = RID();
|
|
state.current_tex = RID();
|
|
|
|
|
|
|
|
+ const uint64_t base_specialization = GLES3::Config::get_singleton()->float_texture_supported ? 0 : CanvasShaderGLES3::USE_RGBA_SHADOWS;
|
|
|
|
+
|
|
for (uint32_t i = 0; i <= state.current_batch_index; i++) {
|
|
for (uint32_t i = 0; i <= state.current_batch_index; i++) {
|
|
// Skipping when there is no instances.
|
|
// Skipping when there is no instances.
|
|
if (state.canvas_instance_batches[i].instance_count == 0) {
|
|
if (state.canvas_instance_batches[i].instance_count == 0) {
|
|
@@ -705,10 +707,9 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
|
|
}
|
|
}
|
|
|
|
|
|
GLES3::CanvasMaterialData *material_data = state.canvas_instance_batches[i].material_data;
|
|
GLES3::CanvasMaterialData *material_data = state.canvas_instance_batches[i].material_data;
|
|
- CanvasShaderGLES3::ShaderVariant variant = state.canvas_instance_batches[i].shader_variant;
|
|
|
|
- uint64_t specialization = 0;
|
|
|
|
- specialization |= uint64_t(state.canvas_instance_batches[i].lights_disabled);
|
|
|
|
- specialization |= uint64_t(!GLES3::Config::get_singleton()->float_texture_supported) << 1;
|
|
|
|
|
|
+ CanvasShaderGLES3::ShaderVariant variant = CanvasShaderGLES3::MODE_DEFAULT;
|
|
|
|
+ uint64_t specialization = state.canvas_instance_batches[i].specialization;
|
|
|
|
+ specialization |= base_specialization;
|
|
RID shader_version = data.canvas_shader_default_version;
|
|
RID shader_version = data.canvas_shader_default_version;
|
|
|
|
|
|
if (material_data) {
|
|
if (material_data) {
|
|
@@ -810,6 +811,7 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
|
|
|
|
|
|
void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_render_target, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip, GLES3::CanvasShaderData::BlendMode p_blend_mode, Light *p_lights, uint32_t &r_index, bool &r_batch_broken, bool &r_sdf_used, const Point2 &p_repeat_offset) {
|
|
void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_render_target, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip, GLES3::CanvasShaderData::BlendMode p_blend_mode, Light *p_lights, uint32_t &r_index, bool &r_batch_broken, bool &r_sdf_used, const Point2 &p_repeat_offset) {
|
|
RenderingServer::CanvasItemTextureFilter texture_filter = p_item->texture_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? state.default_filter : p_item->texture_filter;
|
|
RenderingServer::CanvasItemTextureFilter texture_filter = p_item->texture_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? state.default_filter : p_item->texture_filter;
|
|
|
|
+ const uint64_t specialization_command_mask = ~(CanvasShaderGLES3::USE_NINEPATCH | CanvasShaderGLES3::USE_PRIMITIVE | CanvasShaderGLES3::USE_ATTRIBUTES | CanvasShaderGLES3::USE_INSTANCING);
|
|
|
|
|
|
if (texture_filter != state.canvas_instance_batches[state.current_batch_index].filter) {
|
|
if (texture_filter != state.canvas_instance_batches[state.current_batch_index].filter) {
|
|
_new_batch(r_batch_broken);
|
|
_new_batch(r_batch_broken);
|
|
@@ -868,9 +870,9 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
|
|
|
|
bool lights_disabled = light_count == 0 && !state.using_directional_lights;
|
|
bool lights_disabled = light_count == 0 && !state.using_directional_lights;
|
|
|
|
|
|
- if (lights_disabled != state.canvas_instance_batches[state.current_batch_index].lights_disabled) {
|
|
|
|
|
|
+ if (lights_disabled != bool(state.canvas_instance_batches[state.current_batch_index].specialization & CanvasShaderGLES3::DISABLE_LIGHTING)) {
|
|
_new_batch(r_batch_broken);
|
|
_new_batch(r_batch_broken);
|
|
- state.canvas_instance_batches[state.current_batch_index].lights_disabled = lights_disabled;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization ^= CanvasShaderGLES3::DISABLE_LIGHTING;
|
|
}
|
|
}
|
|
|
|
|
|
const Item::Command *c = p_item->commands;
|
|
const Item::Command *c = p_item->commands;
|
|
@@ -936,7 +938,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
state.canvas_instance_batches[state.current_batch_index].tex = rect->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = rect->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_RECT;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_RECT;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_QUAD;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask;
|
|
}
|
|
}
|
|
|
|
|
|
_prepare_canvas_texture(rect->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
_prepare_canvas_texture(rect->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
@@ -1026,7 +1028,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
state.canvas_instance_batches[state.current_batch_index].tex = np->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = np->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_NINEPATCH;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_NINEPATCH;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_NINEPATCH;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask;
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_NINEPATCH;
|
|
}
|
|
}
|
|
|
|
|
|
_prepare_canvas_texture(np->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
_prepare_canvas_texture(np->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
@@ -1092,7 +1095,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
state.canvas_instance_batches[state.current_batch_index].tex = polygon->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = polygon->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_POLYGON;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_POLYGON;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_ATTRIBUTES;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask;
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_ATTRIBUTES;
|
|
|
|
|
|
_prepare_canvas_texture(polygon->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
_prepare_canvas_texture(polygon->texture, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
|
|
|
|
@@ -1119,7 +1123,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
state.canvas_instance_batches[state.current_batch_index].primitive_points = primitive->point_count;
|
|
state.canvas_instance_batches[state.current_batch_index].primitive_points = primitive->point_count;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_PRIMITIVE;
|
|
state.canvas_instance_batches[state.current_batch_index].command_type = Item::Command::TYPE_PRIMITIVE;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
state.canvas_instance_batches[state.current_batch_index].command = c;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_PRIMITIVE;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask;
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_PRIMITIVE;
|
|
}
|
|
}
|
|
|
|
|
|
_prepare_canvas_texture(state.canvas_instance_batches[state.current_batch_index].tex, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
_prepare_canvas_texture(state.canvas_instance_batches[state.current_batch_index].tex, state.canvas_instance_batches[state.current_batch_index].filter, state.canvas_instance_batches[state.current_batch_index].repeat, r_index, texpixel_size);
|
|
@@ -1164,7 +1169,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
_new_batch(r_batch_broken);
|
|
_new_batch(r_batch_broken);
|
|
|
|
|
|
Color modulate(1, 1, 1, 1);
|
|
Color modulate(1, 1, 1, 1);
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_ATTRIBUTES;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization &= specialization_command_mask;
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_ATTRIBUTES;
|
|
if (c->type == Item::Command::TYPE_MESH) {
|
|
if (c->type == Item::Command::TYPE_MESH) {
|
|
const Item::CommandMesh *m = static_cast<const Item::CommandMesh *>(c);
|
|
const Item::CommandMesh *m = static_cast<const Item::CommandMesh *>(c);
|
|
state.canvas_instance_batches[state.current_batch_index].tex = m->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = m->texture;
|
|
@@ -1174,7 +1180,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
} else if (c->type == Item::Command::TYPE_MULTIMESH) {
|
|
} else if (c->type == Item::Command::TYPE_MULTIMESH) {
|
|
const Item::CommandMultiMesh *mm = static_cast<const Item::CommandMultiMesh *>(c);
|
|
const Item::CommandMultiMesh *mm = static_cast<const Item::CommandMultiMesh *>(c);
|
|
state.canvas_instance_batches[state.current_batch_index].tex = mm->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = mm->texture;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_INSTANCING;
|
|
|
|
|
|
if (GLES3::MeshStorage::get_singleton()->multimesh_uses_colors(mm->multimesh)) {
|
|
if (GLES3::MeshStorage::get_singleton()->multimesh_uses_colors(mm->multimesh)) {
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS;
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS;
|
|
@@ -1189,7 +1195,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
|
const Item::CommandParticles *pt = static_cast<const Item::CommandParticles *>(c);
|
|
const Item::CommandParticles *pt = static_cast<const Item::CommandParticles *>(c);
|
|
RID particles = pt->particles;
|
|
RID particles = pt->particles;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = pt->texture;
|
|
state.canvas_instance_batches[state.current_batch_index].tex = pt->texture;
|
|
- state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED;
|
|
|
|
|
|
+ state.canvas_instance_batches[state.current_batch_index].specialization |= CanvasShaderGLES3::USE_INSTANCING;
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS;
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS;
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA;
|
|
state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA;
|
|
|
|
|