#include "util/u_memory.h"
#include "util/u_prim.h"
#include "util/u_simple_shaders.h"
+#include "util/u_dl.h"
#include <directx/d3d12.h>
#include <dxguids/dxguids.h>
~HModule();
bool load(LPCSTR file_name);
- operator HMODULE () const;
+ operator util_dl_library *() const;
private:
- HMODULE module;
+ util_dl_library *module;
};
HModule dxil_module;
void d3d12_validation_tools::load_dxil_dll()
{
- if (!dxil_module.load("dxil.dll")) {
+ if (!dxil_module.load(UTIL_DL_PREFIX "dxil" UTIL_DL_EXT)) {
char selfPath[MAX_PATH] = "";
uint32_t pathSize = GetModuleFileNameA((HINSTANCE)&__ImageBase, selfPath, sizeof(selfPath));
if (pathSize == 0 || pathSize == sizeof(selfPath)) {
d3d12_validation_tools::d3d12_validation_tools()
{
load_dxil_dll();
- DxcCreateInstanceProc dxil_create_func = (DxcCreateInstanceProc)GetProcAddress(dxil_module, "DxcCreateInstance");
+ DxcCreateInstanceProc dxil_create_func = (DxcCreateInstanceProc)util_dl_get_proc_address(dxil_module, "DxcCreateInstance");
assert(dxil_create_func);
HRESULT hr = dxil_create_func(CLSID_DxcValidator, IID_PPV_ARGS(&validator));
DxcCreateInstanceProc compiler_create_func = nullptr;
if(dxc_compiler_module.load("dxcompiler.dll"))
- compiler_create_func = (DxcCreateInstanceProc)GetProcAddress(dxc_compiler_module, "DxcCreateInstance");
+ compiler_create_func = (DxcCreateInstanceProc)util_dl_get_proc_address(dxc_compiler_module, "DxcCreateInstance");
if (compiler_create_func) {
hr = compiler_create_func(CLSID_DxcLibrary, IID_PPV_ARGS(&library));
d3d12_validation_tools::HModule::~HModule()
{
if (module)
- ::FreeLibrary(module);
+ util_dl_close(module);
}
inline
-d3d12_validation_tools::HModule::operator HMODULE () const
+d3d12_validation_tools::HModule::operator util_dl_library * () const
{
return module;
}
bool
d3d12_validation_tools::HModule::load(LPCSTR file_name)
{
- module = ::LoadLibrary(file_name);
+ module = util_dl_open(file_name);
return module != nullptr;
}
#include "util/u_memory.h"
#include "util/u_upload_mgr.h"
#include "util/u_pstipple.h"
+#include "util/u_dl.h"
#include "nir_to_dxil.h"
#include "D3D12ResourceState.h"
d3d12_root_signature_cache_init(ctx);
d3d12_gs_variant_cache_init(ctx);
- HMODULE hD3D12Mod = LoadLibrary("D3D12.DLL");
- if (!hD3D12Mod) {
+ util_dl_library *d3d12_mod = util_dl_open(UTIL_DL_PREFIX "d3d12" UTIL_DL_EXT);
+ if (!d3d12_mod) {
debug_printf("D3D12: failed to load D3D12.DLL\n");
return NULL;
}
ctx->D3D12SerializeVersionedRootSignature =
- (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)GetProcAddress(hD3D12Mod, "D3D12SerializeVersionedRootSignature");
+ (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)util_dl_get_proc_address(d3d12_mod, "D3D12SerializeVersionedRootSignature");
if (FAILED(screen->dev->CreateFence(0, D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&ctx->cmdqueue_fence)))) {
#include "util/debug.h"
#include "util/u_memory.h"
+#include "util/u_dl.h"
#include <directx/dxcore.h>
#include <dxguids/dxguids.h>
typedef HRESULT(WINAPI *PFN_CREATE_DXCORE_ADAPTER_FACTORY)(REFIID riid, void **ppFactory);
PFN_CREATE_DXCORE_ADAPTER_FACTORY DXCoreCreateAdapterFactory;
- HMODULE hDXCoreMod = LoadLibrary("DXCore.DLL");
- if (!hDXCoreMod) {
+ util_dl_library *dxcore_mod = util_dl_open(UTIL_DL_PREFIX "dxcore" UTIL_DL_EXT);
+ if (!dxcore_mod) {
debug_printf("D3D12: failed to load DXCore.DLL\n");
return NULL;
}
- DXCoreCreateAdapterFactory = (PFN_CREATE_DXCORE_ADAPTER_FACTORY)GetProcAddress(hDXCoreMod, "DXCoreCreateAdapterFactory");
+ DXCoreCreateAdapterFactory = (PFN_CREATE_DXCORE_ADAPTER_FACTORY)util_dl_get_proc_address(dxcore_mod, "DXCoreCreateAdapterFactory");
if (!DXCoreCreateAdapterFactory) {
debug_printf("D3D12: failed to load DXCoreCreateAdapterFactory from DXCore.DLL\n");
return NULL;
#include "util/debug.h"
#include "util/u_memory.h"
+#include "util/u_dl.h"
#include <dxgi1_4.h>
typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactory;
- HMODULE hDXGIMod = LoadLibrary("DXGI.DLL");
- if (!hDXGIMod) {
+ util_dl_library *dxgi_mod = util_dl_open(UTIL_DL_PREFIX "dxgi" UTIL_DL_EXT);
+ if (!dxgi_mod) {
debug_printf("D3D12: failed to load DXGI.DLL\n");
return NULL;
}
- CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)GetProcAddress(hDXGIMod, "CreateDXGIFactory");
+ CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)util_dl_get_proc_address(dxgi_mod, "CreateDXGIFactory");
if (!CreateDXGIFactory) {
debug_printf("D3D12: failed to load CreateDXGIFactory from DXGI.DLL\n");
return NULL;
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_screen.h"
+#include "util/u_dl.h"
#include "nir.h"
#include "frontend/sw_winsys.h"
typedef HRESULT(WINAPI *PFN_D3D12_GET_DEBUG_INTERFACE)(REFIID riid, void **ppFactory);
PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterface;
- HMODULE hD3D12Mod = LoadLibrary("D3D12.DLL");
- if (!hD3D12Mod) {
+ util_dl_library *d3d12_mod = util_dl_open(UTIL_DL_PREFIX "d3d12" UTIL_DL_EXT);
+ if (!d3d12_mod) {
debug_printf("D3D12: failed to load D3D12.DLL\n");
return NULL;
}
- D3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(hD3D12Mod, "D3D12GetDebugInterface");
+ D3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)util_dl_get_proc_address(d3d12_mod, "D3D12GetDebugInterface");
if (!D3D12GetDebugInterface) {
debug_printf("D3D12: failed to load D3D12GetDebugInterface from D3D12.DLL\n");
return NULL;
PFN_D3D12CREATEDEVICE D3D12CreateDevice;
PFN_D3D12ENABLEEXPERIMENTALFEATURES D3D12EnableExperimentalFeatures;
- HMODULE hD3D12Mod = LoadLibrary("D3D12.DLL");
- if (!hD3D12Mod) {
+ util_dl_library *d3d12_mod = util_dl_open(UTIL_DL_PREFIX "d3d12" UTIL_DL_EXT);
+ if (!d3d12_mod) {
debug_printf("D3D12: failed to load D3D12.DLL\n");
return NULL;
}
if (d3d12_debug & D3D12_DEBUG_EXPERIMENTAL) {
- D3D12EnableExperimentalFeatures = (PFN_D3D12ENABLEEXPERIMENTALFEATURES)GetProcAddress(hD3D12Mod, "D3D12EnableExperimentalFeatures");
+ D3D12EnableExperimentalFeatures = (PFN_D3D12ENABLEEXPERIMENTALFEATURES)util_dl_get_proc_address(d3d12_mod, "D3D12EnableExperimentalFeatures");
D3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModels, NULL, NULL);
}
- D3D12CreateDevice = (PFN_D3D12CREATEDEVICE)GetProcAddress(hD3D12Mod, "D3D12CreateDevice");
+ D3D12CreateDevice = (PFN_D3D12CREATEDEVICE)util_dl_get_proc_address(d3d12_mod, "D3D12CreateDevice");
if (!D3D12CreateDevice) {
debug_printf("D3D12: failed to load D3D12CreateDevice from D3D12.DLL\n");
return NULL;