From 51e1834e81cef95759a952c91a558ed965ab7de2 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 21 Sep 2024 04:33:02 +0900 Subject: [PATCH] d3d12: Use D3D12_FILTER_MIN_MAG_MIP_LINEAR filter by default ... instead of D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, since we supports mipmap texture now. Part-of: --- .../gst-libs/gst/d3d12/gstd3d12converter.cpp | 18 ++++++++++-------- .../gst-libs/gst/d3d12/gstd3d12converter.h | 3 ++- .../gst-libs/gst/d3d12/gstd3d12device.cpp | 1 + .../sys/d3d12/gstd3d12pluginutils.cpp | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp index 14f69660ae..1df84c6696 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp @@ -55,6 +55,8 @@ gst_d3d12_converter_sampler_filter_get_type (void) "D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT", "min-linear-mag-mip-point"}, {D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, "D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT", "min-mag-linear-mip-point"}, + {D3D12_FILTER_MIN_MAG_MIP_LINEAR, + "D3D12_FILTER_MIN_MAG_MIP_LINEAR", "min-mag-mip-linear"}, {D3D12_FILTER_ANISOTROPIC, "D3D12_FILTER_ANISOTROPIC", "anisotropic"}, {0, nullptr, nullptr}, }; @@ -95,6 +97,7 @@ using namespace DirectX; #define GAMMA_LUT_SIZE 4096 #define DEFAULT_BUFFER_COUNT 2 +#define DEFAULT_SAMPLER_FILTER D3D12_FILTER_MIN_MAG_MIP_LINEAR static const WORD g_indices[6] = { 0, 1, 2, 3, 0, 2 }; struct PSColorSpace @@ -321,7 +324,7 @@ struct _GstD3D12ConverterPrivate GST_D3D12_CONVERTER_ALPHA_MODE_UNSPECIFIED; GstD3D12ConverterAlphaMode dst_alpha_mode = GST_D3D12_CONVERTER_ALPHA_MODE_UNSPECIFIED; - D3D12_FILTER sampler_filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; + D3D12_FILTER sampler_filter = DEFAULT_SAMPLER_FILTER; }; /* *INDENT-ON* */ @@ -392,7 +395,7 @@ gst_d3d12_converter_class_init (GstD3D12ConverterClass * klass) g_object_class_install_property (object_class, PROP_SAMPLER_FILTER, g_param_spec_enum ("sampler-filter", "Sampler Filter", "Sampler Filter", GST_TYPE_D3D12_CONVERTER_SAMPLER_FILTER, - D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, param_flags)); + DEFAULT_SAMPLER_FILTER, param_flags)); GST_DEBUG_CATEGORY_INIT (gst_d3d12_converter_debug, "d3d12converter", 0, "d3d12converter"); @@ -710,10 +713,9 @@ gst_d3d12_converter_create_sampler (GstD3D12Converter * self, GetCPUDescriptorHandleForHeapStart (sampler_heap), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - if (filter != D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT) { + if (filter != DEFAULT_SAMPLER_FILTER) { hr = gst_d3d12_device_get_sampler_state (self->device, - D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, - sampler_heap.ReleaseAndGetAddressOf ()); + DEFAULT_SAMPLER_FILTER, sampler_heap.ReleaseAndGetAddressOf ()); if (!gst_d3d12_result (hr, self->device)) { GST_ERROR_OBJECT (self, "Couldn't create sampler heap"); @@ -775,8 +777,8 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self, if (!gst_d3d12_converter_create_sampler (self, sampler_filter, &priv->sampler_heap)) { - if (sampler_filter != D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT) { - sampler_filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; + if (sampler_filter != DEFAULT_SAMPLER_FILTER) { + sampler_filter = DEFAULT_SAMPLER_FILTER; if (!gst_d3d12_converter_create_sampler (self, sampler_filter, &priv->sampler_heap)) { return FALSE; @@ -1884,7 +1886,7 @@ gst_d3d12_converter_new (GstD3D12Device * device, GstD3D12CommandQueue * queue, GstD3D12Format out_d3d12_format; gboolean allow_gamma = FALSE; gboolean allow_primaries = FALSE; - D3D12_FILTER sampler_filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; + D3D12_FILTER sampler_filter = DEFAULT_SAMPLER_FILTER; GstVideoInfo matrix_in_info; GstVideoInfo matrix_out_info; guint sample_count = 1; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.h index dd90623816..936ba90c80 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.h @@ -62,9 +62,10 @@ G_BEGIN_DECLS * @D3D12_FILTER_MIN_MAG_MIP_POINT * @D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT * @D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT + * @D3D12_FILTER_MIN_MAG_MIP_LINEAR * @D3D12_FILTER_ANISOTROPIC * - * Default is #D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT. + * Default is #D3D12_FILTER_MIN_MAG_MIP_LINEAR. * * Since: 1.26 */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp index 8422c78e68..29bbcc4ee9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp @@ -2175,6 +2175,7 @@ gst_d3d12_device_get_sampler_state (GstD3D12Device * device, case D3D12_FILTER_MIN_MAG_MIP_POINT: case D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT: case D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT: + case D3D12_FILTER_MIN_MAG_MIP_LINEAR: break; case D3D12_FILTER_ANISOTROPIC: max_anisotropy = 16; diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp index b625db1ce6..890295adbb 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp @@ -77,7 +77,7 @@ struct SamplingMethodMap static const SamplingMethodMap sampling_method_map[] = { {GST_D3D12_SAMPLING_METHOD_NEAREST, D3D12_FILTER_MIN_MAG_MIP_POINT}, - {GST_D3D12_SAMPLING_METHOD_BILINEAR, D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT}, + {GST_D3D12_SAMPLING_METHOD_BILINEAR, D3D12_FILTER_MIN_MAG_MIP_LINEAR}, {GST_D3D12_SAMPLING_METHOD_LINEAR_MINIFICATION, D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT}, {GST_D3D12_SAMPLING_METHOD_ANISOTROPIC, D3D12_FILTER_ANISOTROPIC},