Fix various GCC compilation warnings after Vulkan merge

Part of #36132.
This commit is contained in:
Rémi Verschelde 2020-02-13 15:53:32 +01:00
parent 3679d49f4b
commit d2537407ef
19 changed files with 71 additions and 53 deletions

View file

@ -3,12 +3,13 @@
Import('env')
env_spirv_reflect = env.Clone()
env_spirv_reflect.disable_warnings()
thirdparty_dir = "#thirdparty/spirv-reflect/"
thirdparty_sources = [
"spirv_reflect.c"
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_spirv_reflect.add_source_files(env.drivers_sources, thirdparty_sources)

View file

@ -1997,8 +1997,8 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
//create view
ERR_FAIL_INDEX_V(p_mipmap, src_texture->mipmaps, RID());
ERR_FAIL_INDEX_V(p_layer, src_texture->layers, RID());
ERR_FAIL_UNSIGNED_INDEX_V(p_mipmap, src_texture->mipmaps, RID());
ERR_FAIL_UNSIGNED_INDEX_V(p_layer, src_texture->layers, RID());
Texture texture = *src_texture;
get_image_format_required_size(texture.format, texture.width, texture.height, texture.depth, p_mipmap + 1, &texture.width, &texture.height);
@ -6940,15 +6940,15 @@ uint64_t RenderingDeviceVulkan::get_captured_timestamps_frame() const {
}
uint64_t RenderingDeviceVulkan::get_captured_timestamp_gpu_time(uint32_t p_index) const {
ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
return frames[frame].timestamp_result_values[p_index] * limits.timestampPeriod;
}
uint64_t RenderingDeviceVulkan::get_captured_timestamp_cpu_time(uint32_t p_index) const {
ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
return frames[frame].timestamp_cpu_result_values[p_index];
}
String RenderingDeviceVulkan::get_captured_timestamp_name(uint32_t p_index) const {
ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, String());
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, String());
return frames[frame].timestamp_result_names[p_index];
}

View file

@ -1344,6 +1344,7 @@ Error VulkanContext::swap_buffers() {
/*swapchainCount*/ 0,
/*pSwapchain*/ NULL,
/*pImageIndices*/ NULL,
/*pResults*/ NULL,
};
VkSwapchainKHR *pSwapchains = (VkSwapchainKHR *)alloca(sizeof(VkSwapchainKHR *) * windows.size());

View file

@ -90,9 +90,6 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float
Ref<ImageTexture> icon = memnew(ImageTexture);
Ref<Image> img = memnew(Image);
// dumb gizmo check
bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo");
// Upsample icon generation only if the editor scale isn't an integer multiplier.
// Generating upsampled icons is slower, and the benefit is hardly visible
// with integer editor scales.

View file

@ -113,12 +113,6 @@ void EditorVisualProfiler::clear() {
seeking = false;
}
static String _get_percent_txt(float p_value, float p_total) {
if (p_total == 0)
p_total = 0.00001;
return String::num((p_value / p_total) * 100, 1) + "%";
}
String EditorVisualProfiler::_get_time_as_text(float p_time) {
int dmode = display_mode->get_selected();
@ -126,7 +120,7 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) {
if (dmode == DISPLAY_FRAME_TIME) {
return rtos(p_time) + "ms";
} else if (dmode == DISPLAY_FRAME_PERCENT) {
return String::num(p_time * 100 / graph_limit, 2) + "%"; //_get_percent_txt(p_time, m.frame_time);
return String::num(p_time * 100 / graph_limit, 2) + "%";
}
return "err";

View file

@ -207,6 +207,9 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
case SL::Node::TYPE_ARRAY_DECLARATION: {
// FIXME: Implement
} break;
case SL::Node::TYPE_ARRAY_CONSTRUCT: {
// FIXME: Implement
} break;
case SL::Node::TYPE_CONSTANT: {
SL::ConstantNode *cnode = (SL::ConstantNode *)p_node;
return get_constant_text(cnode->datatype, cnode->values);

View file

@ -320,10 +320,10 @@ public:
static void set_texture_mapping_mode(aiTextureMapMode *map_mode, Ref<ImageTexture> texture) {
ERR_FAIL_COND(texture.is_null());
ERR_FAIL_COND(map_mode == NULL);
aiTextureMapMode tex_mode = map_mode[0];
// FIXME: Commented out during Vulkan port.
/*
aiTextureMapMode tex_mode = map_mode[0];
int32_t flags = Texture2D::FLAGS_DEFAULT;
if (tex_mode == aiTextureMapMode_Wrap) {
//Default

View file

@ -28,7 +28,11 @@ tool_sources = [
tool_sources = [thirdparty_dir + file for file in tool_sources]
transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
env_basisu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"])
# Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
env_basisu.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path, '-isystem', Dir(thirdparty_dir + "transcoder").path])
else:
env_basisu.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"])
if env['target'] == "debug":
env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"])

View file

@ -277,7 +277,9 @@ godot_transform GDAPI godot_arvr_get_reference_frame() {
void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
// blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
ARVRInterface::Eyes eye = (ARVRInterface::Eyes)p_eye;
#if 0
RID *render_target = (RID *)p_render_target;
#endif
Rect2 screen_rect = *(Rect2 *)p_rect;
if (eye == ARVRInterface::EYE_LEFT) {
@ -297,9 +299,12 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
// In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
// This is a handy function to expose that.
#if 0
RID *render_target = (RID *)p_render_target;
RID eye_texture = VSG::storage->render_target_get_texture(*render_target);
#endif
#ifndef _MSC_VER
#warning need to obtain this ID again
#endif

View file

@ -1087,7 +1087,7 @@ PoolVector<uint8_t> Voxelizer::get_sdf_3d_image() const {
if (d == 0) {
w[i] = 0;
} else {
w[i] = CLAMP(d, 0, 254) + 1;
w[i] = MIN(d, 254) + 1;
}
}
}

View file

@ -423,6 +423,7 @@ void BaseMaterial3D::_update_shader() {
case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texfilter_str = "filter_linear_mipmap"; break;
case TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS_ANISOTROPIC: texfilter_str = "filter_nearest_mipmap_aniso"; break;
case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: texfilter_str = "filter_linear_mipmap_aniso"; break;
case TEXTURE_FILTER_MAX: break; // Internal value, skip.
}
if (flags[FLAG_USE_TEXTURE_REPEAT]) {

View file

@ -1080,8 +1080,8 @@ public:
const Item::CommandTransform *transform = static_cast<const Item::CommandTransform *>(c);
xf = transform->xform;
found_xform = true;
} //passthrough
FALLTHROUGH;
}
default: {
c = c->next;
continue;

View file

@ -112,8 +112,8 @@ void LightClusterBuilder::bake_cluster() {
int sx = MAX(0, from_x);
int sy = MAX(0, from_y);
int dx = MIN(width - 1, to_x);
int dy = MIN(height - 1, to_y);
int dx = MIN((int)width - 1, to_x);
int dy = MIN((int)height - 1, to_y);
//print_line(itos(j) + " - " + Vector2i(sx, sy) + " -> " + Vector2i(dx, dy));

View file

@ -1409,7 +1409,7 @@ void RasterizerSceneHighEndRD::_setup_reflections(RID *p_reflection_probe_cull_r
}
if (p_reflection_probe_cull_count) {
RD::get_singleton()->buffer_update(scene_state.reflection_buffer, 0, MIN(scene_state.max_reflections, p_reflection_probe_cull_count) * sizeof(ReflectionData), scene_state.reflections, true);
RD::get_singleton()->buffer_update(scene_state.reflection_buffer, 0, MIN(scene_state.max_reflections, (unsigned int)p_reflection_probe_cull_count) * sizeof(ReflectionData), scene_state.reflections, true);
}
}
@ -1566,10 +1566,10 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, VS::LIGHT_PARAM_ATTENUATION));
light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, VS::LIGHT_PARAM_ENERGY) * Math_PI);
light_data.color_specular[0] = CLAMP(uint32_t(linear_col.r * 255), 0, 255);
light_data.color_specular[1] = CLAMP(uint32_t(linear_col.g * 255), 0, 255);
light_data.color_specular[2] = CLAMP(uint32_t(linear_col.b * 255), 0, 255);
light_data.color_specular[3] = CLAMP(uint32_t(storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR) * 255), 0, 255);
light_data.color_specular[0] = MIN(uint32_t(linear_col.r * 255), 255);
light_data.color_specular[1] = MIN(uint32_t(linear_col.g * 255), 255);
light_data.color_specular[2] = MIN(uint32_t(linear_col.b * 255), 255);
light_data.color_specular[3] = MIN(uint32_t(storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR) * 255), 255);
float radius = MAX(0.001, storage->light_get_param(base, VS::LIGHT_PARAM_RANGE));
light_data.inv_radius = 1.0 / radius;
@ -1595,9 +1595,9 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
Color shadow_color = storage->light_get_shadow_color(base);
bool has_shadow = p_using_shadows && storage->light_has_shadow(base);
light_data.shadow_color_enabled[0] = CLAMP(uint32_t(shadow_color.r * 255), 0, 255);
light_data.shadow_color_enabled[1] = CLAMP(uint32_t(shadow_color.g * 255), 0, 255);
light_data.shadow_color_enabled[2] = CLAMP(uint32_t(shadow_color.b * 255), 0, 255);
light_data.shadow_color_enabled[0] = MIN(uint32_t(shadow_color.r * 255), 255);
light_data.shadow_color_enabled[1] = MIN(uint32_t(shadow_color.g * 255), 255);
light_data.shadow_color_enabled[2] = MIN(uint32_t(shadow_color.b * 255), 255);
light_data.shadow_color_enabled[3] = has_shadow ? 255 : 0;
light_data.atlas_rect[0] = 0;

View file

@ -1958,7 +1958,7 @@ VS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) co
void RasterizerStorageRD::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
@ -1969,7 +1969,7 @@ void RasterizerStorageRD::mesh_surface_update_region(RID p_mesh, int p_surface,
void RasterizerStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
mesh->surfaces[p_surface]->material = p_material;
mesh->instance_dependency.instance_notify_changed(false, true);
@ -1978,7 +1978,7 @@ void RasterizerStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, R
RID RasterizerStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
ERR_FAIL_INDEX_V((uint32_t)p_surface, mesh->surface_count, RID());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RID());
return mesh->surfaces[p_surface]->material;
}
@ -1987,7 +1987,7 @@ VS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface)
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, VS::SurfaceData());
ERR_FAIL_INDEX_V((uint32_t)p_surface, mesh->surface_count, VS::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, VS::SurfaceData());
Mesh::Surface &s = *mesh->surfaces[p_surface];
@ -2468,7 +2468,7 @@ void RasterizerStorageRD::_multimesh_mark_dirty(MultiMesh *multimesh, int p_inde
uint32_t region_index = p_index / MULTIMESH_DIRTY_REGION_SIZE;
#ifdef DEBUG_ENABLED
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
ERR_FAIL_INDEX(region_index, data_cache_dirty_region_count); //bug
ERR_FAIL_UNSIGNED_INDEX(region_index, data_cache_dirty_region_count); //bug
#endif
if (!multimesh->data_cache_dirty_regions[region_index]) {
multimesh->data_cache_dirty_regions[p_index] = true;
@ -3581,7 +3581,7 @@ void RasterizerStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_t
uint32_t cell_count = p_octree_cells.size() / 32;
ERR_FAIL_COND(p_data_cells.size() != cell_count * 16); //see that data size matches
ERR_FAIL_COND(p_data_cells.size() != (int)cell_count * 16); //see that data size matches
gi_probe->cell_count = cell_count;
gi_probe->octree_buffer = RD::get_singleton()->storage_buffer_create(p_octree_cells.size(), p_octree_cells);

View file

@ -657,7 +657,7 @@ public:
_FORCE_INLINE_ VS::PrimitiveType mesh_surface_get_primitive(RID p_mesh, uint32_t p_surface_index) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_MAX);
ERR_FAIL_INDEX_V(p_surface_index, mesh->surface_count, VS::PRIMITIVE_MAX);
ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, VS::PRIMITIVE_MAX);
return mesh->surfaces[p_surface_index]->primitive;
}
@ -665,7 +665,7 @@ public:
_FORCE_INLINE_ void mesh_surface_get_arrays_and_format(RID p_mesh, uint32_t p_surface_index, uint32_t p_input_mask, RID &r_vertex_array_rd, RID &r_index_array_rd, RD::VertexFormatID &r_vertex_format) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX(p_surface_index, mesh->surface_count);
ERR_FAIL_UNSIGNED_INDEX(p_surface_index, mesh->surface_count);
Mesh::Surface *s = mesh->surfaces[p_surface_index];

View file

@ -60,9 +60,5 @@ PoolVector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_st
}
RenderingDevice::RenderingDevice() {
ShaderCompileFunction compile_function;
ShaderCacheFunction cache_function;
singleton = this;
}

View file

@ -2708,31 +2708,43 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "CubeMap";
} break;
case ShaderLanguage::TYPE_STRUCT: {
// FIXME: Implement this.
} break;
}
return pi;
}
uint32_t ShaderLanguage::get_type_size(DataType p_type) {
switch (p_type) {
case TYPE_VOID:
return 0;
case TYPE_BOOL:
case TYPE_INT:
case TYPE_UINT:
case TYPE_FLOAT: return 4;
case TYPE_FLOAT:
return 4;
case TYPE_BVEC2:
case TYPE_IVEC2:
case TYPE_UVEC2:
case TYPE_VEC2: return 8;
case TYPE_VEC2:
return 8;
case TYPE_BVEC3:
case TYPE_IVEC3:
case TYPE_UVEC3:
case TYPE_VEC3: return 12;
case TYPE_VEC3:
return 12;
case TYPE_BVEC4:
case TYPE_IVEC4:
case TYPE_UVEC4:
case TYPE_VEC4: return 16;
case TYPE_MAT2: return 8;
case TYPE_MAT3: return 12;
case TYPE_MAT4: return 16;
case TYPE_VEC4:
return 16;
case TYPE_MAT2:
return 8;
case TYPE_MAT3:
return 12;
case TYPE_MAT4:
return 16;
case TYPE_SAMPLER2D:
case TYPE_ISAMPLER2D:
case TYPE_USAMPLER2D:
@ -2742,7 +2754,11 @@ uint32_t ShaderLanguage::get_type_size(DataType p_type) {
case TYPE_SAMPLER3D:
case TYPE_ISAMPLER3D:
case TYPE_USAMPLER3D:
case TYPE_SAMPLERCUBE: return 4; //not really, but useful for indices
case TYPE_SAMPLERCUBE:
return 4; //not really, but useful for indices
case TYPE_STRUCT:
// FIXME: Implement.
return 0;
}
return 0;
}

View file

@ -139,7 +139,7 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
uint64_t base_cpu = VSG::storage->get_captured_timestamp_cpu_time(0);
uint64_t base_gpu = VSG::storage->get_captured_timestamp_gpu_time(0);
for (int i = 0; i < VSG::storage->get_captured_timestamps_count(); i++) {
for (uint32_t i = 0; i < VSG::storage->get_captured_timestamps_count(); i++) {
uint64_t time_cpu = VSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu;
uint64_t time_gpu = VSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu;
new_profile.write[i].gpu_msec = float(time_gpu / 1000) / 1000.0;