1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fixes and optimizations to mobile renderer

* Only apply final actions to attachments used in the last pass.
* Fixes to draw list final action (was using continue instead of read/drop).
* Profiling regions inside draw lists now properly throw errors.
* Ability to enable gpu profile printing from project settings. (used to debug).
This commit is contained in:
reduz
2021-08-10 21:50:28 -03:00
parent 18bd0fee5a
commit ca117910da
8 changed files with 140 additions and 67 deletions

View File

@@ -3,7 +3,7 @@
#define LIGHT_BAKE_STATIC 2
struct LightData { //this structure needs to be as packed as possible
vec3 position;
highp vec3 position;
float inv_radius;
vec3 direction;
@@ -17,8 +17,8 @@ struct LightData { //this structure needs to be as packed as possible
float specular_amount;
bool shadow_enabled;
vec4 atlas_rect; // rect in the shadow atlas
mat4 shadow_matrix;
highp vec4 atlas_rect; // rect in the shadow atlas
highp mat4 shadow_matrix;
float shadow_bias;
float shadow_normal_bias;
float transmittance_bias;
@@ -27,7 +27,7 @@ struct LightData { //this structure needs to be as packed as possible
uint mask;
float shadow_volumetric_fog_fade;
uint bake_mode;
vec4 projector_rect; //projector rect in srgb decal atlas
highp vec4 projector_rect; //projector rect in srgb decal atlas
};
#define REFLECTION_AMBIENT_DISABLED 0
@@ -69,13 +69,13 @@ struct DirectionalLightData {
vec4 shadow_bias;
vec4 shadow_normal_bias;
vec4 shadow_transmittance_bias;
vec4 shadow_z_range;
vec4 shadow_range_begin;
highp vec4 shadow_z_range;
highp vec4 shadow_range_begin;
vec4 shadow_split_offsets;
mat4 shadow_matrix1;
mat4 shadow_matrix2;
mat4 shadow_matrix3;
mat4 shadow_matrix4;
highp mat4 shadow_matrix1;
highp mat4 shadow_matrix2;
highp mat4 shadow_matrix3;
highp mat4 shadow_matrix4;
vec4 shadow_color1;
vec4 shadow_color2;
vec4 shadow_color3;

View File

@@ -59,27 +59,27 @@ layout(location = 11) in vec4 weight_attrib;
/* Varyings */
layout(location = 0) out vec3 vertex_interp;
layout(location = 0) highp out vec3 vertex_interp;
#ifdef NORMAL_USED
layout(location = 1) out vec3 normal_interp;
layout(location = 1) mediump out vec3 normal_interp;
#endif
#if defined(COLOR_USED)
layout(location = 2) out vec4 color_interp;
layout(location = 2) mediump out vec4 color_interp;
#endif
#ifdef UV_USED
layout(location = 3) out vec2 uv_interp;
layout(location = 3) mediump out vec2 uv_interp;
#endif
#if defined(UV2_USED) || defined(USE_LIGHTMAP)
layout(location = 4) out vec2 uv2_interp;
layout(location = 4) mediump out vec2 uv2_interp;
#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 5) out vec3 tangent_interp;
layout(location = 6) out vec3 binormal_interp;
layout(location = 5) mediump out vec3 tangent_interp;
layout(location = 6) mediump out vec3 binormal_interp;
#endif
#ifdef MATERIAL_UNIFORMS_USED
@@ -370,6 +370,10 @@ void main() {
#VERSION_DEFINES
//use medium precision for floats on mobile.
precision mediump float;
/* Specialization Constants */
/* Specialization Constants (Toggles) */
@@ -395,32 +399,32 @@ layout(constant_id = 11) const bool sc_projector_use_mipmaps = true;
/* Varyings */
layout(location = 0) in vec3 vertex_interp;
layout(location = 0) highp in vec3 vertex_interp;
#ifdef NORMAL_USED
layout(location = 1) in vec3 normal_interp;
layout(location = 1) mediump in vec3 normal_interp;
#endif
#if defined(COLOR_USED)
layout(location = 2) in vec4 color_interp;
layout(location = 2) mediump in vec4 color_interp;
#endif
#ifdef UV_USED
layout(location = 3) in vec2 uv_interp;
layout(location = 3) mediump in vec2 uv_interp;
#endif
#if defined(UV2_USED) || defined(USE_LIGHTMAP)
layout(location = 4) in vec2 uv2_interp;
layout(location = 4) mediump in vec2 uv2_interp;
#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 5) in vec3 tangent_interp;
layout(location = 6) in vec3 binormal_interp;
layout(location = 5) mediump in vec3 tangent_interp;
layout(location = 6) mediump in vec3 binormal_interp;
#endif
#ifdef MODE_DUAL_PARABOLOID
layout(location = 8) in float dp_clip;
layout(location = 8) highp in float dp_clip;
#endif

View File

@@ -16,12 +16,12 @@
/* don't exceed 128 bytes!! */
/* put instance data into our push content, not a array */
layout(push_constant, binding = 0, std430) uniform DrawCall {
mat4 transform; // 64 - 64
highp mat4 transform; // 64 - 64
uint flags; // 04 - 68
uint instance_uniforms_ofs; //base offset in global buffer for instance variables // 04 - 72
uint gi_offset; //GI information when using lightmapping (VCT or lightmap index) // 04 - 76
uint layer_mask; // 04 - 80
vec4 lightmap_uv_scale; // 16 - 96 doubles as uv_offset when needed
highp vec4 lightmap_uv_scale; // 16 - 96 doubles as uv_offset when needed
uvec2 reflection_probes; // 08 - 104
uvec2 omni_lights; // 08 - 112
@@ -126,14 +126,14 @@ global_variables;
/* Set 1: Render Pass (changes per render pass) */
layout(set = 1, binding = 0, std140) uniform SceneData {
mat4 projection_matrix;
mat4 inv_projection_matrix;
mat4 camera_matrix;
mat4 inv_camera_matrix;
highp mat4 projection_matrix;
highp mat4 inv_projection_matrix;
highp mat4 camera_matrix;
highp mat4 inv_camera_matrix;
// only used for multiview
mat4 projection_matrix_view[MAX_VIEWS];
mat4 inv_projection_matrix_view[MAX_VIEWS];
highp mat4 projection_matrix_view[MAX_VIEWS];
highp mat4 inv_projection_matrix_view[MAX_VIEWS];
vec2 viewport_size;
vec2 screen_pixel_size;