mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
d3d11: Pass HLSL source size to compile function
The string size is known at build time Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5457>
This commit is contained in:
parent
bfdea297d2
commit
92cc5722c8
5 changed files with 35 additions and 22 deletions
|
@ -36,6 +36,7 @@ HRESULT gst_d3d11_device_get_pixel_shader (GstD3D11Device * device,
|
|||
const void * bytecode,
|
||||
gsize bytecode_size,
|
||||
const gchar * source,
|
||||
gsize source_size,
|
||||
const gchar * entry_point,
|
||||
ID3D11PixelShader ** ps);
|
||||
|
||||
|
@ -45,6 +46,7 @@ HRESULT gst_d3d11_device_get_vertex_shader (GstD3D11Device * device,
|
|||
const void * bytecode,
|
||||
gsize bytecode_size,
|
||||
const gchar * source,
|
||||
gsize source_size,
|
||||
const gchar * entry_point,
|
||||
const D3D11_INPUT_ELEMENT_DESC * input_desc,
|
||||
guint desc_len,
|
||||
|
|
|
@ -1704,7 +1704,7 @@ gst_d3d11_vertex_shader_token_new (void)
|
|||
HRESULT
|
||||
gst_d3d11_device_get_pixel_shader (GstD3D11Device * device, gint64 token,
|
||||
const void *bytecode, gsize bytecode_len, const gchar * source,
|
||||
const gchar * entry_point, ID3D11PixelShader ** ps)
|
||||
gsize source_size, const gchar * entry_point, ID3D11PixelShader ** ps)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv = device->priv;
|
||||
HRESULT hr;
|
||||
|
@ -1740,7 +1740,7 @@ gst_d3d11_device_get_pixel_shader (GstD3D11Device * device, gint64 token,
|
|||
"Creating shader \"%s\" using precompiled bytecode", entry_point);
|
||||
} else {
|
||||
hr = gst_d3d11_shader_cache_get_pixel_shader_blob (token,
|
||||
source, entry_point, &blob);
|
||||
source, source_size, entry_point, &blob);
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
return hr;
|
||||
|
||||
|
@ -1770,8 +1770,9 @@ gst_d3d11_device_get_pixel_shader (GstD3D11Device * device, gint64 token,
|
|||
HRESULT
|
||||
gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token,
|
||||
const void *bytecode, gsize bytecode_len, const gchar * source,
|
||||
const gchar * entry_point, const D3D11_INPUT_ELEMENT_DESC * input_desc,
|
||||
guint desc_len, ID3D11VertexShader ** vs, ID3D11InputLayout ** layout)
|
||||
gsize source_size, const gchar * entry_point,
|
||||
const D3D11_INPUT_ELEMENT_DESC * input_desc, guint desc_len,
|
||||
ID3D11VertexShader ** vs, ID3D11InputLayout ** layout)
|
||||
{
|
||||
GstD3D11DevicePrivate *priv = device->priv;
|
||||
HRESULT hr;
|
||||
|
@ -1810,7 +1811,7 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token,
|
|||
"Creating shader \"%s\" using precompiled bytecode", entry_point);
|
||||
} else {
|
||||
hr = gst_d3d11_shader_cache_get_vertex_shader_blob (token,
|
||||
source, entry_point, &blob);
|
||||
source, source_size, entry_point, &blob);
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
return hr;
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ static std::map <gint64, ID3DBlob *> vs_blob_;
|
|||
|
||||
HRESULT
|
||||
gst_d3d11_shader_cache_get_pixel_shader_blob (gint64 token,
|
||||
const gchar * source, const gchar * entry_point, ID3DBlob ** blob)
|
||||
const gchar * source, gsize source_size, const gchar * entry_point,
|
||||
ID3DBlob ** blob)
|
||||
{
|
||||
std::lock_guard < std::mutex > lk (cache_lock_);
|
||||
|
||||
|
@ -46,7 +47,7 @@ gst_d3d11_shader_cache_get_pixel_shader_blob (gint64 token,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT hr = gst_d3d11_compile (source, strlen (source), nullptr, nullptr,
|
||||
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, nullptr,
|
||||
nullptr, entry_point, "ps_5_0", 0, 0, blob, nullptr);
|
||||
if (FAILED (hr))
|
||||
return hr;
|
||||
|
@ -59,7 +60,8 @@ gst_d3d11_shader_cache_get_pixel_shader_blob (gint64 token,
|
|||
|
||||
HRESULT
|
||||
gst_d3d11_shader_cache_get_vertex_shader_blob (gint64 token,
|
||||
const gchar * source, const gchar * entry_point, ID3DBlob ** blob)
|
||||
const gchar * source, gsize source_size, const gchar * entry_point,
|
||||
ID3DBlob ** blob)
|
||||
{
|
||||
std::lock_guard < std::mutex > lk (cache_lock_);
|
||||
|
||||
|
@ -70,7 +72,7 @@ gst_d3d11_shader_cache_get_vertex_shader_blob (gint64 token,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT hr = gst_d3d11_compile (source, strlen (source), nullptr, nullptr,
|
||||
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, nullptr,
|
||||
nullptr, entry_point, "vs_5_0", 0, 0, blob, nullptr);
|
||||
if (FAILED (hr))
|
||||
return hr;
|
||||
|
|
|
@ -26,11 +26,13 @@ G_BEGIN_DECLS
|
|||
|
||||
HRESULT gst_d3d11_shader_cache_get_pixel_shader_blob (gint64 token,
|
||||
const gchar * source,
|
||||
gsize source_size,
|
||||
const gchar * entry_point,
|
||||
ID3DBlob ** blob);
|
||||
|
||||
HRESULT gst_d3d11_shader_cache_get_vertex_shader_blob (gint64 token,
|
||||
const gchar * source,
|
||||
gsize source_size,
|
||||
const gchar * entry_point,
|
||||
ID3DBlob ** blob);
|
||||
|
||||
|
|
|
@ -708,7 +708,8 @@ gst_d3d11_get_pixel_shader_checker_luma (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_checker_luma, sizeof (g_PSMain_checker_luma),
|
||||
g_PSMain_checker_luma_str, "PSMain_checker_luma", ps);
|
||||
g_PSMain_checker_luma_str, sizeof (g_PSMain_checker_luma_str),
|
||||
"PSMain_checker_luma", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -723,7 +724,8 @@ gst_d3d11_get_pixel_shader_checker_rgb (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_checker_rgb, sizeof (g_PSMain_checker_rgb),
|
||||
g_PSMain_checker_rgb_str, "PSMain_checker_rgb", ps);
|
||||
g_PSMain_checker_rgb_str, sizeof (g_PSMain_checker_rgb_str),
|
||||
"PSMain_checker_rgb", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -738,7 +740,8 @@ gst_d3d11_get_pixel_shader_checker_vuya (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_checker_vuya, sizeof (g_PSMain_checker_vuya),
|
||||
g_PSMain_checker_vuya_str, "PSMain_checker_vuya", ps);
|
||||
g_PSMain_checker_vuya_str, sizeof (g_PSMain_checker_vuya_str),
|
||||
"PSMain_checker_vuya", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -753,7 +756,8 @@ gst_d3d11_get_pixel_shader_checker (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_checker, sizeof (g_PSMain_checker),
|
||||
g_PSMain_checker_str, "PSMain_checker", ps);
|
||||
g_PSMain_checker_str, sizeof (g_PSMain_checker_str),
|
||||
"PSMain_checker", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -768,7 +772,7 @@ gst_d3d11_get_pixel_shader_color (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_color, sizeof (g_PSMain_color),
|
||||
g_PSMain_color_str, "PSMain_color", ps);
|
||||
g_PSMain_color_str, sizeof (g_PSMain_color_str), "PSMain_color", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -783,7 +787,8 @@ gst_d3d11_get_pixel_shader_sample_premul (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_sample_premul, sizeof (g_PSMain_sample_premul),
|
||||
g_PSMain_sample_premul_str, "PSMain_sample_premul", ps);
|
||||
g_PSMain_sample_premul_str, sizeof (g_PSMain_sample_premul_str),
|
||||
"PSMain_sample_premul", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -798,7 +803,7 @@ gst_d3d11_get_pixel_shader_sample (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_sample, sizeof (g_PSMain_sample),
|
||||
g_PSMain_sample_str, "PSMain_sample", ps);
|
||||
g_PSMain_sample_str, sizeof (g_PSMain_sample_str), "PSMain_sample", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -813,7 +818,7 @@ gst_d3d11_get_pixel_shader_snow (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_pixel_shader (device, token,
|
||||
g_PSMain_snow, sizeof (g_PSMain_snow),
|
||||
g_PSMain_snow_str, "PSMain_snow", ps);
|
||||
g_PSMain_snow_str, sizeof (g_PSMain_snow_str), "PSMain_snow", ps);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -846,8 +851,8 @@ gst_d3d11_get_vertex_shader_color (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_vertex_shader (device, token,
|
||||
g_VSMain_color, sizeof (g_VSMain_color),
|
||||
g_VSMain_color_str, "VSMain_color", input_desc, G_N_ELEMENTS (input_desc),
|
||||
vs, layout);
|
||||
g_VSMain_color_str, sizeof (g_VSMain_color_str), "VSMain_color",
|
||||
input_desc, G_N_ELEMENTS (input_desc), vs, layout);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -880,8 +885,8 @@ gst_d3d11_get_vertex_shader_coord (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_vertex_shader (device, token,
|
||||
g_VSMain_coord, sizeof (g_VSMain_coord),
|
||||
g_VSMain_coord_str, "VSMain_coord", input_desc, G_N_ELEMENTS (input_desc),
|
||||
vs, layout);
|
||||
g_VSMain_coord_str, sizeof (g_VSMain_coord_str), "VSMain_coord",
|
||||
input_desc, G_N_ELEMENTS (input_desc), vs, layout);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -906,5 +911,6 @@ gst_d3d11_get_vertex_shader_pos (GstD3D11Device * device,
|
|||
|
||||
return gst_d3d11_device_get_vertex_shader (device, token,
|
||||
g_VSMain_pos, sizeof (g_VSMain_pos),
|
||||
g_VSMain_pos_str, "VSMain_pos", &input_desc, 1, vs, layout);
|
||||
g_VSMain_pos_str, sizeof (g_VSMain_pos_str), "VSMain_pos", &input_desc, 1,
|
||||
vs, layout);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue