Remove extraneous ::narrow<int>() calls

GSL’s gsl::span didn’t use the correct type for its index_type, which is
why they were needed.
This commit is contained in:
Emmanuel Gil Peyrot 2019-11-09 16:51:53 +01:00
parent 72cdf0b04c
commit f76720ceb0
9 changed files with 13 additions and 13 deletions

View File

@ -44,13 +44,13 @@ namespace
template <typename T>
gsl::span<T> as_span_workaround(gsl::span<std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
template <typename T>
gsl::span<T> as_const_span(gsl::span<const std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
}

View File

@ -30,13 +30,13 @@ namespace
template <typename T>
gsl::span<T> as_span_workaround(gsl::span<std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
template <typename T>
gsl::span<T> as_const_span(gsl::span<const std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
// TODO: Make this function part of GSL
@ -1042,4 +1042,4 @@ std::pair<u32, bool> get_compatible_gcm_format(rsx::surface_depth_format format)
default:
ASSUME(0);
}
}
}

View File

@ -14,7 +14,7 @@ namespace
template <typename T>
gsl::span<T> as_const_span(gsl::span<const std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
}

View File

@ -2405,7 +2405,7 @@ namespace rsx
subres.height_in_block = subres.height_in_texel = image_height;
subres.pitch_in_block = full_width;
subres.depth = 1;
subres.data = { vm::_ptr<const std::byte>(image_base), src.pitch * image_height };
subres.data = { vm::_ptr<const std::byte>(image_base), static_cast<gsl::span<const std::byte>::index_type>(src.pitch * image_height) };
subresource_layout.push_back(subres);
vram_texture = upload_image_from_cpu(cmd, rsx_range, image_width, image_height, 1, 1, src.pitch, gcm_format, texture_upload_context::blit_engine_src,
@ -2537,7 +2537,7 @@ namespace rsx
subres.height_in_block = subres.height_in_texel = dst_dimensions.height;
subres.pitch_in_block = pitch_in_block;
subres.depth = 1;
subres.data = { vm::get_super_ptr<const std::byte>(dst.rsx_address), dst.pitch * dst_dimensions.height };
subres.data = { vm::get_super_ptr<const std::byte>(dst.rsx_address), static_cast<gsl::span<const std::byte>::index_type>(dst.pitch * dst_dimensions.height) };
subresource_layout.push_back(subres);
cached_dest = upload_image_from_cpu(cmd, rsx_range, dst_dimensions.width, dst_dimensions.height, 1, 1, dst.pitch,

View File

@ -1372,7 +1372,7 @@ void GLGSRender::load_program_env()
auto mapping = m_fragment_constants_buffer->alloc_from_heap(fragment_constants_size, m_uniform_buffer_offset_align);
auto buf = static_cast<u8*>(mapping.first);
m_prog_buffer.fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), gsl::narrow<int>(fragment_constants_size) },
m_prog_buffer.fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), fragment_constants_size },
current_fragment_program, gl::get_driver_caps().vendor_NVIDIA);
m_fragment_constants_buffer->bind_range(GL_FRAGMENT_CONSTANT_BUFFERS_BIND_SLOT, mapping.second, fragment_constants_size);

View File

@ -2735,7 +2735,7 @@ void VKGSRender::load_program_env()
auto mem = m_fragment_constants_ring_info.alloc<256>(fragment_constants_size);
auto buf = m_fragment_constants_ring_info.map(mem, fragment_constants_size);
m_prog_buffer->fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), ::narrow<int>(fragment_constants_size) },
m_prog_buffer->fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), fragment_constants_size },
current_fragment_program, vk::sanitize_fp_values());
m_fragment_constants_ring_info.unmap();

View File

@ -245,7 +245,7 @@ namespace vk
subres.height_in_block = subres.height_in_texel = surface_height * samples_y;
subres.pitch_in_block = rsx_pitch / get_bpp();
subres.depth = 1;
subres.data = { (const std::byte*)vm::get_super_ptr(base_addr), s32(rsx_pitch * surface_height * samples_y) };
subres.data = { (const std::byte*)vm::get_super_ptr(base_addr), static_cast<gsl::span<const std::byte>::index_type>(rsx_pitch * surface_height * samples_y) };
if (LIKELY(g_cfg.video.resolution_scale_percent == 100 && samples() == 1))
{

View File

@ -722,7 +722,7 @@ namespace vk
check_caps = false;
}
gsl::span<std::byte> mapped{ (std::byte*)mapped_buffer, ::narrow<int>(image_linear_size) };
gsl::span<std::byte> mapped{ (std::byte*)mapped_buffer, image_linear_size };
opt = upload_texture_subresource(mapped, layout, format, is_swizzled, caps);
upload_heap.unmap();

View File

@ -15,7 +15,7 @@ namespace
template <typename T>
gsl::span<T> as_const_span(gsl::span<const std::byte> unformated_span)
{
return{ (T*)unformated_span.data(), ::narrow<int>(unformated_span.size_bytes() / sizeof(T)) };
return{ (T*)unformated_span.data(), unformated_span.size_bytes() / sizeof(T) };
}
}