mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
d3d11: Port to d3dshader library
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6434>
This commit is contained in:
parent
13c90b606a
commit
cab1f3e547
27 changed files with 180 additions and 5492 deletions
|
@ -25,7 +25,7 @@
|
|||
#include "gstd3d11device.h"
|
||||
#include "gstd3d11utils.h"
|
||||
#include "gstd3d11-private.h"
|
||||
#include <gmodule.h>
|
||||
#include <gst/d3dshader/gstd3dshader.h>
|
||||
#include <wrl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,447 +25,105 @@
|
|||
#include "gstd3d11device-private.h"
|
||||
#include "gstd3d11-private.h"
|
||||
#include "gstd3d11utils.h"
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <gst/d3dshader/gstd3dshader.h>
|
||||
|
||||
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<std::pair<std::string, std::string>> macros;
|
||||
guint num_rtv;
|
||||
};
|
||||
|
||||
enum class PS_OUTPUT
|
||||
{
|
||||
PACKED,
|
||||
LUMA,
|
||||
CHROMA,
|
||||
CHROMA_PLANAR,
|
||||
PLANAR,
|
||||
PLANAR_FULL,
|
||||
};
|
||||
|
||||
static std::map<std::string, std::shared_ptr<ConverterPSSource>> ps_source_cache;
|
||||
static std::mutex cache_lock;
|
||||
#ifdef HLSL_PRECOMPILED
|
||||
#include "PSMainConverter.h"
|
||||
#include "VSMain_converter.h"
|
||||
#else
|
||||
static const std::map<std::string, std::pair<const BYTE *, SIZE_T>> 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<std::pair<PS_OUTPUT, std::string>>
|
||||
make_output (GstVideoFormat format, gboolean premul)
|
||||
{
|
||||
std::vector<std::pair<PS_OUTPUT, std::string>> 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<ConverterPSSource> source;
|
||||
std::vector<D3D_SHADER_MACRO> macros;
|
||||
ComPtr<ID3D11PixelShader> 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<ConverterPSSource> ();
|
||||
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<PixelShader> ();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <vector>
|
||||
#include <wrl.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
enum class CONVERT_TYPE
|
||||
{
|
||||
|
|
|
@ -29,13 +29,11 @@
|
|||
#include "gstd3d11memory.h"
|
||||
#include "gstd3d11bufferpool.h"
|
||||
#include "gstd3d11shadercache.h"
|
||||
#include <gst/d3dshader/gstd3dshader.h>
|
||||
#include <wrl.h>
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
/* *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<std::pair<std::string, std::string>> macros;
|
||||
};
|
||||
|
||||
static std::map<std::string, std::shared_ptr<ConverterCSSource>> cs_source_cache;
|
||||
static std::mutex cache_lock;
|
||||
#ifdef HLSL_PRECOMPILED
|
||||
#include "CSMainConverter.h"
|
||||
#else
|
||||
static const std::map<std::string, std::pair<const BYTE *, SIZE_T>> 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<std::mutex> lk (cache_lock);
|
||||
std::shared_ptr<ConverterCSSource> source;
|
||||
auto cached = cs_source_cache.find (entry_point);
|
||||
if (cached != cs_source_cache.end ()) {
|
||||
source = cached->second;
|
||||
} else {
|
||||
source = std::make_shared<ConverterCSSource> ();
|
||||
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<D3D_SHADER_MACRO> 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);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/d3d11/gstd3d11_fwd.h>
|
||||
#include <gst/d3dshader/gstd3dshader.h>
|
||||
|
||||
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,
|
||||
|
|
|
@ -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 ();
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,75 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,64 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# GStreamer
|
||||
# Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
#
|
||||
# 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<std::string, std::pair<const BYTE *, SIZE_T>> 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:]))
|
|
@ -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
|
|
@ -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 <windows.h>
|
||||
#include <DirectXMath.h>
|
||||
|
@ -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,
|
||||
|
|
|
@ -23,13 +23,12 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <gst/d3dshader/gstd3dshader.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <versionhelpers.h>
|
||||
#include <wrl.h>
|
||||
|
||||
#include "hlsl/gstd3d11plugin-hlsl.h"
|
||||
|
||||
/* Disable platform-specific intrinsics */
|
||||
#define _XM_NO_INTRINSICS_
|
||||
#include <DirectXMath.h>
|
||||
|
@ -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
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,83 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,83 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,83 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,43 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,49 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,61 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,75 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,55 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,55 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,51 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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
|
|
@ -1,58 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* 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"
|
|
@ -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
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue