Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dcompiler_43/blob.c | 25 ++++++++++++++++++++--- dlls/d3dcompiler_43/tests/blob.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dcompiler_43/blob.c b/dlls/d3dcompiler_43/blob.c index 5cc49fe5699..f220eeb6962 100644 --- a/dlls/d3dcompiler_43/blob.c +++ b/dlls/d3dcompiler_43/blob.c @@ -514,9 +514,28 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents) return S_OK; }
-HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob* blob, const WCHAR *filename, BOOL overwrite) +HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob *blob, const WCHAR *filename, BOOL overwrite) { - FIXME("blob %p, filename %s, overwrite %d\n", blob, debugstr_w(filename), overwrite); + DWORD written_size; + SIZE_T data_size; + HANDLE file; + BOOL ret; + + TRACE("blob %p, filename %s, overwrite %d.\n", blob, debugstr_w(filename), overwrite); + + file = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, overwrite ? CREATE_ALWAYS : CREATE_NEW, + FILE_ATTRIBUTE_NORMAL, NULL); + if (file == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(GetLastError());
- return E_NOTIMPL; + data_size = ID3D10Blob_GetBufferSize(blob); + ret = WriteFile(file, ID3D10Blob_GetBufferPointer(blob), data_size, &written_size, NULL); + CloseHandle(file); + if (!ret || data_size != written_size) + { + WARN("Failed to write blob contents.\n"); + return E_FAIL; + } + + return S_OK; } diff --git a/dlls/d3dcompiler_43/tests/blob.c b/dlls/d3dcompiler_43/tests/blob.c index 3e1a3aa3da3..b59611f7eb6 100644 --- a/dlls/d3dcompiler_43/tests/blob.c +++ b/dlls/d3dcompiler_43/tests/blob.c @@ -36,6 +36,7 @@ static HRESULT (WINAPI *pD3DCreateBlob)(SIZE_T, ID3DBlob **); static HRESULT (WINAPI *pD3DGetBlobPart)(const void *, SIZE_T, D3D_BLOB_PART, UINT, ID3DBlob **); static HRESULT (WINAPI *pD3DReadFileToBlob)(const WCHAR *, ID3DBlob **); +static HRESULT (WINAPI *pD3DWriteBlobToFile)(ID3DBlob *blob, const WCHAR *filename, BOOL overwrite); static HRESULT (WINAPI *pD3DStripShader)(const void *, SIZE_T, UINT, ID3DBlob **);
#define MAKE_TAG(ch0, ch1, ch2, ch3) \ @@ -761,6 +762,8 @@ static BOOL load_d3dcompiler_47(void) return FALSE;
pD3DReadFileToBlob = (void *)GetProcAddress(module, "D3DReadFileToBlob"); + pD3DWriteBlobToFile = (void *)GetProcAddress(module, "D3DWriteBlobToFile"); + pD3DCreateBlob = (void *)GetProcAddress(module, "D3DCreateBlob"); return TRUE; }
@@ -862,6 +865,37 @@ static void test_D3DReadFileToBlob(void) ID3D10Blob_Release(blob); }
+static void test_D3DWriteBlobToFile(void) +{ + WCHAR temp_dir[MAX_PATH], filename[MAX_PATH]; + ID3DBlob *blob; + HRESULT hr; + + GetTempPathW(ARRAY_SIZE(temp_dir), temp_dir); + GetTempFileNameW(temp_dir, NULL, 0, filename); + + hr = pD3DCreateBlob(16, &blob); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = pD3DWriteBlobToFile(blob, filename, FALSE); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr); + + hr = pD3DWriteBlobToFile(blob, filename, TRUE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + DeleteFileW(filename); + + hr = pD3DWriteBlobToFile(blob, filename, FALSE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = pD3DWriteBlobToFile(blob, filename, FALSE); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr); + + DeleteFileW(filename); + + ID3D10Blob_Release(blob); +} + START_TEST(blob) { if (load_d3dcompiler_43()) @@ -878,6 +912,7 @@ START_TEST(blob) if (load_d3dcompiler_47()) { test_D3DReadFileToBlob(); + test_D3DWriteBlobToFile(); } else {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106020
Your paranoid android.
=== build (build log) ===
WineRunBuild.pl:error: An error occurred while waiting for the build to complete: network read timed out (wait2:ListSize:0/4) WineRunBuild.pl:error: BotError: The test VM has crashed, rebooted or lost connectivity (or the TestAgent server died)