[vlc-commits] [Git][videolan/vlc][master] 3 commits: d3d_dynamic_shader: make d3d_shader_compiler_t private
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri Feb 25 15:36:55 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
339cfeeb by Steve Lhomme at 2022-02-25T14:26:21+00:00
d3d_dynamic_shader: make d3d_shader_compiler_t private
This will allow changing the internals without the caller knowing about it.
- - - - -
5576161d by Steve Lhomme at 2022-02-25T14:26:21+00:00
d3d_shaders: compile v5 shader with D3D12 feature level
- - - - -
25d20933 by Steve Lhomme at 2022-02-25T14:26:21+00:00
d3d_shaders: remove unused includes
- - - - -
5 changed files:
- modules/video_output/win32/d3d_dynamic_shader.c
- modules/video_output/win32/d3d_dynamic_shader.h
- modules/video_output/win32/d3d_shaders.c
- modules/video_output/win32/d3d_shaders.h
- modules/video_output/win32/direct3d11.cpp
Changes:
=====================================
modules/video_output/win32/d3d_dynamic_shader.c
=====================================
@@ -35,6 +35,12 @@
#include "d3d_shaders.h"
#include "d3d_dynamic_shader.h"
+struct d3d_shader_compiler_t
+{
+ HINSTANCE compiler_dll; /* handle of the opened d3dcompiler dll */
+ pD3DCompile OurD3DCompile;
+};
+
static const char globPixelShaderDefault[] = "\
#pragma warning( disable: 3571 )\n\
cbuffer PS_CONSTANT_BUFFER : register(b0)\n\
@@ -338,7 +344,9 @@ static HRESULT CompileShader(vlc_object_t *obj, const d3d_shader_compiler_t *com
const char *target;
if (pixelShader)
{
- if (likely(feature_level >= D3D_FEATURE_LEVEL_10_0))
+ if (feature_level >= D3D_FEATURE_LEVEL_12_0)
+ target = "ps_5_0";
+ else if (likely(feature_level >= D3D_FEATURE_LEVEL_10_0))
target = "ps_4_0";
else if (feature_level >= D3D_FEATURE_LEVEL_9_3)
target = "ps_4_0_level_9_3";
@@ -347,7 +355,9 @@ static HRESULT CompileShader(vlc_object_t *obj, const d3d_shader_compiler_t *com
}
else
{
- if (likely(feature_level >= D3D_FEATURE_LEVEL_10_0))
+ if (feature_level >= D3D_FEATURE_LEVEL_12_0)
+ target = "vs_5_0";
+ else if (likely(feature_level >= D3D_FEATURE_LEVEL_10_0))
target = "vs_4_0";
else if (feature_level >= D3D_FEATURE_LEVEL_9_3)
target = "vs_4_0_level_9_3";
@@ -730,25 +740,28 @@ HRESULT D3D_CompileVertexShader(vlc_object_t *obj, const d3d_shader_compiler_t *
}
-int D3D_InitShaderCompiler(vlc_object_t *obj, d3d_shader_compiler_t *compiler)
+int D3D_CreateShaderCompiler(vlc_object_t *obj, d3d_shader_compiler_t **compiler)
{
+ *compiler = calloc(1, sizeof(d3d_shader_compiler_t));
+ if (unlikely(*compiler == NULL))
+ return VLC_ENOMEM;
#ifndef VLC_WINSTORE_APP
/* d3dcompiler_47 is the latest on windows 10 */
for (int i = 47; i > 41; --i)
{
WCHAR filename[19];
_snwprintf(filename, ARRAY_SIZE(filename), TEXT("D3DCOMPILER_%d.dll"), i);
- compiler->compiler_dll = LoadLibrary(filename);
- if (compiler->compiler_dll) break;
+ (*compiler)->compiler_dll = LoadLibrary(filename);
+ if ((*compiler)->compiler_dll) break;
}
- if (compiler->compiler_dll)
- {
- compiler->OurD3DCompile = (void *)GetProcAddress(compiler->compiler_dll, "D3DCompile");
- if (!compiler->OurD3DCompile) {
- msg_Err(obj, "Cannot locate reference to D3DCompile in d3dcompiler DLL");
- FreeLibrary(compiler->compiler_dll);
- return VLC_EGENERIC;
- }
+ if ((*compiler)->compiler_dll)
+ (*compiler)->OurD3DCompile = (pD3DCompile)((void*)GetProcAddress((*compiler)->compiler_dll, "D3DCompile"));
+
+ if (!(*compiler)->OurD3DCompile) {
+ msg_Err(obj, "Cannot locate reference to D3DCompile in d3dcompiler DLL");
+ FreeLibrary((*compiler)->compiler_dll);
+ free(*compiler);
+ return VLC_EGENERIC;
}
#endif // !VLC_WINSTORE_APP
@@ -759,11 +772,8 @@ void D3D_ReleaseShaderCompiler(d3d_shader_compiler_t *compiler)
{
#ifndef VLC_WINSTORE_APP
if (compiler->compiler_dll)
- {
FreeLibrary(compiler->compiler_dll);
- compiler->compiler_dll = NULL;
- }
- compiler->OurD3DCompile = NULL;
#endif // !VLC_WINSTORE_APP
+ free(compiler);
}
=====================================
modules/video_output/win32/d3d_dynamic_shader.h
=====================================
@@ -23,17 +23,15 @@
#ifndef VLC_D3D_DYNAMIC_SHADER_H
#define VLC_D3D_DYNAMIC_SHADER_H
+#include <d3dcommon.h>
+
#ifdef __cplusplus
extern "C" {
#endif// __cplusplus
-typedef struct
-{
- HINSTANCE compiler_dll; /* handle of the opened d3dcompiler dll */
- pD3DCompile OurD3DCompile;
-} d3d_shader_compiler_t;
+typedef struct d3d_shader_compiler_t d3d_shader_compiler_t;
-int D3D_InitShaderCompiler(vlc_object_t *, d3d_shader_compiler_t *);
+int D3D_CreateShaderCompiler(vlc_object_t *, d3d_shader_compiler_t **);
void D3D_ReleaseShaderCompiler(d3d_shader_compiler_t *);
HRESULT D3D_CompilePixelShader(vlc_object_t *, const d3d_shader_compiler_t *,
=====================================
modules/video_output/win32/d3d_shaders.c
=====================================
@@ -30,9 +30,7 @@
#include "common.h"
-#define COBJMACROS
#include "d3d_shaders.h"
-#include "d3d_dynamic_shader.h"
#define SPHERE_RADIUS 1.f
=====================================
modules/video_output/win32/d3d_shaders.h
=====================================
@@ -23,8 +23,6 @@
#ifndef VLC_D3D_SHADERS_H
#define VLC_D3D_SHADERS_H
-#include <d3dcompiler.h> // for pD3DCompile
-
#include "../../video_chroma/dxgi_fmt.h"
#include <vlc_es.h>
=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -92,7 +92,7 @@ typedef struct vout_display_sys_t
d3d11_device_t *d3d_dev = NULL;
d3d11_decoder_device_t *local_d3d_dev = NULL; // when opened without a video context
- d3d_shader_compiler_t shaders = {};
+ d3d_shader_compiler_t *shaders = nullptr;
d3d11_quad_t picQuad;
#ifdef HAVE_D3D11_4_H
@@ -356,7 +356,7 @@ static int Open(vout_display_t *vd,
d3d11_decoder_device_t *dev_sys = NULL;
- int ret = D3D_InitShaderCompiler(VLC_OBJECT(vd), &sys->shaders);
+ int ret = D3D_CreateShaderCompiler(VLC_OBJECT(vd), &sys->shaders);
if (ret != VLC_SUCCESS)
goto error;
@@ -452,7 +452,7 @@ error:
static void Close(vout_display_t *vd)
{
vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
- D3D_ReleaseShaderCompiler(&sys->shaders);
+ D3D_ReleaseShaderCompiler(sys->shaders);
#ifndef VLC_WINSTORE_APP
UnhookWindowsSensors(sys->p_sensors);
CommonWindowClean(&sys->sys);
@@ -1033,7 +1033,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
BogusZeroCopy(vd) || !is_d3d11_opaque(fmt->i_chroma);
d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET] = { };
- hr = D3D11_CompilePixelShaderBlob(vd, &sys->shaders, sys->d3d_dev,
+ hr = D3D11_CompilePixelShaderBlob(vd, sys->shaders, sys->d3d_dev,
&sys->display, fmt->transfer,
fmt->color_range == COLOR_RANGE_FULL,
&sys->picQuad, pPSBlob);
@@ -1161,7 +1161,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
if (sys->regionQuad.generic.textureFormat != NULL)
{
d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET] = { };
- hr = D3D11_CompilePixelShaderBlob(vd, &sys->shaders, sys->d3d_dev,
+ hr = D3D11_CompilePixelShaderBlob(vd, sys->shaders, sys->d3d_dev,
&sys->display, TRANSFER_FUNC_SRGB, true,
&sys->regionQuad, pPSBlob);
if (FAILED(hr))
@@ -1179,7 +1179,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
}
d3d_shader_blob VSBlob = { };
- hr = D3D11_CompileVertexShaderBlob(VLC_OBJECT(vd), &sys->shaders, sys->d3d_dev, true, &VSBlob);
+ hr = D3D11_CompileVertexShaderBlob(VLC_OBJECT(vd), sys->shaders, sys->d3d_dev, true, &VSBlob);
if(FAILED(hr)) {
msg_Err(vd, "Failed to compile the flat vertex shader. (hr=0x%lX)", hr);
return VLC_EGENERIC;
@@ -1191,7 +1191,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
}
- hr = D3D11_CompileVertexShaderBlob(VLC_OBJECT(vd), &sys->shaders, sys->d3d_dev, false, &VSBlob);
+ hr = D3D11_CompileVertexShaderBlob(VLC_OBJECT(vd), sys->shaders, sys->d3d_dev, false, &VSBlob);
if(FAILED(hr)) {
msg_Err(vd, "Failed to compile the 360 vertex shader. (hr=0x%lX)", hr);
return VLC_EGENERIC;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/331194a85c57bd7284d641c3dd3b3bad3d6465c9...25d209333398b01d06bad0e71ea5afa3bc0225c3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/331194a85c57bd7284d641c3dd3b3bad3d6465c9...25d209333398b01d06bad0e71ea5afa3bc0225c3
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list