mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
d3d11: Use shader model 4
Since shader model 4 is sufficient for the current pixel shader implementations, prebuild HLSL with shader model 4 as well. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5709>
This commit is contained in:
parent
df0e6c4140
commit
721533d042
4 changed files with 45 additions and 82 deletions
|
@ -1677,7 +1677,6 @@ gst_d3d11_device_get_pixel_shader_uncached (GstD3D11Device * device,
|
||||||
"Creating pixel shader for token %" G_GINT64_FORMAT ", source:\n%s",
|
"Creating pixel shader for token %" G_GINT64_FORMAT ", source:\n%s",
|
||||||
token, source);
|
token, source);
|
||||||
|
|
||||||
if (priv->feature_level >= D3D_FEATURE_LEVEL_11_0) {
|
|
||||||
if (bytecode && bytecode_size > 1) {
|
if (bytecode && bytecode_size > 1) {
|
||||||
data = bytecode;
|
data = bytecode;
|
||||||
size = bytecode_size;
|
size = bytecode_size;
|
||||||
|
@ -1692,34 +1691,6 @@ gst_d3d11_device_get_pixel_shader_uncached (GstD3D11Device * device,
|
||||||
data = blob->GetBufferPointer ();
|
data = blob->GetBufferPointer ();
|
||||||
size = blob->GetBufferSize ();
|
size = blob->GetBufferSize ();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ComPtr < ID3DBlob > error_msg;
|
|
||||||
const gchar *target;
|
|
||||||
if (priv->feature_level >= D3D_FEATURE_LEVEL_10_0)
|
|
||||||
target = "ps_4_0";
|
|
||||||
else if (priv->feature_level >= D3D_FEATURE_LEVEL_9_3)
|
|
||||||
target = "ps_4_0_level_9_3";
|
|
||||||
else
|
|
||||||
target = "ps_4_0_level_9_1";
|
|
||||||
|
|
||||||
hr = gst_d3d11_compile (source, source_size, nullptr, defines,
|
|
||||||
nullptr, entry_point, target, 0, 0, &blob, &error_msg);
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
|
||||||
const gchar *err = nullptr;
|
|
||||||
|
|
||||||
if (error_msg)
|
|
||||||
err = (const gchar *) error_msg->GetBufferPointer ();
|
|
||||||
|
|
||||||
GST_ERROR_OBJECT (device,
|
|
||||||
"Couldn't compile code, hr: 0x%x, error detail: %s, source code: \n%s",
|
|
||||||
(guint) hr, GST_STR_NULL (err), source);
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = blob->GetBufferPointer ();
|
|
||||||
size = blob->GetBufferSize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = priv->device->CreatePixelShader (data, size, nullptr, &shader);
|
hr = priv->device->CreatePixelShader (data, size, nullptr, &shader);
|
||||||
if (!gst_d3d11_result (hr, device))
|
if (!gst_d3d11_result (hr, device))
|
||||||
|
@ -1779,6 +1750,9 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token,
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ComPtr < ID3D11VertexShader > shader;
|
ComPtr < ID3D11VertexShader > shader;
|
||||||
ComPtr < ID3D11InputLayout > input_layout;
|
ComPtr < ID3D11InputLayout > input_layout;
|
||||||
|
ComPtr < ID3DBlob > blob;
|
||||||
|
const void *data;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (device, "Getting vertext shader \"%s\" for token %"
|
GST_DEBUG_OBJECT (device, "Getting vertext shader \"%s\" for token %"
|
||||||
G_GINT64_FORMAT, entry_point, token);
|
G_GINT64_FORMAT, entry_point, token);
|
||||||
|
@ -1800,11 +1774,6 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token,
|
||||||
"Creating vertex shader for token %" G_GINT64_FORMAT ", shader: \n%s",
|
"Creating vertex shader for token %" G_GINT64_FORMAT ", shader: \n%s",
|
||||||
token, source);
|
token, source);
|
||||||
|
|
||||||
if (priv->feature_level >= D3D_FEATURE_LEVEL_11_0) {
|
|
||||||
ComPtr < ID3DBlob > blob;
|
|
||||||
const void *data;
|
|
||||||
gsize size;
|
|
||||||
|
|
||||||
if (bytecode && bytecode_size > 1) {
|
if (bytecode && bytecode_size > 1) {
|
||||||
data = bytecode;
|
data = bytecode;
|
||||||
size = bytecode_size;
|
size = bytecode_size;
|
||||||
|
@ -1828,12 +1797,6 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token,
|
||||||
size, &input_layout);
|
size, &input_layout);
|
||||||
if (!gst_d3d11_result (hr, device))
|
if (!gst_d3d11_result (hr, device))
|
||||||
return hr;
|
return hr;
|
||||||
} else {
|
|
||||||
hr = gst_d3d11_create_vertex_shader_simple (device, source, entry_point,
|
|
||||||
input_desc, desc_len, &shader, &input_layout);
|
|
||||||
if (!gst_d3d11_result (hr, device))
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (device, "Created vertex shader \"%s\" for token %"
|
GST_DEBUG_OBJECT (device, "Created vertex shader \"%s\" for token %"
|
||||||
G_GINT64_FORMAT, entry_point, token);
|
G_GINT64_FORMAT, entry_point, token);
|
||||||
|
|
|
@ -49,7 +49,7 @@ gst_d3d11_shader_cache_get_pixel_shader_blob (gint64 token,
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, defines,
|
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, defines,
|
||||||
nullptr, entry_point, "ps_5_0", 0, 0, blob, nullptr);
|
nullptr, entry_point, "ps_4_0", 0, 0, blob, nullptr);
|
||||||
if (FAILED (hr))
|
if (FAILED (hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ gst_d3d11_shader_cache_get_vertex_shader_blob (gint64 token,
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, nullptr,
|
HRESULT hr = gst_d3d11_compile (source, source_size, nullptr, nullptr,
|
||||||
nullptr, entry_point, "vs_5_0", 0, 0, blob, nullptr);
|
nullptr, entry_point, "vs_4_0", 0, 0, blob, nullptr);
|
||||||
if (FAILED (hr))
|
if (FAILED (hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ foreach input_format : hlsl_ps_input_formats
|
||||||
output : header,
|
output : header,
|
||||||
command : [fxc, '/Fh', '@OUTPUT@',
|
command : [fxc, '/Fh', '@OUTPUT@',
|
||||||
'/E', entry_point,
|
'/E', entry_point,
|
||||||
'/T', 'ps_5_0',
|
'/T', 'ps_4_0',
|
||||||
'/D', 'BUILDING_HLSL=1',
|
'/D', 'BUILDING_HLSL=1',
|
||||||
'/D', 'OUTPUT_TYPE=@0@'.format(output_type),
|
'/D', 'OUTPUT_TYPE=@0@'.format(output_type),
|
||||||
'/D', 'ENTRY_POINT=@0@'.format(entry_point),
|
'/D', 'ENTRY_POINT=@0@'.format(entry_point),
|
||||||
|
@ -109,7 +109,7 @@ generated_collection = custom_target(header_collection,
|
||||||
hlsl_precompiled += generated_collection
|
hlsl_precompiled += generated_collection
|
||||||
|
|
||||||
hlsl_vs_sources = [
|
hlsl_vs_sources = [
|
||||||
[files('VSMain_converter.hlsl'), 'VSMain_converter', 'vs_5_0'],
|
[files('VSMain_converter.hlsl'), 'VSMain_converter', 'vs_4_0'],
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach shader : hlsl_vs_sources
|
foreach shader : hlsl_vs_sources
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
hlsl_sources = [
|
hlsl_sources = [
|
||||||
['PSMain_checker_luma', 'ps_5_0'],
|
['PSMain_checker_luma', 'ps_4_0'],
|
||||||
['PSMain_checker_rgb', 'ps_5_0'],
|
['PSMain_checker_rgb', 'ps_4_0'],
|
||||||
['PSMain_checker_vuya', 'ps_5_0'],
|
['PSMain_checker_vuya', 'ps_4_0'],
|
||||||
['PSMain_checker', 'ps_5_0'],
|
['PSMain_checker', 'ps_4_0'],
|
||||||
['PSMain_color', 'ps_5_0'],
|
['PSMain_color', 'ps_4_0'],
|
||||||
['PSMain_sample_premul', 'ps_5_0'],
|
['PSMain_sample_premul', 'ps_4_0'],
|
||||||
['PSMain_sample', 'ps_5_0'],
|
['PSMain_sample', 'ps_4_0'],
|
||||||
['PSMain_snow', 'ps_5_0'],
|
['PSMain_snow', 'ps_4_0'],
|
||||||
['VSMain_color', 'vs_5_0'],
|
['VSMain_color', 'vs_4_0'],
|
||||||
['VSMain_coord', 'vs_5_0'],
|
['VSMain_coord', 'vs_4_0'],
|
||||||
['VSMain_pos', 'vs_5_0'],
|
['VSMain_pos', 'vs_4_0'],
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach shader : hlsl_sources
|
foreach shader : hlsl_sources
|
||||||
|
|
Loading…
Reference in a new issue