Merge pull request #13181 from tygyh/Replace-'reinterpret_cast'

Replace 'reinterpret_cast' with 'static_cast'
This commit is contained in:
JosJuice
2025-03-15 15:31:38 +01:00
committed by GitHub
26 changed files with 31 additions and 36 deletions

View File

@ -79,7 +79,7 @@ std::vector<BBoxType> D3DBoundingBox::Read(u32 index, u32 length)
HRESULT hr = D3D::context->Map(m_staging_buffer.Get(), 0, D3D11_MAP_READ, 0, &map);
if (SUCCEEDED(hr))
{
std::memcpy(values.data(), reinterpret_cast<const u8*>(map.pData) + sizeof(BBoxType) * index,
std::memcpy(values.data(), static_cast<const u8*>(map.pData) + sizeof(BBoxType) * index,
sizeof(BBoxType) * length);
D3D::context->Unmap(m_staging_buffer.Get(), 0);

View File

@ -244,7 +244,7 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
*out_base_index = (cursor + vertexBufferSize) / sizeof(u16);
D3D::context->Map(m_buffers[m_current_buffer].Get(), 0, MapType, 0, &map);
u8* mappedData = reinterpret_cast<u8*>(map.pData);
u8* mappedData = static_cast<u8*>(map.pData);
if (vertexBufferSize > 0)
std::memcpy(mappedData + cursor, m_base_buffer_pointer, vertexBufferSize);
if (indexBufferSize > 0)

View File

@ -327,7 +327,7 @@ bool DXStagingTexture::Map()
if (FAILED(hr))
return false;
m_map_pointer = reinterpret_cast<char*>(sr.pData);
m_map_pointer = static_cast<char*>(sr.pData);
m_map_stride = sr.RowPitch;
return true;
}

View File

@ -47,7 +47,7 @@ std::vector<BBoxType> D3D12BoundingBox::Read(u32 index, u32 length)
return values;
// Copy out the values we want
std::memcpy(values.data(), reinterpret_cast<const u8*>(mapped_pointer) + sizeof(BBoxType) * index,
std::memcpy(values.data(), static_cast<const u8*>(mapped_pointer) + sizeof(BBoxType) * index,
sizeof(BBoxType) * length);
static constexpr D3D12_RANGE write_range = {0, 0};

View File

@ -305,7 +305,7 @@ void DXTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
{
const u8* src_ptr = buffer;
const u32 copy_size = std::min(source_stride, upload_stride);
u8* dst_ptr = reinterpret_cast<u8*>(upload_buffer_ptr);
u8* dst_ptr = static_cast<u8*>(upload_buffer_ptr);
for (u32 i = 0; i < num_rows; i++)
{
std::memcpy(dst_ptr, src_ptr, copy_size);

View File

@ -55,7 +55,7 @@ std::vector<BBoxType> OGLBoundingBox::Read(u32 index, u32 length)
GL_MAP_READ_BIT);
if (ptr)
{
std::memcpy(values.data(), reinterpret_cast<const u8*>(ptr) + sizeof(BBoxType) * index,
std::memcpy(values.data(), static_cast<const u8*>(ptr) + sizeof(BBoxType) * index,
sizeof(BBoxType) * length);
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);

View File

@ -462,7 +462,7 @@ std::unique_ptr<OGLStagingTexture> OGLStagingTexture::Create(StagingTextureType
}
glBufferStorage(target, buffer_size, nullptr, buffer_flags);
buffer_ptr = reinterpret_cast<char*>(glMapBufferRange(target, 0, buffer_size, map_flags));
buffer_ptr = static_cast<char*>(glMapBufferRange(target, 0, buffer_size, map_flags));
ASSERT(buffer_ptr != nullptr);
}
else
@ -639,7 +639,7 @@ bool OGLStagingTexture::Map()
else
flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
glBindBuffer(m_target, m_buffer_name);
m_map_pointer = reinterpret_cast<char*>(glMapBufferRange(m_target, 0, m_buffer_size, flags));
m_map_pointer = static_cast<char*>(glMapBufferRange(m_target, 0, m_buffer_size, flags));
glBindBuffer(m_target, 0);
return m_map_pointer != nullptr;
}

View File

@ -180,7 +180,7 @@ bool StagingBuffer::AllocateBuffer(STAGING_BUFFER_TYPE type, VkDeviceSize size,
}
}
*out_map_ptr = reinterpret_cast<char*>(alloc_info.pMappedData);
*out_map_ptr = static_cast<char*>(alloc_info.pMappedData);
if (res != VK_SUCCESS)
{

View File

@ -81,7 +81,7 @@ bool StreamBuffer::AllocateBuffer()
// Replace with the new buffer
m_buffer = buffer;
m_alloc = alloc;
m_host_pointer = reinterpret_cast<u8*>(alloc_info.pMappedData);
m_host_pointer = static_cast<u8*>(alloc_info.pMappedData);
m_current_offset = 0;
m_current_gpu_position = 0;
m_tracked_fences.clear();

View File

@ -47,7 +47,7 @@ VkSurfaceKHR SwapChain::CreateVulkanSurface(VkInstance instance, const WindowSys
nullptr, // const void* pNext
0, // VkWin32SurfaceCreateFlagsKHR flags
nullptr, // HINSTANCE hinstance
reinterpret_cast<HWND>(wsi.render_surface) // HWND hwnd
static_cast<HWND>(wsi.render_surface) // HWND hwnd
};
VkSurfaceKHR surface;