(D3D11) Cleanups - go through less inlined functions

This commit is contained in:
twinaphex 2022-04-23 11:36:10 +02:00
parent 1887aee7c4
commit 0888297f31
4 changed files with 60 additions and 70 deletions

View File

@ -381,14 +381,7 @@ static INLINE void D3D11SetRenderTargetsAndUnorderedAccessViews(
device_context, num_rtvs, render_target_views, depth_stencil_view, uavstart_slot, num_uavs,
unordered_access_views, uavinitial_counts);
}
static INLINE void D3D11SetBlendState(
D3D11DeviceContext device_context,
D3D11BlendState blend_state,
FLOAT blend_factor[4],
UINT sample_mask)
{
device_context->lpVtbl->OMSetBlendState(device_context, blend_state, blend_factor, sample_mask);
}
static INLINE void D3D11SetDepthStencilState(
D3D11DeviceContext device_context,
D3D11DepthStencilState depth_stencil_state,
@ -441,17 +434,6 @@ static INLINE void D3D11DispatchIndirect(
device_context->lpVtbl->DispatchIndirect(
device_context, buffer_for_args, aligned_byte_offset_for_args);
}
static INLINE void
D3D11SetRasterizerState(D3D11DeviceContext device_context, D3D11RasterizerState rasterizer_state)
{
device_context->lpVtbl->RSSetState(device_context, rasterizer_state);
}
static INLINE void
D3D11SetScissorRects(D3D11DeviceContext device_context, UINT num_rects, D3D11_RECT* rects)
{
device_context->lpVtbl->RSSetScissorRects(device_context, num_rects, rects);
}
static INLINE void D3D11CopySubresourceRegion(
D3D11DeviceContext device_context,

View File

@ -279,7 +279,8 @@ static void d3d11_render_overlay(void *data)
else
d3d11->context->lpVtbl->RSSetViewports(d3d11->context, 1, &d3d11->frame.viewport);
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
{
UINT stride = sizeof(d3d11_sprite_t);
UINT offset = 0;
@ -1981,9 +1982,10 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
context, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture[0]);
}
D3D11SetRasterizerState(context, d3d11->scissor_disabled);
D3D11SetBlendState(context, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
context->lpVtbl->RSSetState(context, d3d11->scissor_disabled);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_disable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
context->lpVtbl->IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
{
UINT stride = sizeof(d3d11_vertex_t);
UINT offset = 0;
@ -2059,7 +2061,7 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
{
D3D11RenderTargetView null_rt = NULL;
D3D11SetRenderTargets(context, 1, &null_rt, NULL);
context->lpVtbl->OMSetRenderTargets(context, 1, &null_rt, NULL);
}
{
@ -2086,7 +2088,8 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
break;
}
D3D11SetRenderTargets(context, 1, &d3d11->pass[i].rt.rt_view, NULL);
context->lpVtbl->OMSetRenderTargets(context, 1,
&d3d11->pass[i].rt.rt_view, NULL);
context->lpVtbl->RSSetViewports(context, 1, &d3d11->pass[i].viewport);
D3D11Draw(context, 4, 0);
@ -2098,14 +2101,16 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
#ifdef HAVE_DXGI_HDR
if(d3d11->hdr.enable && use_back_buffer)
{
D3D11SetRenderTargets(context, 1, &d3d11->back_buffer.rt_view, NULL);
D3D11ClearRenderTargetView(context, d3d11->back_buffer.rt_view, d3d11->clearcolor);
context->lpVtbl->OMSetRenderTargets(context, 1,
&d3d11->back_buffer.rt_view, NULL);
context->lpVtbl->ClearRenderTargetView(context,
d3d11->back_buffer.rt_view, d3d11->clearcolor);
}
else
#endif
{
D3D11SetRenderTargets(context, 1, &rtv, NULL);
D3D11ClearRenderTargetView(context, rtv, d3d11->clearcolor);
context->lpVtbl->OMSetRenderTargets(context, 1, &rtv, NULL);
context->lpVtbl->ClearRenderTargetView(context, rtv, d3d11->clearcolor);
}
context->lpVtbl->RSSetViewports(context, 1, &d3d11->frame.viewport);
@ -2127,9 +2132,10 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
}
D3D11Draw(context, 4, 0);
D3D11SetRasterizerState(context, d3d11->scissor_enabled);
D3D11SetScissorRects(d3d11->context, 1, &d3d11->scissor);
D3D11SetBlendState(context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
context->lpVtbl->RSSetState(context, d3d11->scissor_enabled);
d3d11->context->lpVtbl->RSSetScissorRects(d3d11->context, 1, &d3d11->scissor);
context->lpVtbl->OMSetBlendState(context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
#ifdef HAVE_MENU
if (d3d11->menu.enabled && d3d11->menu.texture.handle)
@ -2170,7 +2176,8 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
context->lpVtbl->PSSetShader(context, shader->ps, NULL, 0);
context->lpVtbl->GSSetShader(context, shader->gs, NULL, 0);
}
D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
context->lpVtbl->IASetPrimitiveTopology(context,
D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
D3D11SetVShaderConstantBuffers(context, 0, 1, &d3d11->ubo);
context->lpVtbl->PSSetConstantBuffers(
context, 0, 1, &d3d11->ubo);
@ -2212,7 +2219,8 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
if (osd_params)
{
context->lpVtbl->RSSetViewports(context, 1, &d3d11->viewport);
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
{
UINT stride = sizeof(d3d11_sprite_t);
UINT offset = 0;
@ -2243,7 +2251,8 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
UINT stride = sizeof(d3d11_sprite_t);
UINT offset = 0;
context->lpVtbl->RSSetViewports(context, 1, &d3d11->viewport);
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
context->lpVtbl->IASetVertexBuffers(
context, 0, 1, &d3d11->sprites.vbo, &stride, &offset);
font_driver_render_msg(d3d11, msg, NULL, NULL);
@ -2259,12 +2268,10 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
if(d3d11->hdr.enable && use_back_buffer)
{
ID3D11ShaderResourceView* nullSRV[1] = {NULL};
D3D11SetRenderTargets(context, 1, &rtv, NULL);
D3D11ClearRenderTargetView(context, rtv,
d3d11->clearcolor);
context->lpVtbl->OMSetRenderTargets(context, 1, &rtv, NULL);
context->lpVtbl->ClearRenderTargetView(context, rtv, d3d11->clearcolor);
context->lpVtbl->RSSetViewports(context, 1, &d3d11->viewport);
D3D11SetScissorRects(context, 1,
&d3d11->scissor);
context->lpVtbl->RSSetScissorRects(context, 1, &d3d11->scissor);
{
d3d11_shader_t *shader = &d3d11->shaders[VIDEO_SHADER_STOCK_HDR];
@ -2289,18 +2296,20 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
context, 0, 1, &d3d11->frame.vbo, &stride, &offset);
}
D3D11SetRasterizerState(context, d3d11->scissor_disabled);
D3D11SetBlendState(context, d3d11->blend_disable, NULL,
D3D11_DEFAULT_SAMPLE_MASK);
D3D11SetPrimitiveTopology(context,
D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
context->lpVtbl->RSSetState(context, d3d11->scissor_disabled);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_disable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
context->lpVtbl->IASetPrimitiveTopology(context,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
D3D11Draw(context, 4, 0);
D3D11SetPShaderResources(context, 0, 1, nullSRV);
D3D11SetRasterizerState(context, d3d11->scissor_enabled);
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
D3D11SetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
context->lpVtbl->RSSetState(context, d3d11->scissor_enabled);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
context->lpVtbl->IASetPrimitiveTopology(context,
D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
}
#endif

View File

@ -30,15 +30,13 @@
static void gfx_display_d3d11_blend_begin(void *data)
{
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
D3D11SetBlendState(d3d11->context,
d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
}
static void gfx_display_d3d11_blend_end(void *data)
{
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
D3D11SetBlendState(d3d11->context,
d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
}
static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
@ -67,7 +65,7 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
}
D3D11Draw(d3d11->context, draw->coords->vertices, 0);
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
{
d3d11_shader_t *shader = &d3d11->sprites.shader;
d3d11->context->lpVtbl->IASetInputLayout(d3d11->context, shader->layout);
@ -82,7 +80,7 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
d3d11->context, 0, 1,
&d3d11->sprites.vbo, &stride, &offset);
}
D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
d3d11->context->lpVtbl->IASetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
return;
}
@ -106,11 +104,11 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
if (vertex_count == 1)
{
sprite->pos.x = draw->x / (float)d3d11->viewport.Width;
sprite->pos.y =
sprite->pos.x = draw->x / (float)d3d11->viewport.Width;
sprite->pos.y =
(d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height;
sprite->pos.w = draw->width / (float)d3d11->viewport.Width;
sprite->pos.h = draw->height / (float)d3d11->viewport.Height;
sprite->pos.w = draw->width / (float)d3d11->viewport.Width;
sprite->pos.h = draw->height / (float)d3d11->viewport.Height;
sprite->coords.u = 0.0f;
sprite->coords.v = 0.0f;
@ -122,18 +120,18 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
else
sprite->params.scaling = 1.0f;
sprite->params.rotation = draw->rotation;
sprite->params.rotation = draw->rotation;
sprite->colors[3] = DXGI_COLOR_RGBA(
sprite->colors[3] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1],
0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]);
sprite->colors[2] = DXGI_COLOR_RGBA(
sprite->colors[2] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[4], 0xFF * draw->coords->color[5],
0xFF * draw->coords->color[6], 0xFF * draw->coords->color[7]);
sprite->colors[1] = DXGI_COLOR_RGBA(
sprite->colors[1] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[8], 0xFF * draw->coords->color[9],
0xFF * draw->coords->color[10], 0xFF * draw->coords->color[11]);
sprite->colors[0] = DXGI_COLOR_RGBA(
sprite->colors[0] = DXGI_COLOR_RGBA(
0xFF * draw->coords->color[12], 0xFF * draw->coords->color[13],
0xFF * draw->coords->color[14], 0xFF * draw->coords->color[15]);
}
@ -166,7 +164,7 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
d3d11->context->lpVtbl->PSSetShader(d3d11->context, shader->ps, NULL, 0);
d3d11->context->lpVtbl->GSSetShader(d3d11->context, shader->gs, NULL, 0);
}
D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
d3d11->context->lpVtbl->IASetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
D3D11UnmapBuffer(d3d11->context, d3d11->sprites.vbo, 0);
@ -189,7 +187,7 @@ static void gfx_display_d3d11_draw(gfx_display_ctx_draw_t *draw,
d3d11->context->lpVtbl->VSSetShader(d3d11->context, shader->vs, NULL, 0);
d3d11->context->lpVtbl->PSSetShader(d3d11->context, shader->ps, NULL, 0);
d3d11->context->lpVtbl->GSSetShader(d3d11->context, shader->gs, NULL, 0);
D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
d3d11->context->lpVtbl->IASetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
}
}
@ -229,7 +227,7 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw,
&d3d11->menu_pipeline_vbo, &stride, &offset);
}
draw->coords->vertices = ca->coords.vertices;
D3D11SetBlendState(d3d11->context, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK);
break;
}
@ -250,7 +248,7 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw,
return;
}
D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
d3d11->context->lpVtbl->IASetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
d3d11->ubo_values.time += 0.01f;
@ -295,7 +293,7 @@ void gfx_display_d3d11_scissor_begin(void *data,
rect.right = width + x;
rect.bottom = height + y;
D3D11SetScissorRects(d3d11->context, 1, &rect);
d3d11->context->lpVtbl->RSSetScissorRects(d3d11->context, 1, &rect);
}
void gfx_display_d3d11_scissor_end(void *data,
@ -313,7 +311,7 @@ void gfx_display_d3d11_scissor_end(void *data,
rect.right = video_width;
rect.bottom = video_height;
D3D11SetScissorRects(d3d11->context, 1, &rect);
d3d11->context->lpVtbl->RSSetScissorRects(d3d11->context, 1, &rect);
}
gfx_display_ctx_driver_t gfx_display_ctx_d3d11 = {

View File

@ -219,7 +219,8 @@ static void d3d11_font_render_line(
d3d11->context, 0, 1,
(D3D11SamplerState*)&texture->sampler);
}
D3D11SetBlendState(d3d11->context, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_enable,
NULL, D3D11_DEFAULT_SAMPLE_MASK);
d3d11->context->lpVtbl->PSSetShader(d3d11->context, d3d11->sprites.shader_font.ps, NULL, 0);
D3D11Draw(d3d11->context, count, d3d11->sprites.offset);