(D3D11) change the sprite vertex buffer to a ring buffer to avoid data

races with the gpu.
This commit is contained in:
aliaspider 2018-01-25 01:03:54 +01:00
parent 013ecf3719
commit 45541a0d44
3 changed files with 7 additions and 3 deletions

View File

@ -522,7 +522,7 @@ static bool d3d11_gfx_frame(
D3D11SetPShaderSamplers(d3d11->ctx, 0, 1, &d3d11->sampler_linear);
D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->sprites.offset = 0;
d3d11->sprites.enabled = true;
if (d3d11->menu.enabled)

View File

@ -135,9 +135,12 @@ static void d3d11_font_render_line(
int x = roundf(pos_x * width);
int y = roundf((1.0 - pos_y) * height);
if (!d3d11->sprites.enabled || d3d11->sprites.offset + msg_len > d3d11->sprites.capacity)
if (!d3d11->sprites.enabled || msg_len > d3d11->sprites.capacity)
return;
if(d3d11->sprites.offset + msg_len > d3d11->sprites.capacity)
d3d11->sprites.offset = 0;
switch (text_align)
{
case TEXT_ALIGN_RIGHT:

View File

@ -53,7 +53,8 @@ static void menu_display_d3d11_draw(void* data)
return;
if(d3d11->sprites.offset + 1 > d3d11->sprites.capacity)
return;
d3d11->sprites.offset = 0;
D3D11_MAPPED_SUBRESOURCE mapped_vbo;
D3D11MapBuffer(d3d11->ctx, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo);