From: Zebediah Figura Subject: [PATCH vkd3d v2 3/3] vkd3d-utils: Introduce D3DCreateBlob(). Message-Id: <20200922223430.186685-3-zfigura@codeweavers.com> Date: Tue, 22 Sep 2020 17:34:30 -0500 In-Reply-To: <20200922223430.186685-1-zfigura@codeweavers.com> References: <20200922223430.186685-1-zfigura@codeweavers.com> Signed-off-by: Zebediah Figura --- Makefile.am | 1 + include/vkd3d_d3dcompiler.h | 26 ++++++++++++++++++++++++++ include/vkd3d_utils.h | 3 +++ libs/vkd3d-utils/vkd3d_utils.map | 1 + libs/vkd3d-utils/vkd3d_utils_main.c | 18 ++++++++++++++++++ libs/vkd3d-utils/vkd3d_utils_private.h | 1 + 6 files changed, 50 insertions(+) create mode 100644 include/vkd3d_d3dcompiler.h diff --git a/Makefile.am b/Makefile.am index d9745456..b77fc7db 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,7 @@ vkd3d_public_headers = \ include/vkd3d_d3d12.h \ include/vkd3d_d3d12sdklayers.h \ include/vkd3d_d3dcommon.h \ + include/vkd3d_d3dcompiler.h \ include/vkd3d_dxgibase.h \ include/vkd3d_dxgiformat.h \ include/vkd3d_shader.h \ diff --git a/include/vkd3d_d3dcompiler.h b/include/vkd3d_d3dcompiler.h new file mode 100644 index 00000000..25f60449 --- /dev/null +++ b/include/vkd3d_d3dcompiler.h @@ -0,0 +1,26 @@ +/* + * Copyright 2010 Matteo Bruni for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#ifndef __VKD3D_D3DCOMPILER_H +#define __VKD3D_D3DCOMPILER_H +#ifndef __D3DCOMPILER_H__ + +HRESULT WINAPI D3DCreateBlob(SIZE_T size, ID3D10Blob **blob); + +#endif /* __D3DCOMPILER_H__ */ +#endif /* __VKD3D_D3DCOMPILER_H */ diff --git a/include/vkd3d_utils.h b/include/vkd3d_utils.h index 02687ed6..f1fc4dbd 100644 --- a/include/vkd3d_utils.h +++ b/include/vkd3d_utils.h @@ -54,6 +54,9 @@ HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc, ID3DBlob **blob, ID3DBlob **error_blob); +/* 1.3 */ +HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3D10Blob **blob); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/libs/vkd3d-utils/vkd3d_utils.map b/libs/vkd3d-utils/vkd3d_utils.map index fb391240..20d182c5 100644 --- a/libs/vkd3d-utils/vkd3d_utils.map +++ b/libs/vkd3d-utils/vkd3d_utils.map @@ -8,6 +8,7 @@ global: D3D12GetDebugInterface; D3D12SerializeRootSignature; D3D12SerializeVersionedRootSignature; + D3DCreateBlob; vkd3d_create_event; vkd3d_destroy_event; vkd3d_signal_event; diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index c19fe7f1..6a2d709a 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -232,3 +232,21 @@ void vkd3d_destroy_event(HANDLE event) ERR("Failed to destroy condition variable, error %d.\n", rc); vkd3d_free(impl); } + +HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3D10Blob **blob) +{ + void *data; + int ret; + + TRACE("data_size %lu, blob %p.\n", data_size, blob); + + if (!(data = vkd3d_calloc(data_size, 1))) + return E_OUTOFMEMORY; + + if ((ret = vkd3d_shader_create_blob(data, data_size, vkd3d_free, data, blob)) < 0) + { + WARN("Failed to create blob object, vkd3d result %d.\n", ret); + vkd3d_free(data); + } + return hresult_from_vkd3d_result(ret); +} diff --git a/libs/vkd3d-utils/vkd3d_utils_private.h b/libs/vkd3d-utils/vkd3d_utils_private.h index 6b5851e6..0de7d325 100644 --- a/libs/vkd3d-utils/vkd3d_utils_private.h +++ b/libs/vkd3d-utils/vkd3d_utils_private.h @@ -25,6 +25,7 @@ #include #include +#include #include "vkd3d_memory.h" #include -- 2.28.0