(D3D8) More buildfixes

This commit is contained in:
libretroadmin 2022-05-15 07:25:12 +02:00
parent 77fd75dd06
commit c2ae445a85
2 changed files with 53 additions and 49 deletions

View File

@ -1588,6 +1588,10 @@ static void d3d8_set_menu_texture_frame(void *data,
{
D3DLOCKED_RECT d3dlr;
d3d8_video_t *d3d = (d3d8_video_t*)data;
if (!d3d || !d3d->menu)
return;
if ( !d3d->menu->tex ||
d3d->menu->tex_w != width ||
d3d->menu->tex_h != height)
@ -1614,51 +1618,49 @@ static void d3d8_set_menu_texture_frame(void *data,
d3d->menu->alpha_mod = alpha;
if (IDirect3DTexture8_LockRect(d3d->menu->tex,
0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK) == D3D_OK)
{
unsigned h, w;
if (rgb32)
LPDIRECT3DTEXTURE8 tex = d3d->menu->tex;
if (IDirect3DTexture8_LockRect(tex,
0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK) == D3D_OK)
{
uint8_t *dst = (uint8_t*)d3dlr.pBits;
const uint32_t *src = (const uint32_t*)frame;
unsigned h, w;
for (h = 0; h < height; h++, dst += d3dlr.Pitch, src += width)
if (rgb32)
{
memcpy(dst, src, width * sizeof(uint32_t));
memset(dst + width * sizeof(uint32_t), 0,
d3dlr.Pitch - width * sizeof(uint32_t));
}
}
else
{
uint32_t *dst = (uint32_t*)d3dlr.pBits;
const uint16_t *src = (const uint16_t*)frame;
uint8_t *dst = (uint8_t*)d3dlr.pBits;
const uint32_t *src = (const uint32_t*)frame;
for (h = 0; h < height; h++, dst += d3dlr.Pitch >> 2, src += width)
{
for (w = 0; w < width; w++)
for (h = 0; h < height; h++, dst += d3dlr.Pitch, src += width)
{
uint16_t c = src[w];
uint32_t r = (c >> 12) & 0xf;
uint32_t g = (c >> 8) & 0xf;
uint32_t b = (c >> 4) & 0xf;
uint32_t a = (c >> 0) & 0xf;
r = ((r << 4) | r) << 16;
g = ((g << 4) | g) << 8;
b = ((b << 4) | b) << 0;
a = ((a << 4) | a) << 24;
dst[w] = r | g | b | a;
memcpy(dst, src, width * sizeof(uint32_t));
memset(dst + width * sizeof(uint32_t), 0,
d3dlr.Pitch - width * sizeof(uint32_t));
}
}
}
else
{
uint32_t *dst = (uint32_t*)d3dlr.pBits;
const uint16_t *src = (const uint16_t*)frame;
if (d3d->menu)
{
LPDIRECT3DTEXTURE8 tex = d3d->menu->tex;
if (tex)
IDirect3DTexture8_UnlockRect(tex, 0);
for (h = 0; h < height; h++, dst += d3dlr.Pitch >> 2, src += width)
{
for (w = 0; w < width; w++)
{
uint16_t c = src[w];
uint32_t r = (c >> 12) & 0xf;
uint32_t g = (c >> 8) & 0xf;
uint32_t b = (c >> 4) & 0xf;
uint32_t a = (c >> 0) & 0xf;
r = ((r << 4) | r) << 16;
g = ((g << 4) | g) << 8;
b = ((b << 4) | b) << 0;
a = ((a << 4) | a) << 24;
dst[w] = r | g | b | a;
}
}
}
IDirect3DTexture8_UnlockRect(tex, 0);
}
}
}

View File

@ -114,6 +114,7 @@ static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
};
unsigned i;
math_matrix_4x4 mop, m1, m2;
LPDIRECT3DVERTEXBUFFER8 vbo;
LPDIRECT3DDEVICE8 dev;
D3DPRIMITIVETYPE type;
unsigned start = 0;
@ -129,9 +130,9 @@ static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
if ((d3d->menu_display.offset + draw->coords->vertices )
> (unsigned)d3d->menu_display.size)
return;
vbo = (LPDIRECT3DVERTEXBUFFER8)d3d->menu_display.buffer;
dev = d3d->dev;
pv = (Vertex*)
d3d8_vertex_buffer_lock(d3d->menu_display.buffer);
pv = (Vertex*)d3d8_vertex_buffer_lock(vbo);
if (!pv)
return;
@ -161,16 +162,17 @@ static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
pv[i].u = *tex_coord++;
pv[i].v = *tex_coord++;
if ((void*)draw->texture)
{
D3DSURFACE_DESC desc;
if (SUCCEEDED(IDirect3DTexture8_GetLevelDesc(
(void*)draw->texture, 0, (D3DSURFACE_DESC*)&desc)))
{
pv[i].u *= desc.Width;
pv[i].v *= desc.Height;
}
}
if ((void*)draw->texture)
{
D3DSURFACE_DESC desc;
LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)draw->texture;
if (SUCCEEDED(IDirect3DTexture8_GetLevelDesc(tex,
0, (D3DSURFACE_DESC*)&desc)))
{
pv[i].u *= desc.Width;
pv[i].v *= desc.Height;
}
}
pv[i].color =
D3DCOLOR_ARGB(
@ -180,7 +182,7 @@ static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
colors[2] /* B */
);
}
IDirect3DVertexBuffer8_Unlock(d3d->menu_display.buffer);
IDirect3DVertexBuffer8_Unlock(vbo);
if (!draw->matrix_data)
draw->matrix_data = &default_mvp;