mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-28 20:09:38 +08:00
PS2, VITA: Fix void pointer arithmetic warnings (#14995)
This commit is contained in:
@@ -450,7 +450,7 @@ static bool PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_Rende
|
|||||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
|
|
||||||
if (cmd->data.draw.texture) {
|
if (cmd->data.draw.texture) {
|
||||||
const GSPRIMUVPOINT *verts = (GSPRIMUVPOINT *) (vertices + cmd->data.draw.first);
|
const GSPRIMUVPOINT *verts = (GSPRIMUVPOINT *) ((Uint8*)vertices + cmd->data.draw.first);
|
||||||
GSTEXTURE *ps2_tex = (GSTEXTURE *)cmd->data.draw.texture->internal;
|
GSTEXTURE *ps2_tex = (GSTEXTURE *)cmd->data.draw.texture->internal;
|
||||||
|
|
||||||
switch (cmd->data.draw.texture_scale_mode) {
|
switch (cmd->data.draw.texture_scale_mode) {
|
||||||
@@ -467,7 +467,7 @@ static bool PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_Rende
|
|||||||
gsKit_TexManager_bind(data->gsGlobal, ps2_tex);
|
gsKit_TexManager_bind(data->gsGlobal, ps2_tex);
|
||||||
gsKit_prim_list_triangle_goraud_texture_uv_3d(data->gsGlobal, ps2_tex, count, verts);
|
gsKit_prim_list_triangle_goraud_texture_uv_3d(data->gsGlobal, ps2_tex, count, verts);
|
||||||
} else {
|
} else {
|
||||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
const GSPRIMPOINT *verts = (GSPRIMPOINT *)((Uint8*)vertices + cmd->data.draw.first);
|
||||||
gsKit_prim_list_triangle_gouraud_3d(data->gsGlobal, count, verts);
|
gsKit_prim_list_triangle_gouraud_3d(data->gsGlobal, count, verts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@ static bool PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCo
|
|||||||
{
|
{
|
||||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||||
const size_t count = cmd->data.draw.count;
|
const size_t count = cmd->data.draw.count;
|
||||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
const GSPRIMPOINT *verts = (GSPRIMPOINT *)((Uint8*)vertices + cmd->data.draw.first);
|
||||||
|
|
||||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts);
|
gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts);
|
||||||
@@ -491,7 +491,7 @@ static bool PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderC
|
|||||||
{
|
{
|
||||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||||
const size_t count = cmd->data.draw.count;
|
const size_t count = cmd->data.draw.count;
|
||||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
const GSPRIMPOINT *verts = (GSPRIMPOINT *)((Uint8*)vertices + cmd->data.draw.first);
|
||||||
|
|
||||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
gsKit_prim_list_points(data->gsGlobal, count, verts);
|
gsKit_prim_list_points(data->gsGlobal, count, verts);
|
||||||
|
|||||||
@@ -349,25 +349,25 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||||
if (length == pitch && length == dpitch) {
|
if (length == pitch && length == dpitch) {
|
||||||
SDL_memcpy(dst, pixels, length * rect->h);
|
SDL_memcpy(dst, pixels, length * rect->h);
|
||||||
pixels += pitch * rect->h;
|
pixels = (const Uint8 *)pixels + pitch * rect->h;
|
||||||
} else {
|
} else {
|
||||||
for (row = 0; row < rect->h; ++row) {
|
for (row = 0; row < rect->h; ++row) {
|
||||||
SDL_memcpy(dst, pixels, length);
|
SDL_memcpy(dst, pixels, length);
|
||||||
pixels += pitch;
|
pixels = (const Uint8 *)pixels + pitch;
|
||||||
dst += dpitch;
|
dst += dpitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_HAVE_YUV
|
#ifdef SDL_HAVE_YUV
|
||||||
if (vita_texture->yuv) {
|
if (vita_texture->yuv) {
|
||||||
void *Udst;
|
Uint8 *Udst;
|
||||||
void *Vdst;
|
Uint8 *Vdst;
|
||||||
int uv_pitch = (dpitch + 1) / 2;
|
int uv_pitch = (dpitch + 1) / 2;
|
||||||
int uv_src_pitch = (pitch + 1) / 2;
|
int uv_src_pitch = (pitch + 1) / 2;
|
||||||
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
||||||
|
|
||||||
// skip Y plane
|
// skip Y plane
|
||||||
Uint8 *Dpixels = gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h);
|
Uint8 *Dpixels = (Uint8*)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h);
|
||||||
|
|
||||||
Udst = Dpixels + (UVrect.y * uv_pitch) + UVrect.x;
|
Udst = Dpixels + (UVrect.y * uv_pitch) + UVrect.x;
|
||||||
Vdst = Dpixels + (uv_pitch * ((vita_texture->h + 1) / 2)) + (UVrect.y * uv_pitch) + UVrect.x;
|
Vdst = Dpixels + (uv_pitch * ((vita_texture->h + 1) / 2)) + (UVrect.y * uv_pitch) + UVrect.x;
|
||||||
@@ -377,11 +377,11 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
// U plane
|
// U plane
|
||||||
if (length == uv_src_pitch && length == uv_pitch) {
|
if (length == uv_src_pitch && length == uv_pitch) {
|
||||||
SDL_memcpy(Udst, pixels, length * UVrect.h);
|
SDL_memcpy(Udst, pixels, length * UVrect.h);
|
||||||
pixels += uv_src_pitch * UVrect.h;
|
pixels = (const Uint8 *)pixels + uv_src_pitch * UVrect.h;
|
||||||
} else {
|
} else {
|
||||||
for (row = 0; row < UVrect.h; ++row) {
|
for (row = 0; row < UVrect.h; ++row) {
|
||||||
SDL_memcpy(Udst, pixels, length);
|
SDL_memcpy(Udst, pixels, length);
|
||||||
pixels += uv_src_pitch;
|
pixels = (const Uint8 *)pixels + uv_src_pitch;
|
||||||
Udst += uv_pitch;
|
Udst += uv_pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,19 +392,19 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
} else {
|
} else {
|
||||||
for (row = 0; row < UVrect.h; ++row) {
|
for (row = 0; row < UVrect.h; ++row) {
|
||||||
SDL_memcpy(Vdst, pixels, length);
|
SDL_memcpy(Vdst, pixels, length);
|
||||||
pixels += uv_src_pitch;
|
pixels = (const Uint8 *)pixels + uv_src_pitch;
|
||||||
Vdst += uv_pitch;
|
Vdst += uv_pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (vita_texture->nv12) {
|
} else if (vita_texture->nv12) {
|
||||||
void *UVdst;
|
Uint8 *UVdst;
|
||||||
int uv_pitch = 2 * ((dpitch + 1) / 2);
|
int uv_pitch = 2 * ((dpitch + 1) / 2);
|
||||||
int uv_src_pitch = 2 * ((pitch + 1) / 2);
|
int uv_src_pitch = 2 * ((pitch + 1) / 2);
|
||||||
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
||||||
|
|
||||||
// skip Y plane
|
// skip Y plane
|
||||||
void *Dpixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h));
|
Uint8 *Dpixels = (Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h);
|
||||||
UVdst = Dpixels + (UVrect.y * uv_pitch) + UVrect.x;
|
UVdst = Dpixels + (UVrect.y * uv_pitch) + UVrect.x;
|
||||||
|
|
||||||
length = UVrect.w * 2;
|
length = UVrect.w * 2;
|
||||||
@@ -415,7 +415,7 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
} else {
|
} else {
|
||||||
for (row = 0; row < UVrect.h; ++row) {
|
for (row = 0; row < UVrect.h; ++row) {
|
||||||
SDL_memcpy(UVdst, pixels, length);
|
SDL_memcpy(UVdst, pixels, length);
|
||||||
pixels += uv_src_pitch;
|
pixels = (const Uint8 *)pixels + uv_src_pitch;
|
||||||
UVdst += uv_pitch;
|
UVdst += uv_pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,13 +456,13 @@ static bool VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *textu
|
|||||||
|
|
||||||
// U/V planes
|
// U/V planes
|
||||||
{
|
{
|
||||||
void *Udst;
|
Uint8 *Udst;
|
||||||
void *Vdst;
|
Uint8 *Vdst;
|
||||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->internal;
|
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->internal;
|
||||||
int uv_pitch = (dpitch + 1) / 2;
|
int uv_pitch = (dpitch + 1) / 2;
|
||||||
|
|
||||||
// skip Y plane
|
// skip Y plane
|
||||||
void *pixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h));
|
Uint8 *pixels = (Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h);
|
||||||
|
|
||||||
if (texture->format == SDL_PIXELFORMAT_YV12) { // YVU
|
if (texture->format == SDL_PIXELFORMAT_YV12) { // YVU
|
||||||
Vdst = pixels + (UVrect.y * uv_pitch) + UVrect.x;
|
Vdst = pixels + (UVrect.y * uv_pitch) + UVrect.x;
|
||||||
@@ -529,12 +529,12 @@ static bool VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *textur
|
|||||||
|
|
||||||
// UV plane
|
// UV plane
|
||||||
{
|
{
|
||||||
void *UVdst;
|
Uint8 *UVdst;
|
||||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->internal;
|
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->internal;
|
||||||
int uv_pitch = 2 * ((dpitch + 1) / 2);
|
int uv_pitch = 2 * ((dpitch + 1) / 2);
|
||||||
|
|
||||||
// skip Y plane
|
// skip Y plane
|
||||||
void *pixels = (void *)((Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h));
|
Uint8 *pixels = (Uint8 *)gxm_texture_get_datap(vita_texture->tex) + (vita_texture->pitch * vita_texture->h);
|
||||||
|
|
||||||
UVdst = pixels + (UVrect.y * uv_pitch) + UVrect.x;
|
UVdst = pixels + (UVrect.y * uv_pitch) + UVrect.x;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user