Skip to content

Commit

Permalink
fix more warnings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chitalu committed Oct 4, 2023
1 parent 88a313e commit 56117bf
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 92 deletions.
14 changes: 7 additions & 7 deletions include/mcut/internal/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern "C" void debug_message_callback_impl(
extern "C" void get_debug_message_log_impl(McContext context,
McUint32 count, McSize bufSize,
McDebugSource* sources, McDebugType* types, McDebugSeverity* severities,
McSize* lengths, McChar* messageLog, McUint32& numFetched);
McSize* lengths, McChar* messageLog, McUint32& numFetched)noexcept(false);

extern "C" void debug_message_control_impl(
McContext context,
Expand All @@ -108,11 +108,11 @@ extern "C" void bind_state_impl(
const McContext context,
McFlags stateInfo,
McSize bytes,
const McVoid* pMem);
const McVoid* pMem)noexcept(false);

extern "C" void create_user_event_impl(McEvent* event, McContext context);
extern "C" void create_user_event_impl(McEvent* event, McContext context)noexcept(false);

extern "C" void set_user_event_status_impl(McEvent event, McInt32 execution_status);
extern "C" void set_user_event_status_impl(McEvent event, McInt32 execution_status)noexcept(false);

extern "C" void get_event_info_impl(
const McEvent event,
Expand All @@ -124,7 +124,7 @@ extern "C" void get_event_info_impl(
extern "C" void set_event_callback_impl(
McEvent eventHandle,
pfn_McEvent_CALLBACK eventCallback,
McVoid* data);
McVoid* data) noexcept(false);

extern "C" void wait_for_events_impl(
uint32_t numEventsInWaitlist,
Expand Down Expand Up @@ -367,7 +367,7 @@ struct event_t {
, m_timestamp_submit(0)
, m_timestamp_start(0)
, m_timestamp_end(0)
, m_command_exec_status(MC_RESULT_MAX_ENUM)
, m_command_exec_status((McUint32)((int)(MC_RESULT_MAX_ENUM)))
, m_profiling_enabled(true)
, m_command_type(command_type)
, m_user_API_command_task_emulator(nullptr)
Expand Down Expand Up @@ -558,7 +558,7 @@ struct context_t {
, m_user_handle(handle) // i.e. the McContext handle that the client application uses to reference an instance of the context
,m_most_recent_dispatch_intersection_type(McDispatchIntersectionType::MC_DISPATCH_INTERSECTION_TYPE_MAX_ENUM),
// debug callback flags (all zero/unset by default). User must specify what they want via debug control function.
, dbgCallbackBitfieldSource(0)
dbgCallbackBitfieldSource(0)
, dbgCallbackBitfieldType(0)
, dbgCallbackBitfieldSeverity(0)
{
Expand Down
16 changes: 8 additions & 8 deletions include/mcut/internal/tpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ void parallel_for(
// run just one thread)
const uint32_t min_per_thread = (1 << 10))
{
uint32_t const length_ = std::distance(first, last);
uint32_t const length_ = (uint32_t)std::distance(first, last);

MCUT_ASSERT(length_ != 0);
uint32_t block_size = 0;

uint32_t max_threads = 0;
const uint32_t available_threads = pool.get_num_threads() + 1; // workers and master (+1)
const uint32_t available_threads = (uint32_t)(pool.get_num_threads() + 1); // workers and master (+1)
uint32_t num_threads = 0;

get_scheduling_parameters(
Expand Down Expand Up @@ -471,14 +471,14 @@ void parallel_for(
// run just one thread)
const uint32_t min_per_thread = (1 << 10))
{
uint32_t const length_ = std::distance(first, last);
uint32_t const length_ = (uint32_t)std::distance(first, last);

MCUT_ASSERT(length_ != 0);

uint32_t block_size;

uint32_t max_threads = 0;
const uint32_t available_threads = pool.get_num_threads() + 1; // workers and master (+1)
const uint32_t available_threads = (uint32_t)(pool.get_num_threads() + 1); // workers and master (+1)
uint32_t num_threads = 0;

get_scheduling_parameters(
Expand Down Expand Up @@ -570,13 +570,13 @@ void parallel_partial_sum(thread_pool& pool, Iterator first, Iterator last)
};

// number of elements in range
unsigned long const length = std::distance(first, last);
uint32_t const length = (uint32_t)std::distance(first, last);

if (!length)
return;

uint32_t max_threads = 0;
const uint32_t available_threads = pool.get_num_threads() + 1; // workers and master (+1)
const uint32_t available_threads = (uint32_t)(pool.get_num_threads() + 1); // workers and master (+1)
uint32_t num_threads = 0;
uint32_t block_size = 0;

Expand Down Expand Up @@ -730,13 +730,13 @@ void find_map_element_by_key(Iterator begin, Iterator end,
template <typename Iterator, typename KeyType>
Iterator parallel_find_in_map_by_key(thread_pool& pool, Iterator first, Iterator last, KeyType match)
{
unsigned long const length = std::distance(first, last);
uint32_t const length = (uint32_t)std::distance(first, last);

if (!length)
return last;

uint32_t max_threads = 0;
const uint32_t available_threads = pool.get_num_threads() + 1; // workers and master (+1)
const uint32_t available_threads = (uint32_t)(pool.get_num_threads() + 1); // workers and master (+1)
uint32_t num_threads = 0;
uint32_t block_size = 0;

Expand Down
2 changes: 1 addition & 1 deletion source/bvh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void build_oibvh(
// allows us to pretend that we can use an iterator over the nodes
std::vector<uint8_t> level_nodes_placeholder(number_of_real_nodes_on_level);
auto fn_compute_bvh_level_nodes = [&](std::vector<uint8_t>::const_iterator block_start_, std::vector<uint8_t>::const_iterator block_end_) {
uint32_t base_offset = std::distance(level_nodes_placeholder.cbegin(), block_start_);
uint32_t base_offset = (uint32_t)std::distance(level_nodes_placeholder.cbegin(), block_start_);
uint32_t counter = 0;
for (std::vector<uint8_t>::const_iterator it = block_start_; it != block_end_; ++it) {
const int level_node_idx_iter = base_offset + (counter++);
Expand Down
46 changes: 23 additions & 23 deletions source/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ void generate_supertriangle_from_mesh_vertices(
if (have_double) {
memcpy(dst, &vertex0[i], flt_size);
} else {
float tmp = vertex0[i];
float tmp = (float)vertex0[i];
memcpy(dst, &tmp, flt_size);
}
counter++;
Expand All @@ -800,7 +800,7 @@ void generate_supertriangle_from_mesh_vertices(
if (have_double) {
memcpy(dst, &vertex1[i], flt_size);
} else {
float tmp = vertex1[i];
float tmp = (float)vertex1[i];
memcpy(dst, &tmp, flt_size);
}
counter++;
Expand All @@ -812,7 +812,7 @@ void generate_supertriangle_from_mesh_vertices(
if (have_double) {
memcpy(dst, &vertex2[i], flt_size);
} else {
float tmp = vertex2[i];
float tmp = (float)vertex2[i];
memcpy(dst, &tmp, flt_size);
}
counter++;
Expand Down Expand Up @@ -2083,7 +2083,7 @@ void get_connected_component_data_impl_detail(
throw std::invalid_argument("invalid number of bytes");
}

const uint32_t num_indices_to_copy = bytes / sizeof(uint32_t);
const uint32_t num_indices_to_copy = (uint32_t)(bytes / sizeof(uint32_t));
uint32_t* casted_ptr = reinterpret_cast<uint32_t*>(pMem);

#if defined(MCUT_WITH_COMPUTE_HELPER_THREADPOOL)
Expand Down Expand Up @@ -2131,7 +2131,7 @@ void get_connected_component_data_impl_detail(
//

auto fn_face_indices_copy = [flip_winding_order, &cc_uptr, &partial_sum_vec, &casted_ptr, &num_indices_to_copy](face_array_iterator_t block_start_, face_array_iterator_t block_end_) {
const uint32_t base_face_offset = std::distance(cc_uptr->kernel_hmesh_data->mesh->faces_begin(), block_start_);
const uint32_t base_face_offset = (uint32_t)std::distance(cc_uptr->kernel_hmesh_data->mesh->faces_begin(), block_start_);

MCUT_ASSERT(base_face_offset < (uint32_t)cc_uptr->face_sizes_cache.size());

Expand Down Expand Up @@ -2424,7 +2424,7 @@ void get_connected_component_data_impl_detail(
//

auto fn_face_adjface_indices_copy = [&cc_uptr, &partial_sum_vec, &casted_ptr](face_array_iterator_t block_start_, face_array_iterator_t block_end_) {
const uint32_t base_face_offset = std::distance(cc_uptr->kernel_hmesh_data->mesh->faces_begin(), block_start_);
const uint32_t base_face_offset = (uint32_t)std::distance(cc_uptr->kernel_hmesh_data->mesh->faces_begin(), block_start_);

MCUT_ASSERT(base_face_offset < (uint32_t)cc_uptr->face_adjacent_faces_size_cache.size());

Expand Down Expand Up @@ -2745,7 +2745,7 @@ void get_connected_component_data_impl_detail(
throw std::invalid_argument("invalid number of bytes");
}

const uint32_t elems_to_copy = bytes / sizeof(uint32_t);
const uint32_t elems_to_copy = (uint32_t)(bytes / sizeof(uint32_t));

uint32_t* casted_ptr = reinterpret_cast<uint32_t*>(pMem);

Expand Down Expand Up @@ -2800,7 +2800,7 @@ void get_connected_component_data_impl_detail(
std::vector<uint32_t>& seam_vertex_sequence_array = cc_uptr->seam_vertex_sequence_array_cache;

McUint32 total_seq_count = 0;
const uint32_t total_seq_count_idx = seam_vertex_sequence_array.size();
const uint32_t total_seq_count_idx = (uint32_t)seam_vertex_sequence_array.size();
MCUT_ASSERT(total_seq_count_idx == 0);

seam_vertex_sequence_array.push_back(MC_UNDEFINED_VALUE); // location that we will used to store total_seq_count at the end
Expand Down Expand Up @@ -2977,7 +2977,7 @@ void get_connected_component_data_impl_detail(
have_loop = (num_adj_seam_vertices == 2) ? MC_TRUE : MC_FALSE;
}

const uint32_t num_vertices_in_built_sequence = std::distance(
const uint32_t num_vertices_in_built_sequence = (uint32_t)std::distance(
seam_vertex_sequence_array.cbegin() + seam_vertex_sequence_array_start_offset + 2,
seam_vertex_sequence_array.cend());

Expand Down Expand Up @@ -3020,7 +3020,7 @@ void get_connected_component_data_impl_detail(
throw std::invalid_argument("invalid number of bytes");
}

const uint32_t elems_to_copy = bytes / sizeof(uint32_t);
const uint32_t elems_to_copy = (uint32_t)(bytes / sizeof(uint32_t));

uint32_t* casted_ptr = reinterpret_cast<uint32_t*>(pMem);

Expand All @@ -3034,13 +3034,13 @@ void get_connected_component_data_impl_detail(
elem_offset++;
}

MCUT_ASSERT(elem_offset <= cc_uptr->seam_vertex_sequence_array_cache.size());
MCUT_ASSERT(elem_offset <= (uint32_t)cc_uptr->seam_vertex_sequence_array_cache.size());
}
} break;
case MC_CONNECTED_COMPONENT_DATA_VERTEX_MAP: {
SCOPED_TIMER("MC_CONNECTED_COMPONENT_DATA_VERTEX_MAP");

const uint32_t vertex_map_size = cc_uptr->kernel_hmesh_data->data_maps.vertex_map.size();
const uint32_t vertex_map_size = (uint32_t)cc_uptr->kernel_hmesh_data->data_maps.vertex_map.size();

if (vertex_map_size == 0) {
throw std::invalid_argument("vertex map not available"); // user probably forgot to set the dispatch flag
Expand All @@ -3059,7 +3059,7 @@ void get_connected_component_data_impl_detail(
throw std::invalid_argument("invalid number of bytes");
}

const uint32_t elems_to_copy = (bytes / sizeof(uint32_t));
const uint32_t elems_to_copy = (uint32_t)(bytes / sizeof(uint32_t));

MCUT_ASSERT(elems_to_copy <= vertex_map_size);

Expand Down Expand Up @@ -3188,7 +3188,7 @@ void get_connected_component_data_impl_detail(
case MC_CONNECTED_COMPONENT_DATA_FACE_MAP: {
SCOPED_TIMER("MC_CONNECTED_COMPONENT_DATA_FACE_MAP");

const uint32_t face_map_size = cc_uptr->kernel_hmesh_data->data_maps.face_map.size();
const uint32_t face_map_size = (uint32_t)cc_uptr->kernel_hmesh_data->data_maps.face_map.size();

if (face_map_size == 0) {
throw std::invalid_argument("face map not available"); // user probably forgot to set the dispatch flag
Expand All @@ -3207,7 +3207,7 @@ void get_connected_component_data_impl_detail(
throw std::invalid_argument("invalid number of bytes");
}

const uint32_t elems_to_copy = (bytes / sizeof(uint32_t));
const uint32_t elems_to_copy = (uint32_t)(bytes / sizeof(uint32_t));

uint32_t* casted_ptr = reinterpret_cast<uint32_t*>(pMem);

Expand Down Expand Up @@ -3268,7 +3268,7 @@ void get_connected_component_data_impl_detail(
// internal halfedge data structure from the current connected component
const std::shared_ptr<hmesh_t> cc = cc_uptr->kernel_hmesh_data->mesh;

const uint32_t nontri_face_map_size = cc_uptr->kernel_hmesh_data->data_maps.face_map.size();
const uint32_t nontri_face_map_size = (uint32_t)cc_uptr->kernel_hmesh_data->data_maps.face_map.size();

// user has set the dispatch flag to allow us to save the face maps.
const bool user_requested_cdt_face_maps = (nontri_face_map_size != 0);
Expand All @@ -3277,9 +3277,9 @@ void get_connected_component_data_impl_detail(
{
MCUT_ASSERT(cc_uptr->cdt_index_cache.empty());

const uint32_t cc_face_count = cc->number_of_faces();
const uint32_t cc_face_count = (uint32_t)cc->number_of_faces();
if (user_requested_cdt_face_maps) {
cc_uptr->cdt_face_map_cache.reserve(cc_face_count * 1.2);
cc_uptr->cdt_face_map_cache.reserve((uint32_t)(cc_face_count * 1.2));
}

#if defined(MCUT_WITH_COMPUTE_HELPER_THREADPOOL)
Expand All @@ -3302,7 +3302,7 @@ void get_connected_component_data_impl_detail(
const uint32_t min_per_thread = 1 << 10;
{
uint32_t max_threads = 0;
const uint32_t available_threads = context_ptr->get_shared_compute_threadpool().get_num_threads() + 1; // workers and master (+1)
const uint32_t available_threads = (uint32_t)(context_ptr->get_shared_compute_threadpool().get_num_threads() + 1); // workers and master (+1)
uint32_t block_size_unused = 0;
const uint32_t length = cc_face_count;

Expand All @@ -3325,7 +3325,7 @@ void get_connected_component_data_impl_detail(
const uint32_t num_elems_to_process = (uint32_t)std::distance(block_start_, block_end_);
cdt_index_cache_local.reserve(num_elems_to_process * 4);
std::vector<uint32_t> cdt_face_map_cache_local;
cdt_face_map_cache_local.reserve(num_elems_to_process * 1.2);
cdt_face_map_cache_local.reserve((uint32_t)(num_elems_to_process * 1.2));

std::vector<vertex_descriptor_t> cc_face_vertices;
std::vector<uint32_t> cc_face_triangulation;
Expand Down Expand Up @@ -3388,7 +3388,7 @@ void get_connected_component_data_impl_detail(
}

// local num triangulation indices computed by thread
const uint32_t cdt_index_cache_local_len = cdt_index_cache_local.size();
const uint32_t cdt_index_cache_local_len = (uint32_t)cdt_index_cache_local.size();

const uint32_t write_offset = cdt_index_cache_offset.fetch_add(cdt_index_cache_local_len);

Expand Down Expand Up @@ -3574,7 +3574,7 @@ void get_connected_component_data_impl_detail(
case MC_CONNECTED_COMPONENT_DATA_FACE_TRIANGULATION_MAP: {
SCOPED_TIMER("MC_CONNECTED_COMPONENT_DATA_FACE_TRIANGULATION_MAP");
// The default/standard non-tri face map. If this is defined then the tri-face map must also be defined
const uint32_t face_map_size = cc_uptr->kernel_hmesh_data->data_maps.face_map.size();
const uint32_t face_map_size = (uint32_t)cc_uptr->kernel_hmesh_data->data_maps.face_map.size();

if (face_map_size == 0) {
throw std::invalid_argument("face map not available"); // user probably forgot to set the dispatch flag
Expand Down Expand Up @@ -3608,7 +3608,7 @@ void get_connected_component_data_impl_detail(
MCUT_ASSERT(cc_uptr->cdt_face_map_cache_initialized == true);
}

const uint32_t triangulated_face_map_size = cc_uptr->cdt_face_map_cache.size();
const uint32_t triangulated_face_map_size = (uint32_t)cc_uptr->cdt_face_map_cache.size();

MCUT_ASSERT(triangulated_face_map_size >= face_map_size);

Expand Down
2 changes: 1 addition & 1 deletion source/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6947,7 +6947,7 @@ void dispatch(output_t& output, const input_t& input)

// store's the (unsealed) connected components (fragments of the source-mesh)
hmesh_t m1;
m1.reserve_for_additional_elements(m0.number_of_vertices() + m0.number_of_vertices() * 0.25);
m1.reserve_for_additional_elements(m0.number_of_vertices() + (uint32_t)(m0.number_of_vertices() * 0.25));
// copy vertices from m0 t0 m1 (and save mapping to avoid assumptions).
// This map DOES NOT include patch intersection points because they are new
// i.e. we keep only the points represent original vertices in the source-mesh
Expand Down
2 changes: 1 addition & 1 deletion source/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
// https://answers.unity.com/questions/1522620/converting-a-3d-polygon-into-a-2d-polygon.html
void project_to_2d(std::vector<vec2>& out, const std::vector<vec3>& polygon_vertices, const vec3& polygon_normal)
{
const uint32_t N = polygon_vertices.size();
const uint32_t N = (uint32_t)polygon_vertices.size();
out.resize(N);

const vec3 normal = normalize(polygon_normal);
Expand Down

0 comments on commit 56117bf

Please sign in to comment.