Software Backend: Remove reinterpret_cast which violates the strict aliasing rule
This commit is contained in:
parent
332af8aa49
commit
bf7db3f888
|
@ -497,8 +497,7 @@ u8* GetPixelPointer(u16 x, u16 y, bool depth)
|
||||||
return &efb[GetColorOffset(x, y)];
|
return &efb[GetColorOffset(x, y)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect,
|
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale)
|
||||||
float y_scale)
|
|
||||||
{
|
{
|
||||||
if (!xfb_in_ram)
|
if (!xfb_in_ram)
|
||||||
{
|
{
|
||||||
|
@ -555,10 +554,16 @@ void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle&
|
||||||
src_ptr += memory_stride;
|
src_ptr += memory_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply y scaling and copy to the xfb memory location
|
auto dest_rect = EFBRectangle{source_rect.left, source_rect.top, source_rect.right,
|
||||||
SW::CopyRegion(source.data(), source_rect, xfb_in_ram,
|
static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)};
|
||||||
EFBRectangle{source_rect.left, source_rect.top, source_rect.right,
|
|
||||||
static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)});
|
const std::size_t destination_size = dest_rect.GetWidth() * dest_rect.GetHeight() * 2;
|
||||||
|
static std::vector<yuv422_packed> destination;
|
||||||
|
destination.resize(dest_rect.GetWidth() * dest_rect.GetHeight());
|
||||||
|
|
||||||
|
SW::CopyRegion(source.data(), source_rect, destination.data(), dest_rect);
|
||||||
|
|
||||||
|
memcpy(xfb_in_ram, destination.data(), destination_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZCompare(u16 x, u16 y, u32 z)
|
bool ZCompare(u16 x, u16 y, u32 z)
|
||||||
|
|
|
@ -57,8 +57,7 @@ u32 GetDepth(u16 x, u16 y);
|
||||||
|
|
||||||
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
||||||
|
|
||||||
void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect,
|
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale);
|
||||||
float y_scale);
|
|
||||||
|
|
||||||
extern u32 perf_values[PQ_NUM_MEMBERS];
|
extern u32 perf_values[PQ_NUM_MEMBERS];
|
||||||
inline void IncPerfCounterQuadCount(PerfQueryType type)
|
inline void IncPerfCounterQuadCount(PerfQueryType type)
|
||||||
|
|
|
@ -44,8 +44,15 @@ void SWTexture::CopyRectangleFromTexture(const AbstractTexture* source,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CopyRegion(reinterpret_cast<const Pixel*>(software_source_texture->GetData()), srcrect,
|
std::vector<Pixel> source_pixels;
|
||||||
reinterpret_cast<Pixel*>(GetData()), dstrect);
|
source_pixels.resize(srcrect.GetHeight() * srcrect.GetWidth() * 4);
|
||||||
|
memcpy(source_pixels.data(), software_source_texture->GetData(), source_pixels.size());
|
||||||
|
|
||||||
|
std::vector<Pixel> destination_pixels;
|
||||||
|
destination_pixels.resize(dstrect.GetHeight() * dstrect.GetWidth() * 4);
|
||||||
|
|
||||||
|
CopyRegion(source_pixels.data(), srcrect, destination_pixels.data(), dstrect);
|
||||||
|
memcpy(GetData(), destination_pixels.data(), destination_pixels.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1469,8 +1469,7 @@ void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_pe
|
||||||
{
|
{
|
||||||
if (params.copy_format == EFBCopyFormat::XFB)
|
if (params.copy_format == EFBCopyFormat::XFB)
|
||||||
{
|
{
|
||||||
EfbInterface::EncodeXFB(reinterpret_cast<EfbInterface::yuv422_packed*>(dst), native_width,
|
EfbInterface::EncodeXFB(dst, native_width, src_rect, params.y_scale);
|
||||||
src_rect, params.y_scale);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue