mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
d3d11converter: Don't set unnecessary constant buffer
Skip PSSetConstantBuffers() if it's not used by pixel shader Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5492>
This commit is contained in:
parent
e290555367
commit
4e3d87edf5
1 changed files with 34 additions and 26 deletions
|
@ -250,9 +250,9 @@ struct _GstD3D11ConverterPrivate
|
|||
|
||||
gint input_texture_width;
|
||||
gint input_texture_height;
|
||||
gboolean update_src_rect;
|
||||
gboolean update_dest_rect;
|
||||
gboolean update_alpha;
|
||||
gboolean update_src_rect = FALSE;
|
||||
gboolean update_dest_rect = FALSE;
|
||||
gboolean update_alpha = FALSE;
|
||||
|
||||
PSConstBuffer const_data;
|
||||
|
||||
|
@ -750,6 +750,8 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||
}
|
||||
|
||||
/* const buffer */
|
||||
if (priv->convert_type != CONVERT_TYPE::IDENTITY ||
|
||||
GST_VIDEO_INFO_HAS_ALPHA (out_info)) {
|
||||
G_STATIC_ASSERT (sizeof (PSConstBuffer) % 16 == 0);
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
buffer_desc.ByteWidth = sizeof (PSConstBuffer);
|
||||
|
@ -762,6 +764,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||
"Couldn't create constant buffer, hr: 0x%x", (guint) hr);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* setup vertext buffer and index buffer */
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
|
@ -788,8 +791,9 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||
}
|
||||
|
||||
GstD3D11DeviceLockGuard lk (device);
|
||||
hr = context_handle->Map (const_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||
&map);
|
||||
if (const_buffer) {
|
||||
hr = context_handle->Map (const_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD,
|
||||
0, &map);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self,
|
||||
"Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
||||
|
@ -798,6 +802,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||
|
||||
memcpy (map.pData, &priv->const_data, sizeof (PSConstBuffer));
|
||||
context_handle->Unmap (const_buffer.Get (), 0);
|
||||
}
|
||||
|
||||
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||
&map);
|
||||
|
@ -2186,7 +2191,7 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->update_alpha) {
|
||||
if (priv->const_buffer && priv->update_alpha) {
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
PSConstBuffer *const_buffer;
|
||||
HRESULT hr;
|
||||
|
@ -2203,8 +2208,8 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
|||
memcpy (const_buffer, &priv->const_data, sizeof (PSConstBuffer));
|
||||
|
||||
context->Unmap (priv->const_buffer.Get (), 0);
|
||||
priv->update_alpha = FALSE;
|
||||
}
|
||||
priv->update_alpha = FALSE;
|
||||
|
||||
if (priv->clear_background) {
|
||||
for (guint i = 0; i < priv->num_output_view; i++)
|
||||
|
@ -2224,8 +2229,11 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
|||
context->PSSetSamplers (0, 2, samplers);
|
||||
context->VSSetShader (priv->vs.Get (), nullptr, 0);
|
||||
|
||||
if (priv->const_buffer) {
|
||||
ID3D11Buffer *const_buffer[] = { priv->const_buffer.Get () };
|
||||
context->PSSetConstantBuffers (0, 1, const_buffer);
|
||||
}
|
||||
|
||||
context->PSSetShaderResources (0, priv->num_input_view, srv);
|
||||
if (priv->gamma_enc_srv) {
|
||||
ID3D11ShaderResourceView *gamma_srv[] = { priv->gamma_dec_srv.Get (),
|
||||
|
|
Loading…
Reference in a new issue