mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Turn vulkan_write_quad_vbo into macro
This commit is contained in:
parent
9672d9b12f
commit
b4d26aca9c
@ -1124,10 +1124,12 @@ void vulkan_draw_quad(vk_t *vk, const struct vk_draw_quad *quad)
|
||||
6 * sizeof(struct vk_vertex), &range))
|
||||
return;
|
||||
|
||||
vulkan_write_quad_vbo((struct vk_vertex*)range.data,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
&quad->color);
|
||||
{
|
||||
struct vk_vertex *pv = (struct vk_vertex*)range.data;
|
||||
const struct vk_color *color = &quad->color;
|
||||
|
||||
VULKAN_WRITE_QUAD_VBO(pv, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, color);
|
||||
}
|
||||
|
||||
vkCmdBindVertexBuffers(vk->cmd, 0, 1,
|
||||
&range.buffer, &range.offset);
|
||||
|
@ -582,63 +582,60 @@ static INLINE unsigned vulkan_format_to_bpp(VkFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void vulkan_write_quad_vbo(struct vk_vertex *pv,
|
||||
float x, float y, float width, float height,
|
||||
float tex_x, float tex_y, float tex_width, float tex_height,
|
||||
const struct vk_color *color)
|
||||
{
|
||||
float r = color->r;
|
||||
float g = color->g;
|
||||
float b = color->b;
|
||||
float a = color->a;
|
||||
pv[0].x = x + 0.0f * width;
|
||||
pv[0].y = y + 0.0f * height;
|
||||
pv[0].tex_x = tex_x + 0.0f * tex_width;
|
||||
pv[0].tex_y = tex_y + 0.0f * tex_height;
|
||||
pv[0].color.r = r;
|
||||
pv[0].color.g = g;
|
||||
pv[0].color.b = b;
|
||||
pv[0].color.a = a;
|
||||
pv[1].x = x + 0.0f * width;
|
||||
pv[1].y = y + 1.0f * height;
|
||||
pv[1].tex_x = tex_x + 0.0f * tex_width;
|
||||
pv[1].tex_y = tex_y + 1.0f * tex_height;
|
||||
pv[1].color.r = r;
|
||||
pv[1].color.g = g;
|
||||
pv[1].color.b = b;
|
||||
pv[1].color.a = a;
|
||||
pv[2].x = x + 1.0f * width;
|
||||
pv[2].y = y + 0.0f * height;
|
||||
pv[2].tex_x = tex_x + 1.0f * tex_width;
|
||||
pv[2].tex_y = tex_y + 0.0f * tex_height;
|
||||
pv[2].color.r = r;
|
||||
pv[2].color.g = g;
|
||||
pv[2].color.b = b;
|
||||
pv[2].color.a = a;
|
||||
pv[3].x = x + 1.0f * width;
|
||||
pv[3].y = y + 1.0f * height;
|
||||
pv[3].tex_x = tex_x + 1.0f * tex_width;
|
||||
pv[3].tex_y = tex_y + 1.0f * tex_height;
|
||||
pv[3].color.r = r;
|
||||
pv[3].color.g = g;
|
||||
pv[3].color.b = b;
|
||||
pv[3].color.a = a;
|
||||
pv[4].x = x + 1.0f * width;
|
||||
pv[4].y = y + 0.0f * height;
|
||||
pv[4].tex_x = tex_x + 1.0f * tex_width;
|
||||
pv[4].tex_y = tex_y + 0.0f * tex_height;
|
||||
pv[4].color.r = r;
|
||||
pv[4].color.g = g;
|
||||
pv[4].color.b = b;
|
||||
pv[4].color.a = a;
|
||||
pv[5].x = x + 0.0f * width;
|
||||
pv[5].y = y + 1.0f * height;
|
||||
pv[5].tex_x = tex_x + 0.0f * tex_width;
|
||||
pv[5].tex_y = tex_y + 1.0f * tex_height;
|
||||
pv[5].color.r = r;
|
||||
pv[5].color.g = g;
|
||||
pv[5].color.b = b;
|
||||
pv[5].color.a = a;
|
||||
#define VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, color) \
|
||||
{ \
|
||||
float r = color->r; \
|
||||
float g = color->g; \
|
||||
float b = color->b; \
|
||||
float a = color->a; \
|
||||
pv[0].x = (_x) + 0.0f * (_width); \
|
||||
pv[0].y = (_y) + 0.0f * (_height); \
|
||||
pv[0].tex_x = (_tex_x) + 0.0f * (_tex_width); \
|
||||
pv[0].tex_y = (_tex_y) + 0.0f * (_tex_height); \
|
||||
pv[0].color.r = r; \
|
||||
pv[0].color.g = g; \
|
||||
pv[0].color.b = b; \
|
||||
pv[0].color.a = a; \
|
||||
pv[1].x = (_x) + 0.0f * (_width); \
|
||||
pv[1].y = (_y) + 1.0f * (_height); \
|
||||
pv[1].tex_x = (_tex_x) + 0.0f * (_tex_width); \
|
||||
pv[1].tex_y = (_tex_y) + 1.0f * (_tex_height); \
|
||||
pv[1].color.r = r; \
|
||||
pv[1].color.g = g; \
|
||||
pv[1].color.b = b; \
|
||||
pv[1].color.a = a; \
|
||||
pv[2].x = (_x) + 1.0f * (_width); \
|
||||
pv[2].y = (_y) + 0.0f * (_height); \
|
||||
pv[2].tex_x = (_tex_x) + 1.0f * (_tex_width); \
|
||||
pv[2].tex_y = (_tex_y) + 0.0f * (_tex_height); \
|
||||
pv[2].color.r = r; \
|
||||
pv[2].color.g = g; \
|
||||
pv[2].color.b = b; \
|
||||
pv[2].color.a = a; \
|
||||
pv[3].x = (_x) + 1.0f * (_width); \
|
||||
pv[3].y = (_y) + 1.0f * (_height); \
|
||||
pv[3].tex_x = (_tex_x) + 1.0f * (_tex_width); \
|
||||
pv[3].tex_y = (_tex_y) + 1.0f * (_tex_height); \
|
||||
pv[3].color.r = r; \
|
||||
pv[3].color.g = g; \
|
||||
pv[3].color.b = b; \
|
||||
pv[3].color.a = a; \
|
||||
pv[4].x = (_x) + 1.0f * (_width); \
|
||||
pv[4].y = (_y) + 0.0f * (_height); \
|
||||
pv[4].tex_x = (_tex_x) + 1.0f * (_tex_width); \
|
||||
pv[4].tex_y = (_tex_y) + 0.0f * (_tex_height); \
|
||||
pv[4].color.r = r; \
|
||||
pv[4].color.g = g; \
|
||||
pv[4].color.b = b; \
|
||||
pv[4].color.a = a; \
|
||||
pv[5].x = (_x) + 0.0f * (_width); \
|
||||
pv[5].y = (_y) + 1.0f * (_height); \
|
||||
pv[5].tex_x = (_tex_x) + 0.0f * (_tex_width); \
|
||||
pv[5].tex_y = (_tex_y) + 1.0f * (_tex_height); \
|
||||
pv[5].color.r = r; \
|
||||
pv[5].color.g = g; \
|
||||
pv[5].color.b = b; \
|
||||
pv[5].color.a = a; \
|
||||
}
|
||||
|
||||
struct vk_buffer vulkan_create_buffer(
|
||||
|
@ -210,16 +210,22 @@ static void vulkan_raster_font_render_line(
|
||||
width = glyph->width;
|
||||
height = glyph->height;
|
||||
|
||||
vulkan_write_quad_vbo(font->pv + font->vertices,
|
||||
(x + (off_x + delta_x) * scale) * inv_win_width,
|
||||
(y + (off_y + delta_y) * scale) * inv_win_height,
|
||||
width * scale * inv_win_width,
|
||||
height * scale * inv_win_height,
|
||||
tex_x * inv_tex_size_x,
|
||||
tex_y * inv_tex_size_y,
|
||||
width * inv_tex_size_x,
|
||||
height * inv_tex_size_y,
|
||||
&vk_color);
|
||||
{
|
||||
struct vk_vertex *pv = font->pv + font->vertices;
|
||||
float _x = (x + (off_x + delta_x) * scale)
|
||||
* inv_win_width;
|
||||
float _y = (y + (off_y + delta_y) * scale)
|
||||
* inv_win_height;
|
||||
float _width = width * scale * inv_win_width;
|
||||
float _height = height * scale * inv_win_height;
|
||||
float _tex_x = tex_x * inv_tex_size_x;
|
||||
float _tex_y = tex_y * inv_tex_size_y;
|
||||
float _tex_width = width * inv_tex_size_x;
|
||||
float _tex_height = height * inv_tex_size_y;
|
||||
const struct vk_color *color = &vk_color;
|
||||
|
||||
VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, color);
|
||||
}
|
||||
|
||||
font->vertices += 6;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user