diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11compile.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11compile.cpp index 220d08607a..b412847806 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11compile.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11compile.cpp @@ -25,7 +25,7 @@ #include "gstd3d11device.h" #include "gstd3d11utils.h" #include "gstd3d11-private.h" -#include +#include #include #include @@ -60,9 +60,6 @@ ensure_debug_category (void) #define ensure_debug_category() /* NOOP */ #endif /* GST_DISABLE_GST_DEBUG */ -static GModule *d3d_compiler_module = nullptr; -static pD3DCompile GstD3DCompileFunc = nullptr; - /** * gst_d3d11_compile_init: * @@ -75,47 +72,7 @@ static pD3DCompile GstD3DCompileFunc = nullptr; gboolean gst_d3d11_compile_init (void) { - GST_D3D11_CALL_ONCE_BEGIN { -#if GST_D3D11_WINAPI_ONLY_APP - /* Assuming that d3d compiler library is available */ - GstD3DCompileFunc = D3DCompile; -#else - static const gchar *d3d_compiler_names[] = { - "d3dcompiler_47.dll", - "d3dcompiler_46.dll", - "d3dcompiler_45.dll", - "d3dcompiler_44.dll", - "d3dcompiler_43.dll", - }; - for (guint i = 0; i < G_N_ELEMENTS (d3d_compiler_names); i++) { - d3d_compiler_module = - g_module_open (d3d_compiler_names[i], G_MODULE_BIND_LAZY); - - if (d3d_compiler_module) { - GST_INFO ("D3D compiler %s is available", d3d_compiler_names[i]); - if (!g_module_symbol (d3d_compiler_module, "D3DCompile", - (gpointer *) & GstD3DCompileFunc)) { - GST_ERROR ("Cannot load D3DCompile symbol from %s", - d3d_compiler_names[i]); - g_module_close (d3d_compiler_module); - d3d_compiler_module = nullptr; - GstD3DCompileFunc = nullptr; - } else { - break; - } - } - } - - if (!GstD3DCompileFunc) - GST_WARNING ("D3D11 compiler library is unavailable"); -#endif - } - GST_D3D11_CALL_ONCE_END; - - if (!GstD3DCompileFunc) - return FALSE; - - return TRUE; + return gst_d3d_compile_init (); } /** @@ -147,7 +104,7 @@ gst_d3d11_compile (LPCVOID src_data, SIZE_T src_data_size, LPCSTR source_name, if (!gst_d3d11_compile_init ()) return E_FAIL; - return GstD3DCompileFunc (src_data, src_data_size, source_name, defines, + return gst_d3d_compile (src_data, src_data_size, source_name, defines, include, entry_point, target, flags1, flags2, code, error_msgs); } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.cpp index ee8e9ed761..d22f0eae96 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.cpp @@ -25,447 +25,105 @@ #include "gstd3d11device-private.h" #include "gstd3d11-private.h" #include "gstd3d11utils.h" -#include -#include -#include -#include -#include +#include GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_converter_debug); #define GST_CAT_DEFAULT gst_d3d11_converter_debug /* *INDENT-OFF* */ using namespace Microsoft::WRL; - -struct ConverterPSSource -{ - gint64 token; - std::string entry_point; - const BYTE *bytecode; - SIZE_T bytecode_size; - std::vector> macros; - guint num_rtv; -}; - -enum class PS_OUTPUT -{ - PACKED, - LUMA, - CHROMA, - CHROMA_PLANAR, - PLANAR, - PLANAR_FULL, -}; - -static std::map> ps_source_cache; -static std::mutex cache_lock; -#ifdef HLSL_PRECOMPILED -#include "PSMainConverter.h" -#include "VSMain_converter.h" -#else -static const std::map> precompiled_bytecode; -#endif - -#include "hlsl/PSMain_converter.hlsl" -#include "hlsl/VSMain_converter.hlsl" - -static const std::string -ps_output_to_string (PS_OUTPUT output) -{ - switch (output) { - case PS_OUTPUT::PACKED: - return "PS_OUTPUT_PACKED"; - case PS_OUTPUT::LUMA: - return "PS_OUTPUT_LUMA"; - case PS_OUTPUT::CHROMA: - return "PS_OUTPUT_CHROMA"; - case PS_OUTPUT::CHROMA_PLANAR: - return "PS_OUTPUT_CHROMA_PLANAR"; - case PS_OUTPUT::PLANAR: - return "PS_OUTPUT_PLANAR"; - case PS_OUTPUT::PLANAR_FULL: - return "PS_OUTPUT_PLANAR_FULL"; - default: - g_assert_not_reached (); - break; - } - - return ""; -} - -static guint -ps_output_get_num_rtv (PS_OUTPUT output) -{ - switch (output) { - case PS_OUTPUT::PACKED: - case PS_OUTPUT::LUMA: - case PS_OUTPUT::CHROMA: - return 1; - case PS_OUTPUT::CHROMA_PLANAR: - return 2; - case PS_OUTPUT::PLANAR: - return 3; - case PS_OUTPUT::PLANAR_FULL: - return 4; - default: - g_assert_not_reached (); - break; - } - - return 0; -} - -static std::string -make_input (GstVideoFormat format, gboolean premul) -{ - switch (format) { - case GST_VIDEO_FORMAT_RGBA: - case GST_VIDEO_FORMAT_RGBA64_LE: - case GST_VIDEO_FORMAT_RGB10A2_LE: - case GST_VIDEO_FORMAT_BGRA: - if (premul) - return "RGBAPremul"; - return "RGBA"; - case GST_VIDEO_FORMAT_RGBx: - case GST_VIDEO_FORMAT_BGRx: - return "RGBx"; - case GST_VIDEO_FORMAT_ARGB: - if (premul) - return "ARGBPremul"; - return "ARGB"; - case GST_VIDEO_FORMAT_xRGB: - return "xRGB"; - case GST_VIDEO_FORMAT_ABGR: - if (premul) - return "ABGRPremul"; - return "ABGR"; - case GST_VIDEO_FORMAT_xBGR: - return "xBGR"; - case GST_VIDEO_FORMAT_VUYA: - if (premul) - return "VUYAPremul"; - return "VUYA"; - case GST_VIDEO_FORMAT_AYUV: - case GST_VIDEO_FORMAT_AYUV64: - return "AYUV"; - case GST_VIDEO_FORMAT_NV12: - case GST_VIDEO_FORMAT_P010_10LE: - case GST_VIDEO_FORMAT_P012_LE: - case GST_VIDEO_FORMAT_P016_LE: - return "NV12"; - case GST_VIDEO_FORMAT_NV21: - return "NV21"; - case GST_VIDEO_FORMAT_I420: - case GST_VIDEO_FORMAT_Y42B: - case GST_VIDEO_FORMAT_Y444: - case GST_VIDEO_FORMAT_Y444_16LE: - return "I420"; - case GST_VIDEO_FORMAT_YV12: - return "YV12"; - case GST_VIDEO_FORMAT_I420_10LE: - case GST_VIDEO_FORMAT_I422_10LE: - case GST_VIDEO_FORMAT_Y444_10LE: - return "I420_10"; - case GST_VIDEO_FORMAT_I420_12LE: - case GST_VIDEO_FORMAT_I422_12LE: - case GST_VIDEO_FORMAT_Y444_12LE: - return "I420_12"; - case GST_VIDEO_FORMAT_Y410: - return "Y410"; - case GST_VIDEO_FORMAT_GRAY8: - case GST_VIDEO_FORMAT_GRAY16_LE: - return "GRAY"; - case GST_VIDEO_FORMAT_RGBP: - return "RGBP"; - case GST_VIDEO_FORMAT_BGRP: - return "BGRP"; - case GST_VIDEO_FORMAT_GBR: - case GST_VIDEO_FORMAT_GBR_16LE: - return "GBR"; - case GST_VIDEO_FORMAT_GBR_10LE: - return "GBR_10"; - case GST_VIDEO_FORMAT_GBR_12LE: - return "GBR_12"; - case GST_VIDEO_FORMAT_GBRA: - if (premul) - return "GBRAPremul"; - return "GBRA"; - case GST_VIDEO_FORMAT_GBRA_10LE: - if (premul) - return "GBRAPremul_10"; - return "GBRA_10"; - case GST_VIDEO_FORMAT_GBRA_12LE: - if (premul) - return "GBRAPremul_12"; - return "GBRA_12"; - case GST_VIDEO_FORMAT_Y412_LE: - if (premul) - return "Y412Premul"; - return "Y412"; - case GST_VIDEO_FORMAT_BGR10A2_LE: - return "BGR10A2"; - case GST_VIDEO_FORMAT_BGRA64_LE: - if (premul) - return "BGRA64Premul"; - return "BGRA64"; - case GST_VIDEO_FORMAT_RBGA: - if (premul) - return "RBGAPremul"; - return "RBGA"; - default: - g_assert_not_reached (); - break; - } - - return ""; -} - -static std::vector> -make_output (GstVideoFormat format, gboolean premul) -{ - std::vector> ret; - - switch (format) { - case GST_VIDEO_FORMAT_RGBA: - case GST_VIDEO_FORMAT_RGBA64_LE: - case GST_VIDEO_FORMAT_RGB10A2_LE: - case GST_VIDEO_FORMAT_BGRA: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "RGBAPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "RGBA")); - break; - case GST_VIDEO_FORMAT_RGBx: - case GST_VIDEO_FORMAT_BGRx: - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "RGBx")); - break; - case GST_VIDEO_FORMAT_ARGB: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "ARGBPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "ARGB")); - break; - case GST_VIDEO_FORMAT_xRGB: - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "xRGB")); - break; - case GST_VIDEO_FORMAT_ABGR: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "ABGRPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "ABGR")); - break; - case GST_VIDEO_FORMAT_xBGR: - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "xBGR")); - break; - case GST_VIDEO_FORMAT_VUYA: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "VUYAPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "VUYA")); - break; - case GST_VIDEO_FORMAT_AYUV: - case GST_VIDEO_FORMAT_AYUV64: - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "AYUV")); - break; - case GST_VIDEO_FORMAT_NV12: - case GST_VIDEO_FORMAT_P010_10LE: - case GST_VIDEO_FORMAT_P012_LE: - case GST_VIDEO_FORMAT_P016_LE: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA, "ChromaNV12")); - break; - case GST_VIDEO_FORMAT_NV21: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA, "ChromaNV21")); - break; - case GST_VIDEO_FORMAT_I420: - case GST_VIDEO_FORMAT_Y42B: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA_PLANAR, "ChromaI420")); - break; - case GST_VIDEO_FORMAT_Y444: - case GST_VIDEO_FORMAT_Y444_16LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "Y444")); - break; - case GST_VIDEO_FORMAT_YV12: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA_PLANAR, "ChromaYV12")); - break; - case GST_VIDEO_FORMAT_I420_10LE: - case GST_VIDEO_FORMAT_I422_10LE: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma_10")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA_PLANAR, "ChromaI420_10")); - break; - case GST_VIDEO_FORMAT_Y444_10LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "Y444_10")); - break; - case GST_VIDEO_FORMAT_I420_12LE: - case GST_VIDEO_FORMAT_I422_12LE: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma_12")); - ret.push_back(std::make_pair(PS_OUTPUT::CHROMA_PLANAR, "ChromaI420_12")); - break; - case GST_VIDEO_FORMAT_Y444_12LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "Y444_12")); - break; - case GST_VIDEO_FORMAT_GRAY8: - case GST_VIDEO_FORMAT_GRAY16_LE: - ret.push_back(std::make_pair(PS_OUTPUT::LUMA, "Luma")); - break; - case GST_VIDEO_FORMAT_RGBP: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "RGBP")); - break; - case GST_VIDEO_FORMAT_BGRP: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "BGRP")); - break; - case GST_VIDEO_FORMAT_GBR: - case GST_VIDEO_FORMAT_GBR_16LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "GBR")); - break; - case GST_VIDEO_FORMAT_GBR_10LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "GBR_10")); - break; - case GST_VIDEO_FORMAT_GBR_12LE: - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR, "GBR_12")); - break; - case GST_VIDEO_FORMAT_GBRA: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRAPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRA")); - break; - case GST_VIDEO_FORMAT_GBRA_10LE: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRAPremul_10")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRA_10")); - break; - case GST_VIDEO_FORMAT_GBRA_12LE: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRAPremul_12")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PLANAR_FULL, "GBRA_12")); - break; - case GST_VIDEO_FORMAT_RBGA: - if (premul) - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "RBGAPremul")); - else - ret.push_back(std::make_pair(PS_OUTPUT::PACKED, "RBGA")); - break; - default: - g_assert_not_reached (); - break; - } - - return ret; -} +/* *INDENT-ON* */ PixelShaderList gst_d3d11_get_converter_pixel_shader (GstD3D11Device * device, GstVideoFormat in_format, GstVideoFormat out_format, gboolean in_premul, gboolean out_premul, CONVERT_TYPE type) { - HRESULT hr; - auto input = make_input (in_format, in_premul); - auto output = make_output (out_format, out_premul); - std::string conv_type; + GstD3DConverterType conv_type; + GstD3DShaderModel sm; PixelShaderList ret; switch (type) { case CONVERT_TYPE::IDENTITY: - conv_type = "Identity"; + conv_type = GST_D3D_CONVERTER_IDENTITY; break; case CONVERT_TYPE::SIMPLE: - conv_type = "Simple"; + conv_type = GST_D3D_CONVERTER_SIMPLE; break; case CONVERT_TYPE::RANGE: - conv_type = "Range"; + conv_type = GST_D3D_CONVERTER_RANGE; break; case CONVERT_TYPE::GAMMA: - conv_type = "Gamma"; + conv_type = GST_D3D_CONVERTER_GAMMA; break; case CONVERT_TYPE::PRIMARY: - conv_type = "Primary"; + conv_type = GST_D3D_CONVERTER_PRIMARY; break; + default: + g_assert_not_reached (); + return ret; } - for (const auto & it : output) { - std::string entry_point = "PSMain_" + input + "_" + conv_type + "_" + - it.second; - std::shared_ptr source; - std::vector macros; - ComPtr shader; - cache_lock.lock (); - auto cached = ps_source_cache.find(entry_point); - if (cached != ps_source_cache.end()) { - source = cached->second; - } else { - source = std::make_shared (); - source->token = gst_d3d11_pixel_shader_token_new (); - source->entry_point = entry_point; - auto precompiled = precompiled_bytecode.find (entry_point); - if (precompiled != precompiled_bytecode.end ()) { - source->bytecode = precompiled->second.first; - source->bytecode_size = precompiled->second.second; - } else { - source->bytecode = nullptr; - source->bytecode_size = 0; - } + auto handle = gst_d3d11_device_get_device_handle (device); + auto level = handle->GetFeatureLevel (); + if (level >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + else + sm = GST_D3D_SM_4_0; - source->num_rtv = ps_output_get_num_rtv (it.first); + GstD3DConverterPSByteCode blobs[4]; + auto num_blobs = gst_d3d_converter_shader_get_ps_blob (in_format, out_format, + in_premul, out_premul, conv_type, sm, blobs); - source->macros.push_back(std::make_pair("ENTRY_POINT", entry_point)); - source->macros.push_back(std::make_pair("SAMPLER", "Sampler" + input)); - source->macros.push_back(std::make_pair("CONVERTER", - "Converter" + conv_type)); - source->macros.push_back(std::make_pair("OUTPUT_TYPE", - ps_output_to_string(it.first))); - source->macros.push_back(std::make_pair("OUTPUT_BUILDER", - "Output" + it.second)); - ps_source_cache[entry_point] = source; - } - cache_lock.unlock (); + if (!num_blobs) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return ret; + } - for (const auto & defines : source->macros) - macros.push_back({defines.first.c_str (), defines.second.c_str ()}); - - macros.push_back({nullptr, nullptr}); - - hr = gst_d3d11_device_get_pixel_shader_uncached (device, source->token, - source->bytecode, source->bytecode_size, g_PSMain_converter_str, - sizeof (g_PSMain_converter_str), source->entry_point.c_str (), - ¯os[0], &shader); + for (guint i = 0; i < num_blobs; i++) { + ComPtr < ID3D11PixelShader > shader; + auto blob = &blobs[i]; + auto hr = handle->CreatePixelShader (blob->byte_code.byte_code, + blob->byte_code.byte_code_len, nullptr, &shader); if (!gst_d3d11_result (hr, device)) { + GST_ERROR_OBJECT (device, "Couldn't create pixel shader"); ret.clear (); return ret; } - auto ps = std::make_shared (); + auto ps = std::make_shared < PixelShader > (); ps->shader = shader; - ps->num_rtv = source->num_rtv; + ps->num_rtv = blob->num_rtv; ret.push_back (ps); } return ret; } -/* *INDENT-ON* */ HRESULT gst_d3d11_get_converter_vertex_shader (GstD3D11Device * device, ID3D11VertexShader ** vs, ID3D11InputLayout ** layout) { static gint64 token = 0; - const void *bytecode = nullptr; - gsize bytecode_size = 0; GST_D3D11_CALL_ONCE_BEGIN { token = gst_d3d11_vertex_shader_token_new (); } GST_D3D11_CALL_ONCE_END; -#ifdef HLSL_PRECOMPILED - bytecode = g_VSMain_converter; - bytecode_size = sizeof (g_VSMain_converter); -#endif + auto handle = gst_d3d11_device_get_device_handle (device); + auto level = handle->GetFeatureLevel (); + GstD3DShaderModel sm; + if (level >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + else + sm = GST_D3D_SM_4_0; + + GstD3DShaderByteCode bytecode = { }; + if (!gst_d3d_converter_shader_get_vs_blob (sm, &bytecode)) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return E_FAIL; + } D3D11_INPUT_ELEMENT_DESC input_desc[2]; @@ -485,8 +143,6 @@ gst_d3d11_get_converter_vertex_shader (GstD3D11Device * device, input_desc[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; input_desc[1].InstanceDataStepRate = 0; - return gst_d3d11_device_get_vertex_shader (device, token, - bytecode, bytecode_size, g_VSMain_converter_str, - sizeof (g_VSMain_converter_str), "VSMain_converter", input_desc, - G_N_ELEMENTS (input_desc), vs, layout); + return gst_d3d11_device_get_vertex_shader (device, token, "VSMain_converter", + &bytecode, input_desc, G_N_ELEMENTS (input_desc), vs, layout); } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.h index bce879abc2..cd49394ac7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-builder.h @@ -25,7 +25,6 @@ #include #include #include -#include enum class CONVERT_TYPE { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-helper.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-helper.cpp index e6e9b7ab44..c5b6e992f7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-helper.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11converter-helper.cpp @@ -29,13 +29,11 @@ #include "gstd3d11memory.h" #include "gstd3d11bufferpool.h" #include "gstd3d11shadercache.h" +#include #include #include -#include #include #include -#include -#include /* *INDENT-OFF* */ using namespace Microsoft::WRL; @@ -44,27 +42,6 @@ using namespace Microsoft::WRL; GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_converter_debug); #define GST_CAT_DEFAULT gst_d3d11_converter_debug -/* *INDENT-OFF* */ -struct ConverterCSSource -{ - gint64 token; - std::string entry_point; - const BYTE *bytecode; - SIZE_T bytecode_size; - std::vector> macros; -}; - -static std::map> cs_source_cache; -static std::mutex cache_lock; -#ifdef HLSL_PRECOMPILED -#include "CSMainConverter.h" -#else -static const std::map> precompiled_bytecode; -#endif -/* *INDENT-ON* */ - -#include "hlsl/CSMain_converter.hlsl" - struct _GstD3D11ConverterHelper { ~_GstD3D11ConverterHelper () @@ -105,249 +82,28 @@ gst_d3d11_converter_helper_new (GstD3D11Device * device, { GstD3D11ConverterHelper *self; ComPtr < ID3D11ComputeShader > cs; - D3D_FEATURE_LEVEL feature_level; DXGI_FORMAT srv_format = DXGI_FORMAT_UNKNOWN; DXGI_FORMAT uav_format = DXGI_FORMAT_UNKNOWN; guint x_unit = 8; guint y_unit = 8; - std::string entry_point; HRESULT hr; + GstD3DConverterCSByteCode bytecode = { }; + gboolean try_cs = FALSE; + gboolean need_convert = FALSE; + auto handle = gst_d3d11_device_get_device_handle (device); if (in_format != out_format) { - std::string in_format_str; - std::string out_format_str; - - switch (in_format) { - case GST_VIDEO_FORMAT_YUY2: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "YUY2"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_UYVY: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "UYVY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_VYUY: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "VYUY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_YVYU: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "YVYU"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_Y210: - case GST_VIDEO_FORMAT_Y212_LE: - srv_format = DXGI_FORMAT_R16G16B16A16_UNORM; - in_format_str = "YUY2"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_v210: - srv_format = DXGI_FORMAT_R10G10B10A2_UNORM; - in_format_str = "v210"; - x_unit = 48; - break; - case GST_VIDEO_FORMAT_v216: - srv_format = DXGI_FORMAT_R16G16B16A16_UNORM; - in_format_str = "UYVY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_v308: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "v308"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_IYU2: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "IYU2"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_RGB: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "RGB"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_BGR: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "BGR"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_RGB16: - srv_format = DXGI_FORMAT_R16_UINT; - in_format_str = "RGB16"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGR16: - srv_format = DXGI_FORMAT_R16_UINT; - in_format_str = "BGR16"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_RGB15: - srv_format = DXGI_FORMAT_R16_UINT; - in_format_str = "RGB15"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGR15: - srv_format = DXGI_FORMAT_R16_UINT; - in_format_str = "BGR15"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_r210: - srv_format = DXGI_FORMAT_R32_UINT; - in_format_str = "r210"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_AYUV: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "AYUV"; - break; - case GST_VIDEO_FORMAT_AYUV64: - srv_format = DXGI_FORMAT_R16G16B16A16_UNORM; - in_format_str = "AYUV"; - break; - case GST_VIDEO_FORMAT_RGBA: - srv_format = DXGI_FORMAT_R8G8B8A8_UNORM; - in_format_str = "RGBA"; - break; - case GST_VIDEO_FORMAT_RGB10A2_LE: - srv_format = DXGI_FORMAT_R10G10B10A2_UNORM; - in_format_str = "RGBA"; - break; - case GST_VIDEO_FORMAT_RGBA64_LE: - srv_format = DXGI_FORMAT_R16G16B16A16_UNORM; - in_format_str = "RGBA"; - break; - default: - g_assert_not_reached (); - return nullptr; + need_convert = TRUE; + if (handle->GetFeatureLevel () >= D3D_FEATURE_LEVEL_11_0) { + try_cs = gst_d3d_converter_shader_get_cs_blob (in_format, out_format, + GST_D3D_SM_5_0, &bytecode); + if (try_cs) { + srv_format = bytecode.srv_format; + uav_format = bytecode.uav_format; + x_unit = bytecode.x_unit; + y_unit = bytecode.y_unit; + } } - - switch (out_format) { - case GST_VIDEO_FORMAT_YUY2: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "YUY2"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_UYVY: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "UYVY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_VYUY: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "VYUY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_YVYU: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "YVYU"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_Y210: - case GST_VIDEO_FORMAT_Y212_LE: - uav_format = DXGI_FORMAT_R16G16B16A16_UNORM; - out_format_str = "YUY2"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_v210: - uav_format = DXGI_FORMAT_R10G10B10A2_UNORM; - out_format_str = "v210"; - x_unit = 48; - break; - case GST_VIDEO_FORMAT_v216: - uav_format = DXGI_FORMAT_R16G16B16A16_UNORM; - out_format_str = "UYVY"; - x_unit = 16; - break; - case GST_VIDEO_FORMAT_v308: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "v308"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_IYU2: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "IYU2"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_Y410: - uav_format = DXGI_FORMAT_R10G10B10A2_UNORM; - out_format_str = "Y410"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_Y412_LE: - uav_format = DXGI_FORMAT_R16G16B16A16_UNORM; - out_format_str = "Y410"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_RGB: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "RGB"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_BGR: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "BGR"; - x_unit = 32; - break; - case GST_VIDEO_FORMAT_RGB16: - uav_format = DXGI_FORMAT_R16_UINT; - out_format_str = "RGB16"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGR16: - uav_format = DXGI_FORMAT_R16_UINT; - out_format_str = "BGR16"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_RGB15: - uav_format = DXGI_FORMAT_R16_UINT; - out_format_str = "RGB15"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGR15: - uav_format = DXGI_FORMAT_R16_UINT; - out_format_str = "BGR15"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_r210: - uav_format = DXGI_FORMAT_R32_UINT; - out_format_str = "r210"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGRA64_LE: - uav_format = DXGI_FORMAT_R16G16B16A16_UNORM; - out_format_str = "BGRA"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_BGR10A2_LE: - uav_format = DXGI_FORMAT_R10G10B10A2_UNORM; - out_format_str = "BGRA"; - x_unit = 8; - break; - case GST_VIDEO_FORMAT_AYUV: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "AYUV"; - break; - case GST_VIDEO_FORMAT_AYUV64: - uav_format = DXGI_FORMAT_R16G16B16A16_UNORM; - out_format_str = "AYUV"; - break; - case GST_VIDEO_FORMAT_RGBA: - uav_format = DXGI_FORMAT_R8G8B8A8_UNORM; - out_format_str = "RGBA"; - break; - case GST_VIDEO_FORMAT_RGB10A2_LE: - uav_format = DXGI_FORMAT_R10G10B10A2_UNORM; - out_format_str = "RGBA"; - break; - default: - g_assert_not_reached (); - return nullptr; - } - - entry_point = "CSMain_" + in_format_str + "_to_" + out_format_str; } self = new GstD3D11ConverterHelper (); @@ -361,14 +117,8 @@ gst_d3d11_converter_helper_new (GstD3D11Device * device, self->srv_format = srv_format; self->uav_format = uav_format; - if (!entry_point.empty ()) { - auto handle = gst_d3d11_device_get_device_handle (device); - gboolean try_cs = TRUE; - feature_level = handle->GetFeatureLevel (); - if (feature_level < D3D_FEATURE_LEVEL_11_0) { - try_cs = FALSE; - GST_DEBUG ("Device does not support typed UAV"); - } else if (uav_format != DXGI_FORMAT_R32_UINT) { + if (need_convert) { + if (try_cs && uav_format != DXGI_FORMAT_R32_UINT) { D3D11_FEATURE_DATA_FORMAT_SUPPORT2 support2; support2.InFormat = uav_format; support2.OutFormatSupport2 = 0; @@ -383,57 +133,14 @@ gst_d3d11_converter_helper_new (GstD3D11Device * device, } if (try_cs) { - std::lock_guard lk (cache_lock); - std::shared_ptr source; - auto cached = cs_source_cache.find (entry_point); - if (cached != cs_source_cache.end ()) { - source = cached->second; - } else { - source = std::make_shared (); - source->token = gst_d3d11_compute_shader_token_new (); - source->entry_point = entry_point; - auto precompiled = precompiled_bytecode.find (entry_point); - if (precompiled != precompiled_bytecode.end ()) { - source->bytecode = precompiled->second.first; - source->bytecode_size = precompiled->second.second; - } else { - source->bytecode = nullptr; - source->bytecode_size = 0; - source->macros.push_back(std::make_pair("ENTRY_POINT", entry_point)); - source->macros.push_back(std::make_pair("BUILDING_" + entry_point, "1")); - } - - cs_source_cache[entry_point] = source; - } - - if (source->bytecode) { - hr = handle->CreateComputeShader (source->bytecode, - source->bytecode_size, nullptr, &cs); - if (!gst_d3d11_result (hr, device)) - GST_WARNING ("Couldn't create compute shader from precompiled blob"); - } else { - std::vector macros; - ComPtr < ID3DBlob > blob; - - for (const auto & defines : source->macros) - macros.push_back({defines.first.c_str (), defines.second.c_str ()}); - - macros.push_back({nullptr, nullptr}); - - gst_d3d11_shader_cache_get_compute_shader_blob (source->token, - g_CSMain_converter_str, sizeof (g_CSMain_converter_str), - source->entry_point.c_str (), ¯os[0], &blob); - if (blob) { - hr = handle->CreateComputeShader (blob->GetBufferPointer (), - blob->GetBufferSize (), nullptr, &cs); - if (!gst_d3d11_result (hr, device)) - GST_WARNING ("Couldn't create compute shader from source"); - } - } + hr = handle->CreateComputeShader (bytecode.byte_code.byte_code, + bytecode.byte_code.byte_code_len, nullptr, &cs); + if (!gst_d3d11_result (hr, device)) + GST_WARNING ("Couldn't create compute shader from precompiled blob"); } if (cs) { - GST_DEBUG ("Compute shader \"%s\" available", entry_point.c_str ()); + GST_DEBUG ("Compute shader available"); self->cs = cs; @@ -448,8 +155,7 @@ gst_d3d11_converter_helper_new (GstD3D11Device * device, self->tg_y = (UINT) ceil (height / (float) y_unit); } } else { - GST_DEBUG ("Creating software converter for \"%s\"", - entry_point.c_str ()); + GST_DEBUG ("Creating software converter"); self->sw_conv = gst_video_converter_new (&self->in_info, &self->out_info, nullptr); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h index e31043f621..832702390a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device-private.h @@ -21,6 +21,7 @@ #include #include +#include G_BEGIN_DECLS @@ -36,33 +37,15 @@ gint64 gst_d3d11_compute_shader_token_new (void); GST_D3D11_API HRESULT gst_d3d11_device_get_pixel_shader (GstD3D11Device * device, gint64 token, - const void * bytecode, - gsize bytecode_size, - const gchar * source, - gsize source_size, const gchar * entry_point, - const D3D_SHADER_MACRO * defines, + const GstD3DShaderByteCode * bytecode, ID3D11PixelShader ** ps); -GST_D3D11_API -HRESULT gst_d3d11_device_get_pixel_shader_uncached (GstD3D11Device * device, - gint64 token, - const void * bytecode, - gsize bytecode_size, - const gchar * source, - gsize source_size, - const gchar * entry_point, - const D3D_SHADER_MACRO * defines, - ID3D11PixelShader ** ps); - GST_D3D11_API HRESULT gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token, - const void * bytecode, - gsize bytecode_size, - const gchar * source, - gsize source_size, const gchar * entry_point, + const GstD3DShaderByteCode * bytecode, const D3D11_INPUT_ELEMENT_DESC * input_desc, guint desc_len, ID3D11VertexShader ** vs, diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp index b70a2752bd..3a18b2cb44 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp @@ -1718,76 +1718,31 @@ gst_d3d11_compute_shader_token_new (void) return token_.fetch_add (1); } -HRESULT -gst_d3d11_device_get_pixel_shader_uncached (GstD3D11Device * device, - gint64 token, const void *bytecode, gsize bytecode_size, - const gchar * source, gsize source_size, const gchar * entry_point, - const D3D_SHADER_MACRO * defines, ID3D11PixelShader ** ps) -{ - GstD3D11DevicePrivate *priv = device->priv; - HRESULT hr; - ComPtr < ID3D11PixelShader > shader; - ComPtr < ID3DBlob > blob; - const void *data; - gsize size; - - GST_LOG_OBJECT (device, - "Creating pixel shader for token %" G_GINT64_FORMAT ", source:\n%s", - token, source); - - if (bytecode && bytecode_size > 1) { - data = bytecode; - size = bytecode_size; - GST_DEBUG_OBJECT (device, - "Creating shader \"%s\" using precompiled bytecode", entry_point); - } else { - hr = gst_d3d11_shader_cache_get_pixel_shader_blob (token, - source, source_size, entry_point, defines, &blob); - if (!gst_d3d11_result (hr, device)) - return hr; - - data = blob->GetBufferPointer (); - size = blob->GetBufferSize (); - } - - hr = priv->device->CreatePixelShader (data, size, nullptr, &shader); - if (!gst_d3d11_result (hr, device)) - return hr; - - GST_DEBUG_OBJECT (device, - "Created pixel shader \"%s\" for token %" G_GINT64_FORMAT, - entry_point, token); - *ps = shader.Detach (); - - return S_OK; -} - HRESULT gst_d3d11_device_get_pixel_shader (GstD3D11Device * device, gint64 token, - const void *bytecode, gsize bytecode_size, const gchar * source, - gsize source_size, const gchar * entry_point, - const D3D_SHADER_MACRO * defines, ID3D11PixelShader ** ps) + const gchar * entry_point, const GstD3DShaderByteCode * bytecode, + ID3D11PixelShader ** ps) { GstD3D11DevicePrivate *priv = device->priv; HRESULT hr; ComPtr < ID3D11PixelShader > shader; GST_DEBUG_OBJECT (device, "Getting pixel shader \"%s\" for token %" - G_GINT64_FORMAT, entry_point, token); + G_GINT64_FORMAT, GST_STR_NULL (entry_point), token); std::lock_guard < std::mutex > lk (priv->resource_lock); auto cached = priv->ps_cache.find (token); if (cached != priv->ps_cache.end ()) { GST_DEBUG_OBJECT (device, - "Found cached pixel shader \"%s\" for token %" G_GINT64_FORMAT, - entry_point, token); + "Found cached pixel shader \"%s for token %" G_GINT64_FORMAT, + GST_STR_NULL (entry_point), token); *ps = cached->second.Get (); (*ps)->AddRef (); return S_OK; } - hr = gst_d3d11_device_get_pixel_shader_uncached (device, token, bytecode, - bytecode_size, source, source_size, entry_point, defines, &shader); + hr = priv->device->CreatePixelShader (bytecode->byte_code, + bytecode->byte_code_len, nullptr, &shader); if (!gst_d3d11_result (hr, device)) return hr; @@ -1799,8 +1754,7 @@ 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_size, const gchar * source, - gsize source_size, const gchar * entry_point, + const gchar * entry_point, const GstD3DShaderByteCode * bytecode, const D3D11_INPUT_ELEMENT_DESC * input_desc, guint desc_len, ID3D11VertexShader ** vs, ID3D11InputLayout ** layout) { @@ -1808,19 +1762,16 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token, HRESULT hr; ComPtr < ID3D11VertexShader > shader; ComPtr < ID3D11InputLayout > input_layout; - ComPtr < ID3DBlob > blob; - const void *data; - gsize size; GST_DEBUG_OBJECT (device, "Getting vertext shader \"%s\" for token %" - G_GINT64_FORMAT, entry_point, token); + G_GINT64_FORMAT, GST_STR_NULL (entry_point), token); std::lock_guard < std::mutex > lk (priv->resource_lock); auto cached = priv->vs_cache.find (token); if (cached != priv->vs_cache.end ()) { GST_DEBUG_OBJECT (device, "Found cached vertex shader \"%s\" for token %" G_GINT64_FORMAT, - entry_point, token); + GST_STR_NULL (entry_point), token); *vs = cached->second.first.Get (); *layout = cached->second.second.Get (); (*vs)->AddRef (); @@ -1828,36 +1779,18 @@ gst_d3d11_device_get_vertex_shader (GstD3D11Device * device, gint64 token, return S_OK; } - GST_LOG_OBJECT (device, - "Creating vertex shader for token %" G_GINT64_FORMAT ", shader: \n%s", - token, source); - - if (bytecode && bytecode_size > 1) { - data = bytecode; - size = bytecode_size; - GST_DEBUG_OBJECT (device, - "Creating shader \"%s\" using precompiled bytecode", entry_point); - } else { - hr = gst_d3d11_shader_cache_get_vertex_shader_blob (token, - source, source_size, entry_point, &blob); - if (!gst_d3d11_result (hr, device)) - return hr; - - data = blob->GetBufferPointer (); - size = blob->GetBufferSize (); - } - - hr = priv->device->CreateVertexShader (data, size, nullptr, &shader); + hr = priv->device->CreateVertexShader (bytecode->byte_code, + bytecode->byte_code_len, nullptr, &shader); if (!gst_d3d11_result (hr, device)) return hr; - hr = priv->device->CreateInputLayout (input_desc, desc_len, data, - size, &input_layout); + hr = priv->device->CreateInputLayout (input_desc, desc_len, + bytecode->byte_code, bytecode->byte_code_len, &input_layout); if (!gst_d3d11_result (hr, device)) return hr; GST_DEBUG_OBJECT (device, "Created vertex shader \"%s\" for token %" - G_GINT64_FORMAT, entry_point, token); + G_GINT64_FORMAT, GST_STR_NULL (entry_point), token); priv->vs_cache[token] = std::make_pair (shader, input_layout); *vs = shader.Detach (); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/CSMain_converter.hlsl b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/CSMain_converter.hlsl deleted file mode 100644 index b34a051db2..0000000000 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/CSMain_converter.hlsl +++ /dev/null @@ -1,1169 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -#ifdef BUILDING_CSMain_YUY2_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - float Y0 = val.r; - float U = val.g; - float Y1 = val.b; - float V = val.a; - - outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V); - outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V); -} -#endif - -#ifdef BUILDING_CSMain_UYVY_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - float Y0 = val.g; - float U = val.r; - float Y1 = val.a; - float V = val.b; - - outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V); - outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V); -} -#endif - -#ifdef BUILDING_CSMain_VYUY_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - float Y0 = val.g; - float U = val.b; - float Y1 = val.a; - float V = val.r; - - outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V); - outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V); -} -#endif - -#ifdef BUILDING_CSMain_YVYU_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - float Y0 = val.r; - float U = val.a; - float Y1 = val.b; - float V = val.g; - - outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V); - outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V); -} -#endif - -#ifdef BUILDING_CSMain_v210_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint xpos = tid.x * 4; - float3 val = inTex.Load (uint3 (xpos, tid.y, 0)).xyz; - float U0 = val.r; - float Y0 = val.g; - float V0 = val.b; - - val = inTex.Load (uint3 (xpos + 1, tid.y, 0)).xyz; - float Y1 = val.r; - float U2 = val.g; - float Y2 = val.b; - - val = inTex.Load (uint3 (xpos + 2, tid.y, 0)).xyz; - float V2 = val.r; - float Y3 = val.g; - float U4 = val.b; - - val = inTex.Load (uint3 (xpos + 3, tid.y, 0)).xyz; - float Y4 = val.r; - float V4 = val.g; - float Y5 = val.b; - - xpos = tid.x * 6; - outTex[uint2(xpos, tid.y)] = float4 (1.0, Y0, U0, V0); - outTex[uint2(xpos + 1, tid.y)] = float4 (1.0, Y1, U0, V0); - outTex[uint2(xpos + 2, tid.y)] = float4 (1.0, Y2, U2, V2); - outTex[uint2(xpos + 3, tid.y)] = float4 (1.0, Y3, U2, V2); - outTex[uint2(xpos + 4, tid.y)] = float4 (1.0, Y4, U4, V4); - outTex[uint2(xpos + 5, tid.y)] = float4 (1.0, Y5, U4, V4); -} -#endif - -#ifdef BUILDING_CSMain_v308_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0)); - float Y0 = val.x; - float U0 = val.y; - float V0 = val.z; - float Y1 = val.w; - - val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0)); - float U1 = val.x; - float V1 = val.y; - float Y2 = val.z; - float U2 = val.w; - - val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0)); - float V2 = val.x; - float Y3 = val.y; - float U3 = val.z; - float V3 = val.w; - - outTex[uint2(tid.x * 4, tid.y)] = float4 (1.0, Y0, U0, V0); - outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (1.0, Y1, U1, V1); - outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (1.0, Y2, U2, V2); - outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (1.0, Y3, U3, V3); -} -#endif - -#ifdef BUILDING_CSMain_IYU2_to_AYUV -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0)); - float U0 = val.x; - float Y0 = val.y; - float V0 = val.z; - float U1 = val.w; - - val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0)); - float Y1 = val.x; - float V1 = val.y; - float U2 = val.z; - float Y2 = val.w; - - val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0)); - float V2 = val.x; - float U3 = val.y; - float Y3 = val.z; - float V3 = val.w; - - outTex[uint2(tid.x * 4, tid.y)] = float4 (1.0, Y0, U0, V0); - outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (1.0, Y1, U1, V1); - outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (1.0, Y2, U2, V2); - outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (1.0, Y3, U3, V3); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_YUY2 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw; - float Y0 = val.x; - float U = val.y; - float V = val.z; - float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y; - - outTex[tid.xy] = float4 (Y0, U, Y1, V); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_UYVY -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw; - float Y0 = val.x; - float U = val.y; - float V = val.z; - float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y; - - outTex[tid.xy] = float4 (U, Y0, V, Y1); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_VYUY -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw; - float Y0 = val.x; - float U = val.y; - float V = val.z; - float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y; - - outTex[tid.xy] = float4 (V, Y0, U, Y1); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_YVYU -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw; - float Y0 = val.x; - float U = val.y; - float V = val.z; - float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y; - - outTex[tid.xy] = float4 (Y0, V, Y1, U); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_v210 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint xpos = tid.x * 6; - float3 val = inTex.Load (uint3 (xpos, tid.y, 0)).yzw; - float Y0 = val.x; - float U0 = val.y; - float V0 = val.z; - float Y1 = inTex.Load (uint3 (xpos + 1, tid.y, 0)).y; - - val = inTex.Load (uint3 (xpos + 2, tid.y, 0)).yzw; - float Y2 = val.x; - float U2 = val.y; - float V2 = val.z; - float Y3 = inTex.Load (uint3 (xpos + 3, tid.y, 0)).y; - - val = inTex.Load (uint3 (xpos + 4, tid.y, 0)).yzw; - float Y4 = val.x; - float U4 = val.y; - float V4 = val.z; - float Y5 = inTex.Load (uint3 (xpos + 5, tid.y, 0)).y; - - xpos = tid.x * 4; - outTex[uint2(xpos, tid.y)] = float4 (U0, Y0, V0, 0); - outTex[uint2(xpos + 1, tid.y)] = float4 (Y1, U2, Y2, 0); - outTex[uint2(xpos + 2, tid.y)] = float4 (V2, Y3, U4, 0); - outTex[uint2(xpos + 3, tid.y)] = float4 (Y4, V4, Y5, 0); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_v308 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).yzw; - float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).yzw; - float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).yzw; - float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).yzw; - - outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.x, val0.y, val0.z, val1.x); - outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.y, val1.z, val2.x, val2.y); - outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.z, val3.x, val3.y, val3.z); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_IYU2 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).zyw; - float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).zyw; - float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).zyw; - float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).zyw; - - outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.x, val0.y, val0.z, val1.x); - outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.y, val1.z, val2.x, val2.y); - outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.z, val3.x, val3.y, val3.z); -} -#endif - -#ifdef BUILDING_CSMain_AYUV_to_Y410 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - float Y = val.y; - float U = val.z; - float V = val.w; - float A = val.x; - - outTex[tid.xy] = float4 (U, Y, V, A); -} -#endif - -#ifdef BUILDING_CSMain_RGB_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0)); - float R0 = val.r; - float G0 = val.g; - float B0 = val.b; - float R1 = val.a; - - val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0)); - float G1 = val.r; - float B1 = val.g; - float R2 = val.b; - float G2 = val.a; - - val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0)); - float B2 = val.r; - float R3 = val.g; - float G3 = val.b; - float B3 = val.a; - - outTex[uint2(tid.x * 4, tid.y)] = float4 (R0, G0, B0, 1.0); - outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (R1, G1, B1, 1.0); - outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (R2, G2, B2, 1.0); - outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (R3, G3, B3, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_BGR_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0)); - float B0 = val.r; - float G0 = val.g; - float R0 = val.b; - float B1 = val.a; - - val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0)); - float G1 = val.r; - float R1 = val.g; - float B2 = val.b; - float G2 = val.a; - - val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0)); - float R2 = val.r; - float B3 = val.g; - float G3 = val.b; - float R3 = val.a; - - outTex[uint2(tid.x * 4, tid.y)] = float4 (R0, G0, B0, 1.0); - outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (R1, G1, B1, 1.0); - outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (R2, G2, B2, 1.0); - outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (R3, G3, B3, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_RGB16_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint val = inTex.Load (tid); - float R = float ((val & 0xf800) >> 11) / 31; - float G = float ((val & 0x7e0) >> 5) / 63; - float B = float ((val & 0x1f)) / 31; - - outTex[tid.xy] = float4 (R, G, B, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_BGR16_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint val = inTex.Load (tid); - float B = float ((val & 0xf800) >> 11) / 31; - float G = float ((val & 0x7e0) >> 5) / 63; - float R = float ((val & 0x1f)) / 31; - - outTex[tid.xy] = float4 (R, G, B, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_RGB15_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint val = inTex.Load (tid); - uint R = (val & 0x7c00) >> 10; - uint G = (val & 0x3e0) >> 5; - uint B = (val & 0x1f); - - outTex[tid.xy] = float4 (float3 (R, G, B) / 31, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_BGR15_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint val = inTex.Load (tid); - uint B = (val & 0x7c00) >> 10; - uint G = (val & 0x3e0) >> 5; - uint R = (val & 0x1f); - - outTex[tid.xy] = float4 (float3 (R, G, B) / 31, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_r210_to_RGBA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint val = inTex.Load (tid); - uint val_be = ((val & 0xff) << 24) | ((val & 0xff00) << 8) | - ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24); - uint R = (val_be >> 20) & 0x3ff; - uint G = (val_be >> 10) & 0x3ff; - uint B = val_be & 0x3ff; - - outTex[tid.xy] = float4 (float3 (R, G, B) / 1023, 1.0); -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_RGB -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).rgb; - float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).rgb; - float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).rgb; - float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).rgb; - - outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.r, val0.g, val0.b, val1.r); - outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.g, val1.b, val2.r, val2.g); - outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.b, val3.r, val3.g, val3.b); -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_BGR -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).rgb; - float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).rgb; - float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).rgb; - float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).rgb; - - outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.b, val0.g, val0.r, val1.b); - outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.g, val1.r, val2.b, val2.g); - outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.r, val3.b, val3.g, val3.r); -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_RGB16 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (tid).rgb; - uint R = val.r * 31; - uint G = val.g * 63; - uint B = val.b * 31; - - outTex[tid.xy] = (R << 11) | (G << 5) | B; -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_BGR16 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float3 val = inTex.Load (tid).rgb; - uint R = val.r * 31; - uint G = val.g * 63; - uint B = val.b * 31; - - outTex[tid.xy] = (B << 11) | (G << 5) | R; -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_RGB15 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint3 val = inTex.Load (tid).rgb * 31; - - outTex[tid.xy] = (val.r << 10) | (val.g << 5) | val.b; -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_BGR15 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint3 val = inTex.Load (tid).rgb * 31; - - outTex[tid.xy] = (val.b << 10) | (val.g << 5) | val.r; -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_r210 -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - uint3 val = inTex.Load (tid).rgb * 1023; - uint packed = (val.r << 20) | (val.g << 10) | val.b; - uint packed_be = ((packed & 0xff) << 24) | ((packed & 0xff00) << 8) | - ((packed & 0xff0000) >> 8) | ((packed & 0xff000000) >> 24); - - outTex[tid.xy] = packed_be; -} -#endif - -#ifdef BUILDING_CSMain_RGBA_to_BGRA -Texture2D inTex : register(t0); -RWTexture2D outTex : register(u0); - -void Execute (uint3 tid) -{ - float4 val = inTex.Load (tid); - - outTex[tid.xy] = val.bgra; -} -#endif - -[numthreads(8, 8, 1)] -void ENTRY_POINT (uint3 tid : SV_DispatchThreadID) -{ - Execute (tid); -} -#else -static const char g_CSMain_converter_str[] = -"#ifdef BUILDING_CSMain_YUY2_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -" float Y0 = val.r;\n" -" float U = val.g;\n" -" float Y1 = val.b;\n" -" float V = val.a;\n" -"\n" -" outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V);\n" -" outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_UYVY_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -" float Y0 = val.g;\n" -" float U = val.r;\n" -" float Y1 = val.a;\n" -" float V = val.b;\n" -"\n" -" outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V);\n" -" outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_VYUY_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -" float Y0 = val.g;\n" -" float U = val.b;\n" -" float Y1 = val.a;\n" -" float V = val.r;\n" -"\n" -" outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V);\n" -" outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_YVYU_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -" float Y0 = val.r;\n" -" float U = val.a;\n" -" float Y1 = val.b;\n" -" float V = val.g;\n" -"\n" -" outTex[uint2(tid.x * 2, tid.y)] = float4 (1.0, Y0, U, V);\n" -" outTex[uint2(tid.x * 2 + 1, tid.y)] = float4 (1.0, Y1, U, V);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_v210_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint xpos = tid.x * 4;\n" -" float3 val = inTex.Load (uint3 (xpos, tid.y, 0)).xyz;\n" -" float U0 = val.r;\n" -" float Y0 = val.g;\n" -" float V0 = val.b;\n" -"\n" -" val = inTex.Load (uint3 (xpos + 1, tid.y, 0)).xyz;\n" -" float Y1 = val.r;\n" -" float U2 = val.g;\n" -" float Y2 = val.b;\n" -"\n" -" val = inTex.Load (uint3 (xpos + 2, tid.y, 0)).xyz;\n" -" float V2 = val.r;\n" -" float Y3 = val.g;\n" -" float U4 = val.b;\n" -"\n" -" val = inTex.Load (uint3 (xpos + 3, tid.y, 0)).xyz;\n" -" float Y4 = val.r;\n" -" float V4 = val.g;\n" -" float Y5 = val.b;\n" -"\n" -" xpos = tid.x * 6;\n" -" outTex[uint2(xpos, tid.y)] = float4 (1.0, Y0, U0, V0);\n" -" outTex[uint2(xpos + 1, tid.y)] = float4 (1.0, Y1, U0, V0);\n" -" outTex[uint2(xpos + 2, tid.y)] = float4 (1.0, Y2, U2, V2);\n" -" outTex[uint2(xpos + 3, tid.y)] = float4 (1.0, Y3, U2, V2);\n" -" outTex[uint2(xpos + 4, tid.y)] = float4 (1.0, Y4, U4, V4);\n" -" outTex[uint2(xpos + 5, tid.y)] = float4 (1.0, Y5, U4, V4);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_v308_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0));\n" -" float Y0 = val.x;\n" -" float U0 = val.y;\n" -" float V0 = val.z;\n" -" float Y1 = val.w;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0));\n" -" float U1 = val.x;\n" -" float V1 = val.y;\n" -" float Y2 = val.z;\n" -" float U2 = val.w;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0));\n" -" float V2 = val.x;\n" -" float Y3 = val.y;\n" -" float U3 = val.z;\n" -" float V3 = val.w;\n" -"\n" -" outTex[uint2(tid.x * 4, tid.y)] = float4 (1.0, Y0, U0, V0);\n" -" outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (1.0, Y1, U1, V1);\n" -" outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (1.0, Y2, U2, V2);\n" -" outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (1.0, Y3, U3, V3);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_IYU2_to_AYUV\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0));\n" -" float U0 = val.x;\n" -" float Y0 = val.y;\n" -" float V0 = val.z;\n" -" float U1 = val.w;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0));\n" -" float Y1 = val.x;\n" -" float V1 = val.y;\n" -" float U2 = val.z;\n" -" float Y2 = val.w;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0));\n" -" float V2 = val.x;\n" -" float U3 = val.y;\n" -" float Y3 = val.z;\n" -" float V3 = val.w;\n" -"\n" -" outTex[uint2(tid.x * 4, tid.y)] = float4 (1.0, Y0, U0, V0);\n" -" outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (1.0, Y1, U1, V1);\n" -" outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (1.0, Y2, U2, V2);\n" -" outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (1.0, Y3, U3, V3);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_YUY2\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw;\n" -" float Y0 = val.x;\n" -" float U = val.y;\n" -" float V = val.z;\n" -" float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y;\n" -"\n" -" outTex[tid.xy] = float4 (Y0, U, Y1, V);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_UYVY\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw;\n" -" float Y0 = val.x;\n" -" float U = val.y;\n" -" float V = val.z;\n" -" float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y;\n" -"\n" -" outTex[tid.xy] = float4 (U, Y0, V, Y1);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_VYUY\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw;\n" -" float Y0 = val.x;\n" -" float U = val.y;\n" -" float V = val.z;\n" -" float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y;\n" -"\n" -" outTex[tid.xy] = float4 (V, Y0, U, Y1);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_YVYU\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (uint3(tid.x * 2, tid.y, 0)).yzw;\n" -" float Y0 = val.x;\n" -" float U = val.y;\n" -" float V = val.z;\n" -" float Y1 = inTex.Load (uint3(tid.x * 2 + 1, tid.y, 0)).y;\n" -"\n" -" outTex[tid.xy] = float4 (Y0, V, Y1, U);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_v210\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint xpos = tid.x * 6;\n" -" float3 val = inTex.Load (uint3 (xpos, tid.y, 0)).yzw;\n" -" float Y0 = val.x;\n" -" float U0 = val.y;\n" -" float V0 = val.z;\n" -" float Y1 = inTex.Load (uint3 (xpos + 1, tid.y, 0)).y;\n" -"\n" -" val = inTex.Load (uint3 (xpos + 2, tid.y, 0)).yzw;\n" -" float Y2 = val.x;\n" -" float U2 = val.y;\n" -" float V2 = val.z;\n" -" float Y3 = inTex.Load (uint3 (xpos + 3, tid.y, 0)).y;\n" -"\n" -" val = inTex.Load (uint3 (xpos + 4, tid.y, 0)).yzw;\n" -" float Y4 = val.x;\n" -" float U4 = val.y;\n" -" float V4 = val.z;\n" -" float Y5 = inTex.Load (uint3 (xpos + 5, tid.y, 0)).y;\n" -"\n" -" xpos = tid.x * 4;\n" -" outTex[uint2(xpos, tid.y)] = float4 (U0, Y0, V0, 0);\n" -" outTex[uint2(xpos + 1, tid.y)] = float4 (Y1, U2, Y2, 0);\n" -" outTex[uint2(xpos + 2, tid.y)] = float4 (V2, Y3, U4, 0);\n" -" outTex[uint2(xpos + 3, tid.y)] = float4 (Y4, V4, Y5, 0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_v308\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).yzw;\n" -" float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).yzw;\n" -" float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).yzw;\n" -" float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).yzw;\n" -"\n" -" outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.x, val0.y, val0.z, val1.x);\n" -" outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.y, val1.z, val2.x, val2.y);\n" -" outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.z, val3.x, val3.y, val3.z);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_IYU2\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).zyw;\n" -" float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).zyw;\n" -" float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).zyw;\n" -" float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).zyw;\n" -"\n" -" outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.x, val0.y, val0.z, val1.x);\n" -" outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.y, val1.z, val2.x, val2.y);\n" -" outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.z, val3.x, val3.y, val3.z);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_AYUV_to_Y410\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -" float Y = val.y;\n" -" float U = val.z;\n" -" float V = val.w;\n" -" float A = val.x;\n" -"\n" -" outTex[tid.xy] = float4 (U, Y, V, A);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGB_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0));\n" -" float R0 = val.r;\n" -" float G0 = val.g;\n" -" float B0 = val.b;\n" -" float R1 = val.a;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0));\n" -" float G1 = val.r;\n" -" float B1 = val.g;\n" -" float R2 = val.b;\n" -" float G2 = val.a;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0));\n" -" float B2 = val.r;\n" -" float R3 = val.g;\n" -" float G3 = val.b;\n" -" float B3 = val.a;\n" -"\n" -" outTex[uint2(tid.x * 4, tid.y)] = float4 (R0, G0, B0, 1.0);\n" -" outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (R1, G1, B1, 1.0);\n" -" outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (R2, G2, B2, 1.0);\n" -" outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (R3, G3, B3, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_BGR_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (uint3 (tid.x * 3, tid.y, 0));\n" -" float B0 = val.r;\n" -" float G0 = val.g;\n" -" float R0 = val.b;\n" -" float B1 = val.a;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 1, tid.y, 0));\n" -" float G1 = val.r;\n" -" float R1 = val.g;\n" -" float B2 = val.b;\n" -" float G2 = val.a;\n" -"\n" -" val = inTex.Load (uint3 (tid.x * 3 + 2, tid.y, 0));\n" -" float R2 = val.r;\n" -" float B3 = val.g;\n" -" float G3 = val.b;\n" -" float R3 = val.a;\n" -"\n" -" outTex[uint2(tid.x * 4, tid.y)] = float4 (R0, G0, B0, 1.0);\n" -" outTex[uint2(tid.x * 4 + 1, tid.y)] = float4 (R1, G1, B1, 1.0);\n" -" outTex[uint2(tid.x * 4 + 2, tid.y)] = float4 (R2, G2, B2, 1.0);\n" -" outTex[uint2(tid.x * 4 + 3, tid.y)] = float4 (R3, G3, B3, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGB16_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint val = inTex.Load (tid);\n" -" float R = float ((val & 0xf800) >> 11) / 31;\n" -" float G = float ((val & 0x7e0) >> 5) / 63;\n" -" float B = float ((val & 0x1f)) / 31;\n" -"\n" -" outTex[tid.xy] = float4 (R, G, B, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_BGR16_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint val = inTex.Load (tid);\n" -" float B = float ((val & 0xf800) >> 11) / 31;\n" -" float G = float ((val & 0x7e0) >> 5) / 63;\n" -" float R = float ((val & 0x1f)) / 31;\n" -"\n" -" outTex[tid.xy] = float4 (R, G, B, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGB15_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint val = inTex.Load (tid);\n" -" uint R = (val & 0x7c00) >> 10;\n" -" uint G = (val & 0x3e0) >> 5;\n" -" uint B = (val & 0x1f);\n" -"\n" -" outTex[tid.xy] = float4 (float3 (R, G, B) / 31, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_BGR15_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint val = inTex.Load (tid);\n" -" uint B = (val & 0x7c00) >> 10;\n" -" uint G = (val & 0x3e0) >> 5;\n" -" uint R = (val & 0x1f);\n" -"\n" -" outTex[tid.xy] = float4 (float3 (R, G, B) / 31, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_r210_to_RGBA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint val = inTex.Load (tid);\n" -" uint val_be = ((val & 0xff) << 24) | ((val & 0xff00) << 8) |\n" -" ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);\n" -" uint R = (val_be >> 20) & 0x3ff;\n" -" uint G = (val_be >> 10) & 0x3ff;\n" -" uint B = val_be & 0x3ff;\n" -"\n" -" outTex[tid.xy] = float4 (float3 (R, G, B) / 1023, 1.0);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_RGB\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).rgb;\n" -" float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).rgb;\n" -" float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).rgb;\n" -" float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).rgb;\n" -"\n" -" outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.r, val0.g, val0.b, val1.r);\n" -" outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.g, val1.b, val2.r, val2.g);\n" -" outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.b, val3.r, val3.g, val3.b);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_BGR\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val0 = inTex.Load (uint3 (tid.x * 4, tid.y, 0)).rgb;\n" -" float3 val1 = inTex.Load (uint3 (tid.x * 4 + 1, tid.y, 0)).rgb;\n" -" float3 val2 = inTex.Load (uint3 (tid.x * 4 + 2, tid.y, 0)).rgb;\n" -" float3 val3 = inTex.Load (uint3 (tid.x * 4 + 3, tid.y, 0)).rgb;\n" -"\n" -" outTex[uint2(tid.x * 3, tid.y)] = float4 (val0.b, val0.g, val0.r, val1.b);\n" -" outTex[uint2(tid.x * 3 + 1, tid.y)] = float4 (val1.g, val1.r, val2.b, val2.g);\n" -" outTex[uint2(tid.x * 3 + 2, tid.y)] = float4 (val2.r, val3.b, val3.g, val3.r);\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_RGB16\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (tid).rgb;\n" -" uint R = val.r * 31;\n" -" uint G = val.g * 63;\n" -" uint B = val.b * 31;\n" -"\n" -" outTex[tid.xy] = (R << 11) | (G << 5) | B;\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_BGR16\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float3 val = inTex.Load (tid).rgb;\n" -" uint R = val.r * 31;\n" -" uint G = val.g * 63;\n" -" uint B = val.b * 31;\n" -"\n" -" outTex[tid.xy] = (B << 11) | (G << 5) | R;\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_RGB15\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint3 val = inTex.Load (tid).rgb * 31;\n" -"\n" -" outTex[tid.xy] = (val.r << 10) | (val.g << 5) | val.b;\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_BGR15\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint3 val = inTex.Load (tid).rgb * 31;\n" -"\n" -" outTex[tid.xy] = (val.b << 10) | (val.g << 5) | val.r;\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_r210\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" uint3 val = inTex.Load (tid).rgb * 1023;\n" -" uint packed = (val.r << 20) | (val.g << 10) | val.b;\n" -" uint packed_be = ((packed & 0xff) << 24) | ((packed & 0xff00) << 8) |\n" -" ((packed & 0xff0000) >> 8) | ((packed & 0xff000000) >> 24);\n" -"\n" -" outTex[tid.xy] = packed_be;\n" -"}\n" -"#endif\n" -"\n" -"#ifdef BUILDING_CSMain_RGBA_to_BGRA\n" -"Texture2D inTex : register(t0);\n" -"RWTexture2D outTex : register(u0);\n" -"\n" -"void Execute (uint3 tid)\n" -"{\n" -" float4 val = inTex.Load (tid);\n" -"\n" -" outTex[tid.xy] = val.bgra;\n" -"}\n" -"#endif\n" -"\n" -"[numthreads(8, 8, 1)]\n" -"void ENTRY_POINT (uint3 tid : SV_DispatchThreadID)\n" -"{\n" -" Execute (tid);\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/PSMain_converter.hlsl b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/PSMain_converter.hlsl deleted file mode 100644 index e59096fa95..0000000000 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/PSMain_converter.hlsl +++ /dev/null @@ -1,2253 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -cbuffer PsAlphaFactor : register(b1) -{ - float alphaFactor; -}; - -struct PSColorSpace -{ - float3 CoeffX; - float3 CoeffY; - float3 CoeffZ; - float3 Offset; - float3 Min; - float3 Max; - float padding; -}; - -cbuffer PsConstBuffer : register(b2) -{ - PSColorSpace preCoeff; - PSColorSpace postCoeff; - PSColorSpace primariesCoeff; -}; - -Texture2D shaderTexture_0 : register(t0); -Texture2D shaderTexture_1 : register(t1); -Texture2D shaderTexture_2 : register(t2); -Texture2D shaderTexture_3 : register(t3); -Texture1D gammaDecLUT : register(t4); -Texture1D gammaEncLUT: register(t5); - -SamplerState samplerState : register(s0); -SamplerState lutSamplerState : register(s1); - -struct PS_INPUT -{ - float4 Position: SV_POSITION; - float2 Texture: TEXCOORD; -}; - -struct PS_OUTPUT_LUMA -{ - float4 Plane0: SV_TARGET0; -}; - -struct PS_OUTPUT_CHROMA -{ - float4 Plane0: SV_TARGET0; -}; - -struct PS_OUTPUT_CHROMA_PLANAR -{ - float4 Plane0: SV_TARGET0; - float4 Plane1: SV_TARGET1; -}; - -struct PS_OUTPUT_PLANAR -{ - float4 Plane0: SV_TARGET0; - float4 Plane1: SV_TARGET1; - float4 Plane2: SV_TARGET2; -}; - -struct PS_OUTPUT_PLANAR_FULL -{ - float4 Plane0: SV_TARGET0; - float4 Plane1: SV_TARGET1; - float4 Plane2: SV_TARGET2; - float4 Plane3: SV_TARGET3; -}; - -struct PS_OUTPUT_PACKED -{ - float4 Plane0: SV_TARGET0; -}; - -float4 DoAlphaPremul (float4 sample) -{ - float4 premul_tex; - premul_tex.rgb = sample.rgb * sample.a; - premul_tex.a = sample.a; - return premul_tex; -} - -float4 DoAlphaUnpremul (float4 sample) -{ - float4 unpremul_tex; - if (sample.a == 0 || sample.a == 1) - return sample; - - unpremul_tex.rgb = saturate (sample.rgb / sample.a); - unpremul_tex.a = sample.a; - return unpremul_tex; -} - -interface ISampler -{ - float4 Execute (float2 uv); -}; - -class SamplerGRAY : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.y = 0.5; - sample.z = 0.5; - sample.a = 1.0; - return sample; - } -}; - -class SamplerNV12 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.yz = shaderTexture_1.Sample(samplerState, uv).xy; - sample.a = 1.0; - return sample; - } -}; - -class SamplerNV21 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.yz = shaderTexture_1.Sample(samplerState, uv).yx; - sample.a = 1.0; - return sample; - } -}; - -class SamplerI420 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.y = shaderTexture_1.Sample(samplerState, uv).x; - sample.z = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = 1.0; - return sample; - } -}; - -class SamplerYV12 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.z = shaderTexture_1.Sample(samplerState, uv).x; - sample.y = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = 1.0; - return sample; - } -}; - -class SamplerI420_10 : ISampler -{ - float4 Execute (float2 uv) - { - float3 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.y = shaderTexture_1.Sample(samplerState, uv).x; - sample.z = shaderTexture_2.Sample(samplerState, uv).x; - return float4 (saturate (sample * 64.0), 1.0); - } -}; - -class SamplerI420_12 : ISampler -{ - float4 Execute (float2 uv) - { - float3 sample; - sample.x = shaderTexture_0.Sample(samplerState, uv).x; - sample.y = shaderTexture_1.Sample(samplerState, uv).x; - sample.z = shaderTexture_2.Sample(samplerState, uv).x; - return float4 (saturate (sample * 16.0), 1.0); - } -}; - -class SamplerVUYA : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).zyxw; - } -}; - -class SamplerVUYAPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).zyxw); - } -}; - -class SamplerY410 : ISampler -{ - float4 Execute (float2 uv) - { - return float4 (shaderTexture_0.Sample(samplerState, uv).yxz, 1.0); - } -}; - -class SamplerY412 : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).grba; - } -}; - -class SamplerY412Premul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).grba); - } -}; - -class SamplerAYUV : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).yzwx; - } -}; - -class SamplerAYUVPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).yzwx); - } -}; - -class SamplerRGBA : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv); - } -}; - -class SamplerRGBAPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv)); - } -}; - -class SamplerRGBx : ISampler -{ - float4 Execute (float2 uv) - { - return float4 (shaderTexture_0.Sample(samplerState, uv).rgb, 1.0); - } -}; - -class SamplerxRGB : ISampler -{ - float4 Execute (float2 uv) - { - return float4 (shaderTexture_0.Sample(samplerState, uv).gba, 1.0); - } -}; - -class SamplerARGB : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).gbar; - } -}; - -class SamplerARGBPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).gbar); - } -}; - -class SamplerxBGR : ISampler -{ - float4 Execute (float2 uv) - { - return float4 (shaderTexture_0.Sample(samplerState, uv).abg, 1.0); - } -}; - -class SamplerABGR : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).abgr; - } -}; - -class SamplerABGRPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).abgr); - } -}; - -class SamplerBGR10A2 : ISampler -{ - float4 Execute (float2 uv) - { - return float4 (shaderTexture_0.Sample(samplerState, uv).zyx, 1.0); - } -}; - -class SamplerBGRA64 : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).bgra; - } -}; - -class SamplerBGRA64Premul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).bgra); - } -}; - -class SamplerGBR : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = 1.0; - return sample; - } -}; - -class SamplerGBR_10 : ISampler -{ - float4 Execute (float2 uv) - { - float3 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - return float4 (saturate (sample * 64.0), 1.0); - } -}; - -class SamplerGBR_12 : ISampler -{ - float4 Execute (float2 uv) - { - float3 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - return float4 (saturate (sample * 16.0), 1.0); - } -}; - -class SamplerGBRA : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return sample; - } -}; - -class SamplerGBRAPremul : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return DoAlphaUnpremul (sample); - } -}; - -class SamplerGBRA_10 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return saturate (sample * 64.0); - } -}; - -class SamplerGBRAPremul_10 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return DoAlphaUnpremul (saturate (sample * 64.0)); - } -}; - -class SamplerGBRA_12 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return saturate (sample * 16.0); - } -}; - -class SamplerGBRAPremul_12 : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.g = shaderTexture_0.Sample(samplerState, uv).x; - sample.b = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = shaderTexture_3.Sample(samplerState, uv).x; - return DoAlphaUnpremul (saturate (sample * 16.0)); - } -}; - -class SamplerRGBP : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.r = shaderTexture_0.Sample(samplerState, uv).x; - sample.g = shaderTexture_1.Sample(samplerState, uv).x; - sample.b = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = 1.0; - return sample; - } -}; - -class SamplerBGRP : ISampler -{ - float4 Execute (float2 uv) - { - float4 sample; - sample.b = shaderTexture_0.Sample(samplerState, uv).x; - sample.g = shaderTexture_1.Sample(samplerState, uv).x; - sample.r = shaderTexture_2.Sample(samplerState, uv).x; - sample.a = 1.0; - return sample; - } -}; - -class SamplerRBGA : ISampler -{ - float4 Execute (float2 uv) - { - return shaderTexture_0.Sample(samplerState, uv).rbga; - } -}; - -class SamplerRBGAPremul : ISampler -{ - float4 Execute (float2 uv) - { - return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).rbga); - } -}; - -interface IConverter -{ - float4 Execute (float4 sample); -}; - -class ConverterIdentity : IConverter -{ - float4 Execute (float4 sample) - { - return sample; - } -}; - -class ConverterRange : IConverter -{ - float4 Execute (float4 sample) - { - float3 out_space; - out_space.x = postCoeff.CoeffX.x * sample.x; - out_space.y = postCoeff.CoeffY.y * sample.y; - out_space.z = postCoeff.CoeffZ.z * sample.z; - out_space += postCoeff.Offset; - return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a); - } -}; - -class ConverterSimple : IConverter -{ - float4 Execute (float4 sample) - { - float3 out_space; - out_space.x = dot (postCoeff.CoeffX, sample.xyz); - out_space.y = dot (postCoeff.CoeffY, sample.xyz); - out_space.z = dot (postCoeff.CoeffZ, sample.xyz); - out_space += postCoeff.Offset; - return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a); - } -}; - -class ConverterGamma : IConverter -{ - float4 Execute (float4 sample) - { - float3 out_space; - out_space.x = dot (preCoeff.CoeffX, sample.xyz); - out_space.y = dot (preCoeff.CoeffY, sample.xyz); - out_space.z = dot (preCoeff.CoeffZ, sample.xyz); - out_space += preCoeff.Offset; - out_space = clamp (out_space, preCoeff.Min, preCoeff.Max); - - out_space.x = gammaDecLUT.Sample (lutSamplerState, out_space.x); - out_space.y = gammaDecLUT.Sample (lutSamplerState, out_space.y); - out_space.z = gammaDecLUT.Sample (lutSamplerState, out_space.z); - - out_space.x = gammaEncLUT.Sample (lutSamplerState, out_space.x); - out_space.y = gammaEncLUT.Sample (lutSamplerState, out_space.y); - out_space.z = gammaEncLUT.Sample (lutSamplerState, out_space.z); - - out_space.x = dot (postCoeff.CoeffX, out_space); - out_space.y = dot (postCoeff.CoeffY, out_space); - out_space.z = dot (postCoeff.CoeffZ, out_space); - out_space += postCoeff.Offset; - return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a); - } -}; - -class ConverterPrimary : IConverter -{ - float4 Execute (float4 sample) - { - float3 out_space; - float3 tmp; - out_space.x = dot (preCoeff.CoeffX, sample.xyz); - out_space.y = dot (preCoeff.CoeffY, sample.xyz); - out_space.z = dot (preCoeff.CoeffZ, sample.xyz); - out_space += preCoeff.Offset; - out_space = clamp (out_space, preCoeff.Min, preCoeff.Max); - - out_space.x = gammaDecLUT.Sample (lutSamplerState, out_space.x); - out_space.y = gammaDecLUT.Sample (lutSamplerState, out_space.y); - out_space.z = gammaDecLUT.Sample (lutSamplerState, out_space.z); - - tmp.x = dot (primariesCoeff.CoeffX, out_space); - tmp.y = dot (primariesCoeff.CoeffY, out_space); - tmp.z = dot (primariesCoeff.CoeffZ, out_space); - - out_space.x = gammaEncLUT.Sample (lutSamplerState, tmp.x); - out_space.y = gammaEncLUT.Sample (lutSamplerState, tmp.y); - out_space.z = gammaEncLUT.Sample (lutSamplerState, tmp.z); - - out_space.x = dot (postCoeff.CoeffX, out_space); - out_space.y = dot (postCoeff.CoeffY, out_space); - out_space.z = dot (postCoeff.CoeffZ, out_space); - out_space += postCoeff.Offset; - return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a); - } -}; - -float UnormTo10bit (float sample) -{ - return sample * 1023.0 / 65535.0; -} - -float2 UnormTo10bit (float2 sample) -{ - return sample * 1023.0 / 65535.0; -} - -float3 UnormTo10bit (float3 sample) -{ - return sample * 1023.0 / 65535.0; -} - -float4 UnormTo10bit (float4 sample) -{ - return sample * 1023.0 / 65535.0; -} - -float UnormTo12bit (float sample) -{ - return sample * 4095.0 / 65535.0; -} - -float2 UnormTo12bit (float2 sample) -{ - return sample * 4095.0 / 65535.0; -} - -float3 UnormTo12bit (float3 sample) -{ - return sample * 4095.0 / 65535.0; -} - -float4 UnormTo12bit (float4 sample) -{ - return sample * 4095.0 / 65535.0; -} - -interface IOutputLuma -{ - PS_OUTPUT_LUMA Build (float4 sample); -}; - -class OutputLuma : IOutputLuma -{ - PS_OUTPUT_LUMA Build (float4 sample) - { - PS_OUTPUT_LUMA output; - output.Plane0 = float4 (sample.x, 0, 0, 0); - return output; - } -}; - -class OutputLuma_10 : IOutputLuma -{ - PS_OUTPUT_LUMA Build (float4 sample) - { - PS_OUTPUT_LUMA output; - output.Plane0 = float4 (UnormTo10bit (sample.x), 0, 0, 0); - return output; - } -}; - -class OutputLuma_12 : IOutputLuma -{ - PS_OUTPUT_LUMA Build (float4 sample) - { - PS_OUTPUT_LUMA output; - output.Plane0 = float4 (UnormTo12bit (sample.x), 0, 0, 0); - return output; - } -}; - -interface IOutputChroma -{ - PS_OUTPUT_CHROMA Build (float4 sample); -}; - -class OutputChromaNV12 : IOutputChroma -{ - PS_OUTPUT_CHROMA Build (float4 sample) - { - PS_OUTPUT_CHROMA output; - output.Plane0 = float4 (sample.yz, 0, 0); - return output; - } -}; - -class OutputChromaNV21 : IOutputChroma -{ - PS_OUTPUT_CHROMA Build (float4 sample) - { - PS_OUTPUT_CHROMA output; - output.Plane0 = float4 (sample.zy, 0, 0); - return output; - } -}; - -interface IOutputChromaPlanar -{ PS_OUTPUT_CHROMA_PLANAR Build (float4 sample); -}; - -class OutputChromaI420 : IOutputChromaPlanar -{ - PS_OUTPUT_CHROMA_PLANAR Build (float4 sample) - { - PS_OUTPUT_CHROMA_PLANAR output; - output.Plane0 = float4 (sample.y, 0, 0, 0); - output.Plane1 = float4 (sample.z, 0, 0, 0); - return output; - } -}; - -class OutputChromaYV12 : IOutputChromaPlanar -{ - PS_OUTPUT_CHROMA_PLANAR Build (float4 sample) - { - PS_OUTPUT_CHROMA_PLANAR output; - output.Plane0 = float4 (sample.z, 0, 0, 0); - output.Plane1 = float4 (sample.y, 0, 0, 0); - return output; - } -}; - -class OutputChromaI420_10 : IOutputChromaPlanar -{ - PS_OUTPUT_CHROMA_PLANAR Build (float4 sample) - { - PS_OUTPUT_CHROMA_PLANAR output; - float2 scaled = UnormTo10bit (sample.yz); - output.Plane0 = float4 (scaled.x, 0, 0, 0); - output.Plane1 = float4 (scaled.y, 0, 0, 0); - return output; - } -}; - -class OutputChromaI420_12 : IOutputChromaPlanar -{ - PS_OUTPUT_CHROMA_PLANAR Build (float4 sample) - { - PS_OUTPUT_CHROMA_PLANAR output; - float2 scaled = UnormTo12bit (sample.yz); - output.Plane0 = float4 (scaled.x, 0, 0, 0); - output.Plane1 = float4 (scaled.y, 0, 0, 0); - return output; - } -}; - -interface IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample); -}; - -class OutputY444 : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - output.Plane0 = float4 (sample.x, 0, 0, 0); - output.Plane1 = float4 (sample.y, 0, 0, 0); - output.Plane2 = float4 (sample.z, 0, 0, 0); - return output; - } -}; - -class OutputY444_10 : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - float3 scaled = UnormTo10bit (sample.xyz); - output.Plane0 = float4 (scaled.x, 0, 0, 0); - output.Plane1 = float4 (scaled.y, 0, 0, 0); - output.Plane2 = float4 (scaled.z, 0, 0, 0); - return output; - } -}; - -class OutputY444_12 : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - float3 scaled = UnormTo12bit (sample.xyz); - output.Plane0 = float4 (scaled.x, 0, 0, 0); - output.Plane1 = float4 (scaled.y, 0, 0, 0); - output.Plane2 = float4 (scaled.z, 0, 0, 0); - return output; - } -}; - -class OutputGBR : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - output.Plane0 = float4 (sample.g, 0, 0, 0); - output.Plane1 = float4 (sample.b, 0, 0, 0); - output.Plane2 = float4 (sample.r, 0, 0, 0); - return output; - } -}; - -class OutputGBR_10 : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - float3 scaled = UnormTo10bit (sample.rgb); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - return output; - } -}; - -class OutputGBR_12 : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - float3 scaled = UnormTo12bit (sample.rgb); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - return output; - } -}; - -class OutputRGBP : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - output.Plane0 = float4 (sample.r, 0, 0, 0); - output.Plane1 = float4 (sample.g, 0, 0, 0); - output.Plane2 = float4 (sample.b, 0, 0, 0); - return output; - } -}; - -class OutputBGRP : IOutputPlanar -{ - PS_OUTPUT_PLANAR Build (float4 sample) - { - PS_OUTPUT_PLANAR output; - output.Plane0 = float4 (sample.b, 0, 0, 0); - output.Plane1 = float4 (sample.g, 0, 0, 0); - output.Plane2 = float4 (sample.r, 0, 0, 0); - return output; - } -}; - -interface IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample); -}; - -class OutputGBRA : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - output.Plane0 = float4 (sample.g, 0, 0, 0); - output.Plane1 = float4 (sample.b, 0, 0, 0); - output.Plane2 = float4 (sample.r, 0, 0, 0); - output.Plane3 = float4 (sample.a * alphaFactor, 0, 0, 0); - return output; - } -}; - -class OutputGBRAPremul : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - float4 premul; - sample.a *= alphaFactor; - premul = DoAlphaPremul (sample); - output.Plane0 = float4 (premul.g, 0, 0, 0); - output.Plane1 = float4 (premul.b, 0, 0, 0); - output.Plane2 = float4 (premul.r, 0, 0, 0); - output.Plane3 = float4 (premul.a, 0, 0, 0); - return output; - } -}; - -class OutputGBRA_10 : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - float4 scaled; - sample.a *= alphaFactor; - scaled = UnormTo10bit (sample); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - output.Plane3 = float4 (scaled.a, 0, 0, 0); - return output; - } -}; - -class OutputGBRAPremul_10 : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - float4 scaled; - sample.a *= alphaFactor; - scaled = UnormTo10bit (DoAlphaPremul (sample)); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - output.Plane3 = float4 (scaled.a, 0, 0, 0); - return output; - } -}; - -class OutputGBRA_12 : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - float4 scaled; - sample.a *= alphaFactor; - scaled = UnormTo12bit (sample); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - output.Plane3 = float4 (scaled.a, 0, 0, 0); - return output; - } -}; - -class OutputGBRAPremul_12 : IOutputPlanarFull -{ - PS_OUTPUT_PLANAR_FULL Build (float4 sample) - { - PS_OUTPUT_PLANAR_FULL output; - float4 scaled; - sample.a *= alphaFactor; - scaled = UnormTo12bit (DoAlphaPremul (sample)); - output.Plane0 = float4 (scaled.g, 0, 0, 0); - output.Plane1 = float4 (scaled.b, 0, 0, 0); - output.Plane2 = float4 (scaled.r, 0, 0, 0); - output.Plane3 = float4 (scaled.a, 0, 0, 0); - return output; - } -}; - -interface IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample); -}; - -class OutputRGBA : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = float4 (sample.rgb, sample.a * alphaFactor); - return output; - } -}; - -class OutputRGBAPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = DoAlphaPremul (sample); - return output; - } -}; - -class OutputRGBx : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = float4 (sample.rgb, 1.0); - return output; - } -}; - -class OutputxRGB : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = float4 (0.0, sample.rgb); - return output; - } -}; - -class OutputARGB : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = sample.argb; - return output; - } -}; - -class OutputARGBPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = DoAlphaPremul (sample).argb; - return output; - } -}; - -class OutputxBGR : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = float4 (0.0, sample.bgr); - return output; - } -}; - -class OutputABGR : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = sample.abgr; - return output; - } -}; - -class OutputABGRPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - output.Plane0 = DoAlphaPremul (sample.abgr); - return output; - } -}; - -class OutputVUYA : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = sample.zyxw; - return output; - } -}; - -class OutputVUYAPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = DoAlphaPremul (sample).zyxw; - return output; - } -}; - -class OutputAYUV : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = sample.wxyz; - return output; - } -}; - -class OutputAYUVPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = DoAlphaPremul (sample).wxyz; - return output; - } -}; - -class OutputRBGA : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = sample.rbga; - return output; - } -}; - -class OutputRBGAPremul : IOutputPacked -{ - PS_OUTPUT_PACKED Build (float4 sample) - { - PS_OUTPUT_PACKED output; - sample.a *= alphaFactor; - output.Plane0 = DoAlphaPremul (sample).rbga; - return output; - } -}; - -OUTPUT_TYPE ENTRY_POINT (PS_INPUT input) -{ - SAMPLER g_sampler; - CONVERTER g_converter; - OUTPUT_BUILDER g_builder; - return g_builder.Build (g_converter.Execute (g_sampler.Execute (input.Texture))); -} -#else /* BUILDING_HLSL */ -static const char g_PSMain_converter_str[] = -"cbuffer PsAlphaFactor : register(b1)\n" -"{\n" -" float alphaFactor;\n" -"};\n" -"\n" -"struct PSColorSpace\n" -"{\n" -" float3 CoeffX;\n" -" float3 CoeffY;\n" -" float3 CoeffZ;\n" -" float3 Offset;\n" -" float3 Min;\n" -" float3 Max;\n" -" float padding;\n" -"};\n" -"\n" -"cbuffer PsConstBuffer : register(b2)\n" -"{\n" -" PSColorSpace preCoeff;\n" -" PSColorSpace postCoeff;\n" -" PSColorSpace primariesCoeff;\n" -"};\n" -"\n" -"Texture2D shaderTexture_0 : register(t0);\n" -"Texture2D shaderTexture_1 : register(t1);\n" -"Texture2D shaderTexture_2 : register(t2);\n" -"Texture2D shaderTexture_3 : register(t3);\n" -"Texture1D gammaDecLUT : register(t4);\n" -"Texture1D gammaEncLUT: register(t5);\n" -"\n" -"SamplerState samplerState : register(s0);\n" -"SamplerState lutSamplerState : register(s1);\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position: SV_POSITION;\n" -" float2 Texture: TEXCOORD;\n" -"};\n" -"\n" -"struct PS_OUTPUT_LUMA\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -"};\n" -"\n" -"struct PS_OUTPUT_CHROMA\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -"};\n" -"\n" -"struct PS_OUTPUT_CHROMA_PLANAR\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -" float4 Plane1: SV_TARGET1;\n" -"};\n" -"\n" -"struct PS_OUTPUT_PLANAR\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -" float4 Plane1: SV_TARGET1;\n" -" float4 Plane2: SV_TARGET2;\n" -"};\n" -"\n" -"struct PS_OUTPUT_PLANAR_FULL\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -" float4 Plane1: SV_TARGET1;\n" -" float4 Plane2: SV_TARGET2;\n" -" float4 Plane3: SV_TARGET3;\n" -"};\n" -"\n" -"struct PS_OUTPUT_PACKED\n" -"{\n" -" float4 Plane0: SV_TARGET0;\n" -"};\n" -"\n" -"float4 DoAlphaPremul (float4 sample)\n" -"{\n" -" float4 premul_tex;\n" -" premul_tex.rgb = sample.rgb * sample.a;\n" -" premul_tex.a = sample.a;\n" -" return premul_tex;\n" -"}\n" -"\n" -"float4 DoAlphaUnpremul (float4 sample)\n" -"{\n" -" float4 unpremul_tex;\n" -" if (sample.a == 0 || sample.a == 1)\n" -" return sample;\n" -"\n" -" unpremul_tex.rgb = saturate (sample.rgb / sample.a);\n" -" unpremul_tex.a = sample.a;\n" -" return unpremul_tex;\n" -"}\n" -"\n" -"interface ISampler\n" -"{\n" -" float4 Execute (float2 uv);\n" -"};\n" -"\n" -"class SamplerGRAY : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.y = 0.5;\n" -" sample.z = 0.5;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerNV12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.yz = shaderTexture_1.Sample(samplerState, uv).xy;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerNV21 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.yz = shaderTexture_1.Sample(samplerState, uv).yx;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerI420 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.y = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.z = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerYV12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.z = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.y = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerI420_10 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float3 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.y = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.z = shaderTexture_2.Sample(samplerState, uv).x;\n" -" return float4 (saturate (sample * 64.0), 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerI420_12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float3 sample;\n" -" sample.x = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.y = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.z = shaderTexture_2.Sample(samplerState, uv).x;\n" -" return float4 (saturate (sample * 16.0), 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerVUYA : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).zyxw;\n" -" }\n" -"};\n" -"\n" -"class SamplerVUYAPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).zyxw);\n" -" }\n" -"};\n" -"\n" -"class SamplerY410 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return float4 (shaderTexture_0.Sample(samplerState, uv).yxz, 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerY412 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).grba;\n" -" }\n" -"};\n" -"\n" -"class SamplerY412Premul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).grba);\n" -" }\n" -"};\n" -"\n" -"class SamplerAYUV : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).yzwx;\n" -" }\n" -"};\n" -"\n" -"class SamplerAYUVPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).yzwx);\n" -" }\n" -"};\n" -"\n" -"class SamplerRGBA : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv);\n" -" }\n" -"};\n" -"\n" -"class SamplerRGBAPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv));\n" -" }\n" -"};\n" -"\n" -"class SamplerRGBx : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return float4 (shaderTexture_0.Sample(samplerState, uv).rgb, 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerxRGB : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return float4 (shaderTexture_0.Sample(samplerState, uv).gba, 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerARGB : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).gbar;\n" -" }\n" -"};\n" -"\n" -"class SamplerARGBPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).gbar);\n" -" }\n" -"};\n" -"\n" -"class SamplerxBGR : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return float4 (shaderTexture_0.Sample(samplerState, uv).abg, 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerABGR : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).abgr;\n" -" }\n" -"};\n" -"\n" -"class SamplerABGRPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).abgr);\n" -" }\n" -"};\n" -"\n" -"class SamplerBGR10A2 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return float4 (shaderTexture_0.Sample(samplerState, uv).zyx, 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerBGRA64 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).bgra;\n" -" }\n" -"};\n" -"\n" -"class SamplerBGRA64Premul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).bgra);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBR : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerGBR_10 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float3 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" return float4 (saturate (sample * 64.0), 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBR_12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float3 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" return float4 (saturate (sample * 16.0), 1.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRA : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRAPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return DoAlphaUnpremul (sample);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRA_10 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return saturate (sample * 64.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRAPremul_10 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return DoAlphaUnpremul (saturate (sample * 64.0));\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRA_12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return saturate (sample * 16.0);\n" -" }\n" -"};\n" -"\n" -"class SamplerGBRAPremul_12 : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.g = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = shaderTexture_3.Sample(samplerState, uv).x;\n" -" return DoAlphaUnpremul (saturate (sample * 16.0));\n" -" }\n" -"};\n" -"\n" -"class SamplerRGBP : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.r = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.g = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.b = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerBGRP : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" float4 sample;\n" -" sample.b = shaderTexture_0.Sample(samplerState, uv).x;\n" -" sample.g = shaderTexture_1.Sample(samplerState, uv).x;\n" -" sample.r = shaderTexture_2.Sample(samplerState, uv).x;\n" -" sample.a = 1.0;\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class SamplerRBGA : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return shaderTexture_0.Sample(samplerState, uv).rbga;\n" -" }\n" -"};\n" -"\n" -"class SamplerRBGAPremul : ISampler\n" -"{\n" -" float4 Execute (float2 uv)\n" -" {\n" -" return DoAlphaUnpremul (shaderTexture_0.Sample(samplerState, uv).rbga);\n" -" }\n" -"};\n" -"\n" -"interface IConverter\n" -"{\n" -" float4 Execute (float4 sample);\n" -"};\n" -"\n" -"class ConverterIdentity : IConverter\n" -"{\n" -" float4 Execute (float4 sample)\n" -" {\n" -" return sample;\n" -" }\n" -"};\n" -"\n" -"class ConverterRange : IConverter\n" -"{\n" -" float4 Execute (float4 sample)\n" -" {\n" -" float3 out_space;\n" -" out_space.x = postCoeff.CoeffX.x * sample.x;\n" -" out_space.y = postCoeff.CoeffY.y * sample.y;\n" -" out_space.z = postCoeff.CoeffZ.z * sample.z;\n" -" out_space += postCoeff.Offset;\n" -" return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a);\n" -" }\n" -"};\n" -"\n" -"class ConverterSimple : IConverter\n" -"{\n" -" float4 Execute (float4 sample)\n" -" {\n" -" float3 out_space;\n" -" out_space.x = dot (postCoeff.CoeffX, sample.xyz);\n" -" out_space.y = dot (postCoeff.CoeffY, sample.xyz);\n" -" out_space.z = dot (postCoeff.CoeffZ, sample.xyz);\n" -" out_space += postCoeff.Offset;\n" -" return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a);\n" -" }\n" -"};\n" -"\n" -"class ConverterGamma : IConverter\n" -"{\n" -" float4 Execute (float4 sample)\n" -" {\n" -" float3 out_space;\n" -" out_space.x = dot (preCoeff.CoeffX, sample.xyz);\n" -" out_space.y = dot (preCoeff.CoeffY, sample.xyz);\n" -" out_space.z = dot (preCoeff.CoeffZ, sample.xyz);\n" -" out_space += preCoeff.Offset;\n" -" out_space = clamp (out_space, preCoeff.Min, preCoeff.Max);\n" -"\n" -" out_space.x = gammaDecLUT.Sample (lutSamplerState, out_space.x);\n" -" out_space.y = gammaDecLUT.Sample (lutSamplerState, out_space.y);\n" -" out_space.z = gammaDecLUT.Sample (lutSamplerState, out_space.z);\n" -"\n" -" out_space.x = gammaEncLUT.Sample (lutSamplerState, out_space.x);\n" -" out_space.y = gammaEncLUT.Sample (lutSamplerState, out_space.y);\n" -" out_space.z = gammaEncLUT.Sample (lutSamplerState, out_space.z);\n" -"\n" -" out_space.x = dot (postCoeff.CoeffX, out_space);\n" -" out_space.y = dot (postCoeff.CoeffY, out_space);\n" -" out_space.z = dot (postCoeff.CoeffZ, out_space);\n" -" out_space += postCoeff.Offset;\n" -" return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a);\n" -" }\n" -"};\n" -"\n" -"class ConverterPrimary : IConverter\n" -"{\n" -" float4 Execute (float4 sample)\n" -" {\n" -" float3 out_space;\n" -" float3 tmp;\n" -" out_space.x = dot (preCoeff.CoeffX, sample.xyz);\n" -" out_space.y = dot (preCoeff.CoeffY, sample.xyz);\n" -" out_space.z = dot (preCoeff.CoeffZ, sample.xyz);\n" -" out_space += preCoeff.Offset;\n" -" out_space = clamp (out_space, preCoeff.Min, preCoeff.Max);\n" -"\n" -" out_space.x = gammaDecLUT.Sample (lutSamplerState, out_space.x);\n" -" out_space.y = gammaDecLUT.Sample (lutSamplerState, out_space.y);\n" -" out_space.z = gammaDecLUT.Sample (lutSamplerState, out_space.z);\n" -"\n" -" tmp.x = dot (primariesCoeff.CoeffX, out_space);\n" -" tmp.y = dot (primariesCoeff.CoeffY, out_space);\n" -" tmp.z = dot (primariesCoeff.CoeffZ, out_space);\n" -"\n" -" out_space.x = gammaEncLUT.Sample (lutSamplerState, tmp.x);\n" -" out_space.y = gammaEncLUT.Sample (lutSamplerState, tmp.y);\n" -" out_space.z = gammaEncLUT.Sample (lutSamplerState, tmp.z);\n" -"\n" -" out_space.x = dot (postCoeff.CoeffX, out_space);\n" -" out_space.y = dot (postCoeff.CoeffY, out_space);\n" -" out_space.z = dot (postCoeff.CoeffZ, out_space);\n" -" out_space += postCoeff.Offset;\n" -" return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a);\n" -" }\n" -"};\n" -"\n" -"float UnormTo10bit (float sample)\n" -"{\n" -" return sample * 1023.0 / 65535.0;\n" -"}\n" -"\n" -"float2 UnormTo10bit (float2 sample)\n" -"{\n" -" return sample * 1023.0 / 65535.0;\n" -"}\n" -"\n" -"float3 UnormTo10bit (float3 sample)\n" -"{\n" -" return sample * 1023.0 / 65535.0;\n" -"}\n" -"\n" -"float4 UnormTo10bit (float4 sample)\n" -"{\n" -" return sample * 1023.0 / 65535.0;\n" -"}\n" -"\n" -"float UnormTo12bit (float sample)\n" -"{\n" -" return sample * 4095.0 / 65535.0;\n" -"}\n" -"\n" -"float2 UnormTo12bit (float2 sample)\n" -"{\n" -" return sample * 4095.0 / 65535.0;\n" -"}\n" -"\n" -"float3 UnormTo12bit (float3 sample)\n" -"{\n" -" return sample * 4095.0 / 65535.0;\n" -"}\n" -"\n" -"float4 UnormTo12bit (float4 sample)\n" -"{\n" -" return sample * 4095.0 / 65535.0;\n" -"}\n" -"\n" -"interface IOutputLuma\n" -"{\n" -" PS_OUTPUT_LUMA Build (float4 sample);\n" -"};\n" -"\n" -"class OutputLuma : IOutputLuma\n" -"{\n" -" PS_OUTPUT_LUMA Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_LUMA output;\n" -" output.Plane0 = float4 (sample.x, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputLuma_10 : IOutputLuma\n" -"{\n" -" PS_OUTPUT_LUMA Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_LUMA output;\n" -" output.Plane0 = float4 (UnormTo10bit (sample.x), 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputLuma_12 : IOutputLuma\n" -"{\n" -" PS_OUTPUT_LUMA Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_LUMA output;\n" -" output.Plane0 = float4 (UnormTo12bit (sample.x), 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"interface IOutputChroma\n" -"{\n" -" PS_OUTPUT_CHROMA Build (float4 sample);\n" -"};\n" -"\n" -"class OutputChromaNV12 : IOutputChroma\n" -"{\n" -" PS_OUTPUT_CHROMA Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA output;\n" -" output.Plane0 = float4 (sample.yz, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputChromaNV21 : IOutputChroma\n" -"{\n" -" PS_OUTPUT_CHROMA Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA output;\n" -" output.Plane0 = float4 (sample.zy, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"interface IOutputChromaPlanar\n" -"{ PS_OUTPUT_CHROMA_PLANAR Build (float4 sample);\n" -"};\n" -"\n" -"class OutputChromaI420 : IOutputChromaPlanar\n" -"{\n" -" PS_OUTPUT_CHROMA_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA_PLANAR output;\n" -" output.Plane0 = float4 (sample.y, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.z, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputChromaYV12 : IOutputChromaPlanar\n" -"{\n" -" PS_OUTPUT_CHROMA_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA_PLANAR output;\n" -" output.Plane0 = float4 (sample.z, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.y, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputChromaI420_10 : IOutputChromaPlanar\n" -"{\n" -" PS_OUTPUT_CHROMA_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA_PLANAR output;\n" -" float2 scaled = UnormTo10bit (sample.yz);\n" -" output.Plane0 = float4 (scaled.x, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.y, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputChromaI420_12 : IOutputChromaPlanar\n" -"{\n" -" PS_OUTPUT_CHROMA_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_CHROMA_PLANAR output;\n" -" float2 scaled = UnormTo12bit (sample.yz);\n" -" output.Plane0 = float4 (scaled.x, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.y, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"interface IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample);\n" -"};\n" -"\n" -"class OutputY444 : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" output.Plane0 = float4 (sample.x, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.y, 0, 0, 0);\n" -" output.Plane2 = float4 (sample.z, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputY444_10 : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" float3 scaled = UnormTo10bit (sample.xyz);\n" -" output.Plane0 = float4 (scaled.x, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.y, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.z, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputY444_12 : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" float3 scaled = UnormTo12bit (sample.xyz);\n" -" output.Plane0 = float4 (scaled.x, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.y, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.z, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBR : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" output.Plane0 = float4 (sample.g, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.b, 0, 0, 0);\n" -" output.Plane2 = float4 (sample.r, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBR_10 : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" float3 scaled = UnormTo10bit (sample.rgb);\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBR_12 : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" float3 scaled = UnormTo12bit (sample.rgb);\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputRGBP : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" output.Plane0 = float4 (sample.r, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.g, 0, 0, 0);\n" -" output.Plane2 = float4 (sample.b, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputBGRP : IOutputPlanar\n" -"{\n" -" PS_OUTPUT_PLANAR Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR output;\n" -" output.Plane0 = float4 (sample.b, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.g, 0, 0, 0);\n" -" output.Plane2 = float4 (sample.r, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"interface IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample);\n" -"};\n" -"\n" -"class OutputGBRA : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" output.Plane0 = float4 (sample.g, 0, 0, 0);\n" -" output.Plane1 = float4 (sample.b, 0, 0, 0);\n" -" output.Plane2 = float4 (sample.r, 0, 0, 0);\n" -" output.Plane3 = float4 (sample.a * alphaFactor, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBRAPremul : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" float4 premul;\n" -" sample.a *= alphaFactor;\n" -" premul = DoAlphaPremul (sample);\n" -" output.Plane0 = float4 (premul.g, 0, 0, 0);\n" -" output.Plane1 = float4 (premul.b, 0, 0, 0);\n" -" output.Plane2 = float4 (premul.r, 0, 0, 0);\n" -" output.Plane3 = float4 (premul.a, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBRA_10 : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" float4 scaled;\n" -" sample.a *= alphaFactor;\n" -" scaled = UnormTo10bit (sample);\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" output.Plane3 = float4 (scaled.a, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBRAPremul_10 : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" float4 scaled;\n" -" sample.a *= alphaFactor;\n" -" scaled = UnormTo10bit (DoAlphaPremul (sample));\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" output.Plane3 = float4 (scaled.a, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBRA_12 : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" float4 scaled;\n" -" sample.a *= alphaFactor;\n" -" scaled = UnormTo12bit (sample);\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" output.Plane3 = float4 (scaled.a, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputGBRAPremul_12 : IOutputPlanarFull\n" -"{\n" -" PS_OUTPUT_PLANAR_FULL Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PLANAR_FULL output;\n" -" float4 scaled;\n" -" sample.a *= alphaFactor;\n" -" scaled = UnormTo12bit (DoAlphaPremul (sample));\n" -" output.Plane0 = float4 (scaled.g, 0, 0, 0);\n" -" output.Plane1 = float4 (scaled.b, 0, 0, 0);\n" -" output.Plane2 = float4 (scaled.r, 0, 0, 0);\n" -" output.Plane3 = float4 (scaled.a, 0, 0, 0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"interface IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample);\n" -"};\n" -"\n" -"class OutputRGBA : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = float4 (sample.rgb, sample.a * alphaFactor);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputRGBAPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = DoAlphaPremul (sample);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputRGBx : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = float4 (sample.rgb, 1.0);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputxRGB : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = float4 (0.0, sample.rgb);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputARGB : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = sample.argb;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputARGBPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = DoAlphaPremul (sample).argb;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputxBGR : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = float4 (0.0, sample.bgr);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputABGR : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = sample.abgr;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputABGRPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" output.Plane0 = DoAlphaPremul (sample.abgr);\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputVUYA : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = sample.zyxw;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputVUYAPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = DoAlphaPremul (sample).zyxw;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputAYUV : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = sample.wxyz;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputAYUVPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = DoAlphaPremul (sample).wxyz;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputRBGA : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = sample.rbga;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"class OutputRBGAPremul : IOutputPacked\n" -"{\n" -" PS_OUTPUT_PACKED Build (float4 sample)\n" -" {\n" -" PS_OUTPUT_PACKED output;\n" -" sample.a *= alphaFactor;\n" -" output.Plane0 = DoAlphaPremul (sample).rbga;\n" -" return output;\n" -" }\n" -"};\n" -"\n" -"OUTPUT_TYPE ENTRY_POINT (PS_INPUT input)\n" -"{\n" -" SAMPLER g_sampler;\n" -" CONVERTER g_converter;\n" -" OUTPUT_BUILDER g_builder;\n" -" return g_builder.Build (g_converter.Execute (g_sampler.Execute (input.Texture)));\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/VSMain_converter.hlsl b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/VSMain_converter.hlsl deleted file mode 100644 index e9bd34c30b..0000000000 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/VSMain_converter.hlsl +++ /dev/null @@ -1,75 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -cbuffer VsConstBuffer : register(b0) -{ - matrix Transform; -}; - -struct VS_INPUT -{ - float4 Position : POSITION; - float2 Texture : TEXCOORD; -}; - -struct VS_OUTPUT -{ - float4 Position : SV_POSITION; - float2 Texture : TEXCOORD; -}; - -VS_OUTPUT VSMain_converter (VS_INPUT input) -{ - VS_OUTPUT output; - - output.Position = mul (Transform, input.Position); - output.Texture = input.Texture; - - return output; -} -#else -static const char g_VSMain_converter_str[] = -"cbuffer VsConstBuffer : register(b0)\n" -"{\n" -" matrix Transform;\n" -"};\n" -"\n" -"struct VS_INPUT\n" -"{\n" -" float4 Position : POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"struct VS_OUTPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"VS_OUTPUT VSMain_converter (VS_INPUT input)\n" -"{\n" -" VS_OUTPUT output;\n" -"\n" -" output.Position = mul (Transform, input.Position);\n" -" output.Texture = input.Texture;\n" -"\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/collect_hlsl_header.py b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/collect_hlsl_header.py deleted file mode 100644 index 1c8cf3c1e1..0000000000 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/collect_hlsl_header.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python3 -# GStreamer -# Copyright (C) 2023 Seungha Yang -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -# Boston, MA 02110-1301, USA. - -import sys -import os -import argparse - -start_header = """/* - * This file is autogenerated by collect_hlsl_header.py - */ -#pragma once - -""" - -start_map = """ -#define MAKE_BYTECODE(name) { G_STRINGIFY (name), { g_##name, sizeof (g_##name)} } -static const std::map> precompiled_bytecode = { -""" - -end_map = """}; -#undef MAKE_BYTECODE -""" - -def main(args): - parser = argparse.ArgumentParser(description='Read precompiled HLSL headers from directory and make single header') - parser.add_argument("--input", help="the precompiled HLSL header directory") - parser.add_argument("--output", help="output header file location") - parser.add_argument("--prefix", help="HLSL header filename prefix") - args = parser.parse_args(args) - - # Scan precompiled PSMain_*.h headers in build directory - # and generate single header - hlsl_headers = [os.path.basename(file) for file in os.listdir(args.input) if file.startswith(args.prefix) and file.endswith(".h") ] - - with open(args.output, 'w', newline='\n', encoding='utf8') as f: - f.write(start_header) - for file in hlsl_headers: - f.write("#include \"") - f.write(file) - f.write("\"\n") - f.write(start_map) - for file in hlsl_headers: - f.write(" MAKE_BYTECODE ({}),\n".format(os.path.splitext(file)[0])) - f.write(end_map) - - -if __name__ == "__main__": - sys.exit(main(sys.argv[1:])) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/meson.build deleted file mode 100644 index d67e1139be..0000000000 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/hlsl/meson.build +++ /dev/null @@ -1,211 +0,0 @@ -hlsl_ps_source = files('PSMain_converter.hlsl') - -hlsl_ps_input_formats = [ - ['NV12', false], - ['NV21', false], - ['I420', false], - ['YV12', false], - ['I420_10', false], - ['I420_12', false], - ['VUYA', false], - ['VUYAPremul', false], - ['Y410', false], - ['AYUV', false], - ['AYUVPremul', false], - ['Y412', false], - ['Y412Premul', false], - ['RGBA', true], - ['RGBAPremul', true], - ['RGBx', true], - ['GBR', true], - ['GBR_10', true], - ['GBR_12', true], - ['GBRA', true], - ['GBRAPremul', true], - ['GBRA_10', true], - ['GBRAPremul_10', true], - ['GBRA_12', true], - ['GBRAPremul_12', true], - ['RGBP', true], - ['BGRP', true], - ['xRGB', true], - ['ARGB', true], - ['ARGBPremul', true], - ['xBGR', true], - ['ABGR', true], - ['ABGRPremul', true], - ['BGR10A2', true], - ['BGRA64', true], - ['BGRA64Premul', true], - ['RBGA', true], - ['RBGAPremul', true], -] - -hlsl_ps_output_formats = [ - ['PS_OUTPUT_LUMA', 'Luma', false], - ['PS_OUTPUT_LUMA', 'Luma_10', false], - ['PS_OUTPUT_LUMA', 'Luma_12', false], - ['PS_OUTPUT_CHROMA', 'ChromaNV12', false], - ['PS_OUTPUT_CHROMA', 'ChromaNV21', false], - ['PS_OUTPUT_CHROMA_PLANAR', 'ChromaI420', false], - ['PS_OUTPUT_CHROMA_PLANAR', 'ChromaYV12', false], - ['PS_OUTPUT_CHROMA_PLANAR', 'ChromaI420_10', false], - ['PS_OUTPUT_CHROMA_PLANAR', 'ChromaI420_12', false], - ['PS_OUTPUT_PLANAR', 'Y444', false], - ['PS_OUTPUT_PLANAR', 'Y444_10', false], - ['PS_OUTPUT_PLANAR', 'Y444_12', false], - ['PS_OUTPUT_PLANAR', 'GBR', true], - ['PS_OUTPUT_PLANAR', 'GBR_10', true], - ['PS_OUTPUT_PLANAR', 'GBR_12', true], - ['PS_OUTPUT_PLANAR', 'RGBP', true], - ['PS_OUTPUT_PLANAR', 'BGRP', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRA', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRAPremul', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRA_10', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRAPremul_10', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRA_12', true], - ['PS_OUTPUT_PLANAR_FULL', 'GBRAPremul_12', true], - ['PS_OUTPUT_PACKED', 'RGBA', true], - ['PS_OUTPUT_PACKED', 'RGBAPremul', true], - ['PS_OUTPUT_PACKED', 'RBGA', true], - ['PS_OUTPUT_PACKED', 'RBGAPremul', true], - ['PS_OUTPUT_PACKED', 'RGBx', true], - ['PS_OUTPUT_PACKED', 'VUYA', false], - ['PS_OUTPUT_PACKED', 'VUYAPremul', false], - ['PS_OUTPUT_PACKED', 'AYUV', false], - ['PS_OUTPUT_PACKED', 'AYUVPremul', false], - ['PS_OUTPUT_PACKED', 'xRGB', true], - ['PS_OUTPUT_PACKED', 'ARGB', true], - ['PS_OUTPUT_PACKED', 'ARGBPremul', true], - ['PS_OUTPUT_PACKED', 'xBGR', true], - ['PS_OUTPUT_PACKED', 'ABGR', true], - ['PS_OUTPUT_PACKED', 'ABGRPremul', true], -] - -header_collector = find_program('collect_hlsl_header.py') - -foreach input_format : hlsl_ps_input_formats - in_format = input_format.get(0) - foreach output_format : hlsl_ps_output_formats - converter = '' - if input_format.get(1) != output_format.get(2) - converter = 'Simple' - else - converter = 'Identity' - endif - output_type = output_format.get(0) - output_builder = output_format.get(1) - entry_point = 'PSMain_@0@_@1@_@2@'.format(in_format, converter, output_builder) - header = '@0@.h'.format(entry_point) - compiled_shader = custom_target(header, - input : hlsl_ps_source, - output : header, - command : [fxc, '/Fh', '@OUTPUT@', - '/E', entry_point, - '/T', 'ps_4_0', - '/D', 'BUILDING_HLSL=1', - '/D', 'OUTPUT_TYPE=@0@'.format(output_type), - '/D', 'ENTRY_POINT=@0@'.format(entry_point), - '/D', 'SAMPLER=Sampler@0@'.format(in_format), - '/D', 'CONVERTER=Converter@0@'.format(converter), - '/D', 'OUTPUT_BUILDER=Output@0@'.format(output_builder), - '/nologo', - '@INPUT@']) - hlsl_precompiled += [compiled_shader] - endforeach -endforeach - -header_collection = 'PSMainConverter.h' -generated_collection = custom_target(header_collection, - input : hlsl_precompiled, - output : header_collection, - command : [header_collector, - '--input', meson.current_build_dir(), - '--prefix', 'PSMain_', - '--output', '@OUTPUT@' - ]) - -hlsl_precompiled += generated_collection - -hlsl_vs_sources = [ - [files('VSMain_converter.hlsl'), 'VSMain_converter', 'vs_4_0'], -] - -foreach shader : hlsl_vs_sources - source = shader.get(0) - entry_point = shader.get(1) - header = '@0@.h'.format(entry_point) - compiled_shader = custom_target(header, - input : source, - output : header, - command : [fxc, '/Fh', '@OUTPUT@', - '/E', entry_point, - '/T', shader.get(2), - '/D', 'BUILDING_HLSL=1', - '/nologo', - '@INPUT@']) - hlsl_precompiled += [compiled_shader] -endforeach - -hlsl_cs_source = files('CSMain_converter.hlsl') -hlsl_cs_entry_points = [ - 'CSMain_YUY2_to_AYUV', - 'CSMain_UYVY_to_AYUV', - 'CSMain_VYUY_to_AYUV', - 'CSMain_YVYU_to_AYUV', - 'CSMain_v210_to_AYUV', - 'CSMain_v308_to_AYUV', - 'CSMain_IYU2_to_AYUV', - 'CSMain_AYUV_to_YUY2', - 'CSMain_AYUV_to_UYVY', - 'CSMain_AYUV_to_VYUY', - 'CSMain_AYUV_to_YVYU', - 'CSMain_AYUV_to_v210', - 'CSMain_AYUV_to_v308', - 'CSMain_AYUV_to_IYU2', - 'CSMain_AYUV_to_Y410', - 'CSMain_RGB_to_RGBA', - 'CSMain_BGR_to_RGBA', - 'CSMain_RGB16_to_RGBA', - 'CSMain_BGR16_to_RGBA', - 'CSMain_RGB15_to_RGBA', - 'CSMain_BGR15_to_RGBA', - 'CSMain_r210_to_RGBA', - 'CSMain_RGBA_to_RGB', - 'CSMain_RGBA_to_BGR', - 'CSMain_RGBA_to_RGB16', - 'CSMain_RGBA_to_BGR16', - 'CSMain_RGBA_to_RGB15', - 'CSMain_RGBA_to_BGR15', - 'CSMain_RGBA_to_r210', - 'CSMain_RGBA_to_BGRA', -] - -foreach shader : hlsl_cs_entry_points - entry_point = shader - header = '@0@.h'.format(entry_point) - compiled_shader = custom_target(header, - input : hlsl_cs_source, - output : header, - command : [fxc, '/Fh', '@OUTPUT@', - '/E', entry_point, - '/T', 'cs_5_0', - '/D', 'BUILDING_HLSL=1', - '/D', 'ENTRY_POINT=@0@'.format(entry_point), - '/D', 'BUILDING_@0@=1'.format(entry_point), - '/nologo', - '@INPUT@']) - hlsl_precompiled += [compiled_shader] -endforeach - -header_collection = 'CSMainConverter.h' -generated_collection = custom_target(header_collection, - input : hlsl_precompiled, - output : header_collection, - command : [header_collector, - '--input', meson.current_build_dir(), - '--prefix', 'CSMain_', - '--output', '@OUTPUT@' - ]) - -hlsl_precompiled += generated_collection \ No newline at end of file diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build index 5abb1360f4..485baf889e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build @@ -51,6 +51,13 @@ dxgi_lib = cc.find_library('dxgi', required: d3d11_opt) d3dcompiler_lib = cc.find_library('d3dcompiler', required: false) runtimeobject_lib = cc.find_library('runtimeobject', required: false) +if not gstd3dshader_dep.found() + if d3d11_option.enabled() + error('The d3d11 was enabled explicitly, but required d3dshader dep were not found.') + endif + subdir_done() +endif + if not d3d11_lib.found() or not dxgi_lib.found() subdir_done() endif @@ -174,13 +181,6 @@ if cc.get_id() != 'msvc' extra_comm_args += extra_args endif -hlsl_precompiled = [] -fxc = find_program ('fxc', required : get_option ('d3d11-hlsl-precompile')) -if cc.get_id() == 'msvc' and fxc.found() - subdir('hlsl') - extra_comm_args += ['-DHLSL_PRECOMPILED'] -endif - have_dx_math = cxx.compiles(''' #include #include @@ -233,14 +233,14 @@ configure_file( pkg_name = 'gstreamer-d3d11-' + api_version gstd3d11 = library('gstd3d11-' + api_version, - d3d11_sources + hlsl_precompiled, + d3d11_sources, c_args : gst_plugins_bad_args + extra_c_args + extra_comm_args, cpp_args : gst_plugins_bad_args + extra_comm_args, include_directories : [configinc, libsinc], version : libversion, soversion : soversion, install : true, - dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, d3d11_lib, dxgi_lib] + extra_deps + dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstd3dshader_dep, d3d11_lib, dxgi_lib] + extra_deps ) pkgconfig.generate(gstd3d11, diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp index db64725a52..ae1b66c857 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp @@ -23,13 +23,12 @@ #endif #include "gstd3d11pluginutils.h" +#include #include #include #include -#include "hlsl/gstd3d11plugin-hlsl.h" - /* Disable platform-specific intrinsics */ #define _XM_NO_INTRINSICS_ #include @@ -777,6 +776,25 @@ gst_d3d11_buffer_pool_new_with_options (GstD3D11Device * device, return pool; } +static HRESULT +gst_d3d11_get_pixel_shader_internal (GstD3D11Device * device, gint64 token, + GstD3DPluginPS ps_type, const gchar * entry_point, ID3D11PixelShader ** ps) +{ + auto handle = gst_d3d11_device_get_device_handle (device); + GstD3DShaderModel sm = GST_D3D_SM_4_0; + if (handle->GetFeatureLevel () >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + + GstD3DShaderByteCode bytecode = { }; + if (!gst_d3d_plugin_shader_get_ps_blob (ps_type, sm, &bytecode)) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return E_FAIL; + } + + return gst_d3d11_device_get_pixel_shader (device, token, entry_point, + &bytecode, ps); +} + HRESULT gst_d3d11_get_pixel_shader_checker_luma (GstD3D11Device * device, ID3D11PixelShader ** ps) @@ -787,10 +805,8 @@ gst_d3d11_get_pixel_shader_checker_luma (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_checker_luma, sizeof (g_PSMain_checker_luma), - g_PSMain_checker_luma_str, sizeof (g_PSMain_checker_luma_str), - "PSMain_checker_luma", nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_CHECKER_LUMA, "PSMain_checker_luma", ps); } HRESULT @@ -803,10 +819,8 @@ gst_d3d11_get_pixel_shader_checker_rgb (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_checker_rgb, sizeof (g_PSMain_checker_rgb), - g_PSMain_checker_rgb_str, sizeof (g_PSMain_checker_rgb_str), - "PSMain_checker_rgb", nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_CHECKER_RGB, "PSMain_checker_rgb", ps); } HRESULT @@ -819,10 +833,8 @@ gst_d3d11_get_pixel_shader_checker_vuya (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_checker_vuya, sizeof (g_PSMain_checker_vuya), - g_PSMain_checker_vuya_str, sizeof (g_PSMain_checker_vuya_str), - "PSMain_checker_vuya", nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_CHECKER_VUYA, "PSMain_checker_vuya", ps); } HRESULT @@ -835,10 +847,8 @@ gst_d3d11_get_pixel_shader_checker (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_checker, sizeof (g_PSMain_checker), - g_PSMain_checker_str, sizeof (g_PSMain_checker_str), - "PSMain_checker", nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_CHECKER, "PSMain_checker", ps); } HRESULT @@ -851,10 +861,8 @@ gst_d3d11_get_pixel_shader_color (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_color, sizeof (g_PSMain_color), - g_PSMain_color_str, sizeof (g_PSMain_color_str), "PSMain_color", - nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_COLOR, "PSMain_color", ps); } HRESULT @@ -867,10 +875,8 @@ gst_d3d11_get_pixel_shader_sample_premul (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_sample_premul, sizeof (g_PSMain_sample_premul), - g_PSMain_sample_premul_str, sizeof (g_PSMain_sample_premul_str), - "PSMain_sample_premul", nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_SAMPLE_PREMULT, "PSMain_sample_premul", ps); } HRESULT @@ -883,10 +889,8 @@ gst_d3d11_get_pixel_shader_sample (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_sample, sizeof (g_PSMain_sample), - g_PSMain_sample_str, sizeof (g_PSMain_sample_str), "PSMain_sample", - nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_SAMPLE, "PSMain_sample", ps); } HRESULT @@ -899,10 +903,8 @@ gst_d3d11_get_pixel_shader_snow (GstD3D11Device * device, token = gst_d3d11_pixel_shader_token_new (); } GST_D3D11_CALL_ONCE_END; - return gst_d3d11_device_get_pixel_shader (device, token, - g_PSMain_snow, sizeof (g_PSMain_snow), - g_PSMain_snow_str, sizeof (g_PSMain_snow_str), "PSMain_snow", - nullptr, ps); + return gst_d3d11_get_pixel_shader_internal (device, token, + GST_D3D_PLUGIN_PS_SNOW, "PSMain_snow", ps); } HRESULT @@ -915,6 +917,18 @@ gst_d3d11_get_vertex_shader_color (GstD3D11Device * device, token = gst_d3d11_vertex_shader_token_new (); } GST_D3D11_CALL_ONCE_END; + auto handle = gst_d3d11_device_get_device_handle (device); + GstD3DShaderModel sm = GST_D3D_SM_4_0; + if (handle->GetFeatureLevel () >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + + GstD3DShaderByteCode bytecode = { }; + if (!gst_d3d_plugin_shader_get_vs_blob (GST_D3D_PLUGIN_VS_COLOR, + sm, &bytecode)) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return E_FAIL; + } + D3D11_INPUT_ELEMENT_DESC input_desc[2]; input_desc[0].SemanticName = "POSITION"; @@ -933,10 +947,8 @@ gst_d3d11_get_vertex_shader_color (GstD3D11Device * device, input_desc[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; input_desc[1].InstanceDataStepRate = 0; - return gst_d3d11_device_get_vertex_shader (device, token, - g_VSMain_color, sizeof (g_VSMain_color), - g_VSMain_color_str, sizeof (g_VSMain_color_str), "VSMain_color", - input_desc, G_N_ELEMENTS (input_desc), vs, layout); + return gst_d3d11_device_get_vertex_shader (device, token, "VSMain_color", + &bytecode, input_desc, G_N_ELEMENTS (input_desc), vs, layout); } HRESULT @@ -949,6 +961,18 @@ gst_d3d11_get_vertex_shader_coord (GstD3D11Device * device, token = gst_d3d11_vertex_shader_token_new (); } GST_D3D11_CALL_ONCE_END; + auto handle = gst_d3d11_device_get_device_handle (device); + GstD3DShaderModel sm = GST_D3D_SM_4_0; + if (handle->GetFeatureLevel () >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + + GstD3DShaderByteCode bytecode = { }; + if (!gst_d3d_plugin_shader_get_vs_blob (GST_D3D_PLUGIN_VS_COORD, + sm, &bytecode)) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return E_FAIL; + } + D3D11_INPUT_ELEMENT_DESC input_desc[2]; input_desc[0].SemanticName = "POSITION"; @@ -967,10 +991,8 @@ gst_d3d11_get_vertex_shader_coord (GstD3D11Device * device, input_desc[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; input_desc[1].InstanceDataStepRate = 0; - return gst_d3d11_device_get_vertex_shader (device, token, - g_VSMain_coord, sizeof (g_VSMain_coord), - g_VSMain_coord_str, sizeof (g_VSMain_coord_str), "VSMain_coord", - input_desc, G_N_ELEMENTS (input_desc), vs, layout); + return gst_d3d11_device_get_vertex_shader (device, token, "VSMain_coord", + &bytecode, input_desc, G_N_ELEMENTS (input_desc), vs, layout); } HRESULT @@ -983,6 +1005,17 @@ gst_d3d11_get_vertex_shader_pos (GstD3D11Device * device, token = gst_d3d11_vertex_shader_token_new (); } GST_D3D11_CALL_ONCE_END; + auto handle = gst_d3d11_device_get_device_handle (device); + GstD3DShaderModel sm = GST_D3D_SM_4_0; + if (handle->GetFeatureLevel () >= D3D_FEATURE_LEVEL_11_0) + sm = GST_D3D_SM_5_0; + + GstD3DShaderByteCode bytecode = { }; + if (!gst_d3d_plugin_shader_get_vs_blob (GST_D3D_PLUGIN_VS_POS, sm, &bytecode)) { + GST_ERROR_OBJECT (device, "Couldn't get compiled bytecode"); + return E_FAIL; + } + D3D11_INPUT_ELEMENT_DESC input_desc; input_desc.SemanticName = "POSITION"; @@ -993,10 +1026,8 @@ gst_d3d11_get_vertex_shader_pos (GstD3D11Device * device, input_desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; input_desc.InstanceDataStepRate = 0; - return gst_d3d11_device_get_vertex_shader (device, token, - g_VSMain_pos, sizeof (g_VSMain_pos), - g_VSMain_pos_str, sizeof (g_VSMain_pos_str), "VSMain_pos", &input_desc, 1, - vs, layout); + return gst_d3d11_device_get_vertex_shader (device, token, "VSMain_pos", + &bytecode, &input_desc, 1, vs, layout); } gboolean diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker.hlsl deleted file mode 100644 index 2ef6cb5454..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker.hlsl +++ /dev/null @@ -1,73 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -cbuffer CheckerConstBuffer : register(b0) -{ - float width; - float height; - float checker_size; - float alpha; -}; - -struct PS_INPUT -{ - float4 Position: SV_POSITION; - float2 Texture: TEXCOORD; -}; - -float4 PSMain_checker (PS_INPUT input) : SV_Target -{ - float4 output; - float2 xy_mod = floor (0.5 * input.Texture * float2 (width, height) / checker_size); - float result = fmod (xy_mod.x + xy_mod.y, 2.0); - output.r = step (result, 0.5); - output.g = 1.0 - output.r; - output.b = 0; - output.a = alpha; - return output; -} -#else -static const char g_PSMain_checker_str[] = -"cbuffer CheckerConstBuffer : register(b0)\n" -"{\n" -" float width;\n" -" float height;\n" -" float checker_size;\n" -" float alpha;\n" -"};\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position: SV_POSITION;\n" -" float2 Texture: TEXCOORD;\n" -"};\n" -"\n" -"float4 PSMain_checker (PS_INPUT input) : SV_Target\n" -"{\n" -" float4 output;\n" -" float2 xy_mod = floor (0.5 * input.Texture * float2 (width, height) / checker_size);\n" -" float result = fmod (xy_mod.x + xy_mod.y, 2.0);\n" -" output.r = step (result, 0.5);\n" -" output.g = 1.0 - output.r;\n" -" output.b = 0;\n" -" output.a = alpha;\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_luma.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_luma.hlsl deleted file mode 100644 index 79a31ffe7b..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_luma.hlsl +++ /dev/null @@ -1,83 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -static const float blocksize = 8.0; -static const float4 high = float4 (0.667, 0.0, 0.0, 1.0); -static const float4 low = float4 (0.333, 0.0, 0.0, 1.0); - -struct PS_INPUT -{ - float4 Position : SV_POSITION; -}; - -struct PS_OUTPUT -{ - float4 Plane : SV_TARGET; -}; - -PS_OUTPUT PSMain_checker_luma (PS_INPUT input) -{ - PS_OUTPUT output; - if ((input.Position.x % (blocksize * 2.0)) >= blocksize) { - if ((input.Position.y % (blocksize * 2.0)) >= blocksize) - output.Plane = low; - else - output.Plane = high; - } else { - if ((input.Position.y % (blocksize * 2.0)) < blocksize) - output.Plane = low; - else - output.Plane = high; - } - return output; -} -#else -static const char g_PSMain_checker_luma_str[] = -"static const float blocksize = 8.0;\n" -"static const float4 high = float4 (0.667, 0.0, 0.0, 1.0);\n" -"static const float4 low = float4 (0.333, 0.0, 0.0, 1.0);\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -"};\n" -"\n" -"struct PS_OUTPUT\n" -"{\n" -" float4 Plane : SV_TARGET;\n" -"};\n" -"\n" -"PS_OUTPUT PSMain_checker_luma (PS_INPUT input)\n" -"{\n" -" PS_OUTPUT output;\n" -" if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {\n" -" if ((input.Position.y % (blocksize * 2.0)) >= blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" } else {\n" -" if ((input.Position.y % (blocksize * 2.0)) < blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" }\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_rgb.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_rgb.hlsl deleted file mode 100644 index a45f01adad..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_rgb.hlsl +++ /dev/null @@ -1,83 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -static const float blocksize = 8.0; -static const float4 high = float4 (0.667, 0.667, 0.667, 1.0); -static const float4 low = float4 (0.333, 0.333, 0.333, 1.0); - -struct PS_INPUT -{ - float4 Position : SV_POSITION; -}; - -struct PS_OUTPUT -{ - float4 Plane : SV_TARGET; -}; - -PS_OUTPUT PSMain_checker_rgb (PS_INPUT input) -{ - PS_OUTPUT output; - if ((input.Position.x % (blocksize * 2.0)) >= blocksize) { - if ((input.Position.y % (blocksize * 2.0)) >= blocksize) - output.Plane = low; - else - output.Plane = high; - } else { - if ((input.Position.y % (blocksize * 2.0)) < blocksize) - output.Plane = low; - else - output.Plane = high; - } - return output; -} -#else -static const char g_PSMain_checker_rgb_str[] = -"static const float blocksize = 8.0;\n" -"static const float4 high = float4 (0.667, 0.667, 0.667, 1.0);\n" -"static const float4 low = float4 (0.333, 0.333, 0.333, 1.0);\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -"};\n" -"\n" -"struct PS_OUTPUT\n" -"{\n" -" float4 Plane : SV_TARGET;\n" -"};\n" -"\n" -"PS_OUTPUT PSMain_checker_rgb (PS_INPUT input)\n" -"{\n" -" PS_OUTPUT output;\n" -" if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {\n" -" if ((input.Position.y % (blocksize * 2.0)) >= blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" } else {\n" -" if ((input.Position.y % (blocksize * 2.0)) < blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" }\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_vuya.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_vuya.hlsl deleted file mode 100644 index 40d31d7efb..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_checker_vuya.hlsl +++ /dev/null @@ -1,83 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -static const float blocksize = 8.0; -static const float4 high = float4 (0.5, 0.5, 0.667, 1.0); -static const float4 low = float4 (0.5, 0.5, 0.333, 1.0); - -struct PS_INPUT -{ - float4 Position : SV_POSITION; -}; - -struct PS_OUTPUT -{ - float4 Plane : SV_TARGET; -}; - -PS_OUTPUT PSMain_checker_vuya (PS_INPUT input) -{ - PS_OUTPUT output; - if ((input.Position.x % (blocksize * 2.0)) >= blocksize) { - if ((input.Position.y % (blocksize * 2.0)) >= blocksize) - output.Plane = low; - else - output.Plane = high; - } else { - if ((input.Position.y % (blocksize * 2.0)) < blocksize) - output.Plane = low; - else - output.Plane = high; - } - return output; -} -#else -static const char g_PSMain_checker_vuya_str[] = -"static const float blocksize = 8.0;\n" -"static const float4 high = float4 (0.5, 0.5, 0.667, 1.0);\n" -"static const float4 low = float4 (0.5, 0.5, 0.333, 1.0);\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -"};\n" -"\n" -"struct PS_OUTPUT\n" -"{\n" -" float4 Plane : SV_TARGET;\n" -"};\n" -"\n" -"PS_OUTPUT PSMain_checker_vuya (PS_INPUT input)\n" -"{\n" -" PS_OUTPUT output;\n" -" if ((input.Position.x % (blocksize * 2.0)) >= blocksize) {\n" -" if ((input.Position.y % (blocksize * 2.0)) >= blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" } else {\n" -" if ((input.Position.y % (blocksize * 2.0)) < blocksize)\n" -" output.Plane = low;\n" -" else\n" -" output.Plane = high;\n" -" }\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_color.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_color.hlsl deleted file mode 100644 index 921b83ca25..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_color.hlsl +++ /dev/null @@ -1,43 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -struct PS_INPUT -{ - float4 Position: SV_POSITION; - float4 Color: COLOR; -}; - -float4 PSMain_color (PS_INPUT input) : SV_TARGET -{ - return input.Color; -} -#else -static const char g_PSMain_color_str[] = -"struct PS_INPUT\n" -"{\n" -" float4 Position: SV_POSITION;\n" -" float4 Color: COLOR;\n" -"};\n" -"\n" -"float4 PSMain_color (PS_INPUT input) : SV_TARGET\n" -"{\n" -" return input.Color;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample.hlsl deleted file mode 100644 index 90f91b46d6..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -Texture2D shaderTexture; -SamplerState samplerState; - -struct PS_INPUT -{ - float4 Position : SV_POSITION; - float2 Texture : TEXCOORD; -}; - -float4 PSMain_sample (PS_INPUT input): SV_TARGET -{ - return shaderTexture.Sample (samplerState, input.Texture); -} -#else -static const char g_PSMain_sample_str[] = -"Texture2D shaderTexture;\n" -"SamplerState samplerState;\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position: SV_POSITION;\n" -" float2 Texture: TEXCOORD;\n" -"};\n" -"\n" -"float4 PSMain_sample (PS_INPUT input): SV_TARGET\n" -"{\n" -" return shaderTexture.Sample (samplerState, input.Texture);\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample_premul.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample_premul.hlsl deleted file mode 100644 index 1836650109..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_sample_premul.hlsl +++ /dev/null @@ -1,61 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -Texture2D shaderTexture; -SamplerState samplerState; - -struct PS_INPUT -{ - float4 Position : SV_POSITION; - float2 Texture : TEXCOORD; -}; - -float4 PSMain_sample_premul (PS_INPUT input): SV_TARGET -{ - float4 sample = shaderTexture.Sample (samplerState, input.Texture); - float4 premul_sample; - premul_sample.r = saturate (sample.r * sample.a); - premul_sample.g = saturate (sample.g * sample.a); - premul_sample.b = saturate (sample.b * sample.a); - premul_sample.a = sample.a; - return premul_sample; -} -#else -static const char g_PSMain_sample_premul_str[] = -"Texture2D shaderTexture;\n" -"SamplerState samplerState;\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"float4 PSMain_sample_premul (PS_INPUT input): SV_TARGET\n" -"{\n" -" float4 sample = shaderTexture.Sample (samplerState, input.Texture);\n" -" float4 premul_sample;\n" -" premul_sample.r = saturate (sample.r * sample.a);\n" -" premul_sample.g = saturate (sample.g * sample.a);\n" -" premul_sample.b = saturate (sample.b * sample.a);\n" -" premul_sample.a = sample.a;\n" -" return premul_sample;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_snow.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_snow.hlsl deleted file mode 100644 index 15b71ba109..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/PSMain_snow.hlsl +++ /dev/null @@ -1,75 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -cbuffer SnowConstBuffer : register(b0) -{ - float time; - float alpha; - float2 padding; -}; - -struct PS_INPUT -{ - float4 Position : SV_POSITION; - float2 Texture : TEXCOORD; -}; - -float get_rand (float2 uv) -{ - return frac (sin (dot (uv, float2 (12.9898,78.233))) * 43758.5453); -} - -float4 PSMain_snow (PS_INPUT input) : SV_Target -{ - float4 output; - float val = get_rand (time * input.Texture); - output.rgb = float3(val, val, val); - output.a = alpha; - return output; -} -#else -static const char g_PSMain_snow_str[] = -"cbuffer TimeConstBuffer : register(b0)\n" -"{\n" -" float time;\n" -" float alpha;\n" -" float2 padding;\n" -"};\n" -"\n" -"struct PS_INPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"float get_rand(float2 uv)\n" -"{\n" -" return frac (sin (dot (uv, float2 (12.9898,78.233))) * 43758.5453);\n" -"}\n" -"\n" -"float4 PSMain_snow (PS_INPUT input) : SV_Target\n" -"{\n" -" float4 output;\n" -" float val = get_rand (time * input.Texture);\n" -" output.rgb = float3(val, val, val);\n" -" output.a = alpha;\n" -" return output;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_color.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_color.hlsl deleted file mode 100644 index 4c60a73634..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_color.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -struct VS_INPUT -{ - float4 Position : POSITION; - float4 Color : COLOR; -}; - -struct VS_OUTPUT -{ - float4 Position : SV_POSITION; - float4 Color : COLOR; -}; - -VS_OUTPUT VSMain_color (VS_INPUT input) -{ - return input; -} -#else -static const char g_VSMain_color_str[] = -"struct VS_INPUT\n" -"{\n" -" float4 Position : POSITION;\n" -" float4 Color : COLOR;\n" -"};\n" -"\n" -"struct VS_OUTPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -" float4 Color : COLOR;\n" -"};\n" -"\n" -"VS_OUTPUT VSMain_color (VS_INPUT input)\n" -"{\n" -" return input;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_coord.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_coord.hlsl deleted file mode 100644 index f79bd39627..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_coord.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -struct VS_INPUT -{ - float4 Position : POSITION; - float2 Texture : TEXCOORD; -}; - -struct VS_OUTPUT -{ - float4 Position : SV_POSITION; - float2 Texture : TEXCOORD; -}; - -VS_OUTPUT VSMain_coord (VS_INPUT input) -{ - return input; -} -#else -static const char g_VSMain_coord_str[] = -"struct VS_INPUT\n" -"{\n" -" float4 Position : POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"struct VS_OUTPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -" float2 Texture : TEXCOORD;\n" -"};\n" -"\n" -"VS_OUTPUT VSMain_coord (VS_INPUT input)\n" -"{\n" -" return input;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_pos.hlsl b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_pos.hlsl deleted file mode 100644 index 9b786b3826..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/VSMain_pos.hlsl +++ /dev/null @@ -1,51 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef BUILDING_HLSL -struct VS_INPUT -{ - float4 Position : POSITION; -}; - -struct VS_OUTPUT -{ - float4 Position : SV_POSITION; -}; - -VS_OUTPUT VSMain_pos (VS_INPUT input) -{ - return input; -} -#else -static const char g_VSMain_pos_str[] = -"struct VS_INPUT\n" -"{\n" -" float4 Position : POSITION;\n" -"};\n" -"\n" -"struct VS_OUTPUT\n" -"{\n" -" float4 Position : SV_POSITION;\n" -"};\n" -"\n" -"VS_OUTPUT VSMain_pos (VS_INPUT input)\n" -"{\n" -" return input;\n" -"}\n"; -#endif diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/gstd3d11plugin-hlsl.h b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/gstd3d11plugin-hlsl.h deleted file mode 100644 index 140836f929..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/gstd3d11plugin-hlsl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* GStreamer - * Copyright (C) 2023 Seungha Yang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#pragma once - -#ifdef HLSL_PRECOMPILED -#include "PSMain_checker_luma.h" -#include "PSMain_checker_rgb.h" -#include "PSMain_checker_vuya.h" -#include "PSMain_checker.h" -#include "PSMain_color.h" -#include "PSMain_sample_premul.h" -#include "PSMain_sample.h" -#include "PSMain_snow.h" -#include "VSMain_color.h" -#include "VSMain_coord.h" -#include "VSMain_pos.h" -#else -const BYTE g_PSMain_checker_luma[] = { 0 }; -const BYTE g_PSMain_checker_rgb[] = { 0 }; -const BYTE g_PSMain_checker_vuya[] = { 0 }; -const BYTE g_PSMain_checker[] = { 0 }; -const BYTE g_PSMain_color[] = { 0 }; -const BYTE g_PSMain_sample_premul[] = { 0 }; -const BYTE g_PSMain_sample[] = { 0 }; -const BYTE g_PSMain_snow[] = { 0 }; -const BYTE g_VSMain_color[] = { 0 }; -const BYTE g_VSMain_coord[] = { 0 }; -const BYTE g_VSMain_pos[] = { 0 }; -#endif - -#include "PSMain_checker_luma.hlsl" -#include "PSMain_checker_rgb.hlsl" -#include "PSMain_checker_vuya.hlsl" -#include "PSMain_checker.hlsl" -#include "PSMain_color.hlsl" -#include "PSMain_sample_premul.hlsl" -#include "PSMain_sample.hlsl" -#include "PSMain_snow.hlsl" -#include "VSMain_color.hlsl" -#include "VSMain_coord.hlsl" -#include "VSMain_pos.hlsl" diff --git a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/meson.build b/subprojects/gst-plugins-bad/sys/d3d11/hlsl/meson.build deleted file mode 100644 index 0399ecfc5f..0000000000 --- a/subprojects/gst-plugins-bad/sys/d3d11/hlsl/meson.build +++ /dev/null @@ -1,29 +0,0 @@ -hlsl_sources = [ - ['PSMain_checker_luma', 'ps_4_0'], - ['PSMain_checker_rgb', 'ps_4_0'], - ['PSMain_checker_vuya', 'ps_4_0'], - ['PSMain_checker', 'ps_4_0'], - ['PSMain_color', 'ps_4_0'], - ['PSMain_sample_premul', 'ps_4_0'], - ['PSMain_sample', 'ps_4_0'], - ['PSMain_snow', 'ps_4_0'], - ['VSMain_color', 'vs_4_0'], - ['VSMain_coord', 'vs_4_0'], - ['VSMain_pos', 'vs_4_0'], -] - -foreach shader : hlsl_sources - entry_point = shader.get(0) - source = files('@0@.hlsl'.format(entry_point)) - header = '@0@.h'.format(entry_point) - compiled_shader = custom_target(header, - input : source, - output : header, - command : [fxc, '/Fh', '@OUTPUT@', - '/E', entry_point, - '/T', shader.get(1), - '/D', 'BUILDING_HLSL=1', - '/nologo', - '@INPUT@']) - hlsl_precompiled += [compiled_shader] -endforeach diff --git a/subprojects/gst-plugins-bad/sys/d3d11/meson.build b/subprojects/gst-plugins-bad/sys/d3d11/meson.build index ff557be3bd..8ac208ae82 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/meson.build +++ b/subprojects/gst-plugins-bad/sys/d3d11/meson.build @@ -126,20 +126,13 @@ if cc.get_id() != 'msvc' extra_args += extra_mingw_args endif -hlsl_precompiled = [] -fxc = find_program ('fxc', required : get_option ('d3d11-hlsl-precompile')) -if cc.get_id() == 'msvc' and fxc.found() - subdir('hlsl') - extra_args += ['-DHLSL_PRECOMPILED'] -endif - gstd3d11 = library('gstd3d11', - d3d11_sources + hlsl_precompiled, + d3d11_sources, c_args : gst_plugins_bad_args + extra_c_args + extra_args, cpp_args: gst_plugins_bad_args + extra_args, include_directories : [configinc], dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep, - gstd3d11_dep, gstdxva_dep, d2d_dep, directxmath_dep] + extra_dep, + gstd3d11_dep, gstd3dshader_dep, gstdxva_dep, d2d_dep, directxmath_dep] + extra_dep, install : true, install_dir : plugins_install_dir, )