Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 219 +++++++++++++++++++++---------------- 1 file changed, 127 insertions(+), 92 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 0f928284534..654467a0bdb 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -276,7 +276,7 @@ static HWND create_window(void) 0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL); }
-static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window) +static IDirect3DDevice9 *create_d3d9_device(IDirect3D9 *d3d9, HWND focus_window) { D3DPRESENT_PARAMETERS present_parameters = {0}; IDirect3DDevice9 *device = NULL; @@ -6080,7 +6080,7 @@ static void test_MFCreateDXSurfaceBuffer(void) window = create_window(); d3d = Direct3DCreate9(D3D_SDK_VERSION); ok(!!d3d, "Failed to create a D3D object.\n"); - if (!(device = create_device(d3d, window))) + if (!(device = create_d3d9_device(d3d, window))) { skip("Failed to create a D3D device, skipping tests.\n"); goto done; @@ -6768,50 +6768,23 @@ static void test_dxgi_surface_buffer(void) ID3D11Device_Release(device); }
-static void test_sample_allocator(void) +static void test_sample_allocator_sysmem(void) { IMFVideoSampleAllocatorNotify test_notify = { &test_notify_callback_vtbl }; IMFMediaType *media_type, *video_type, *video_type2; IMFVideoSampleAllocatorCallback *allocator_cb; IMFVideoSampleAllocatorEx *allocatorex; - IDirect3DDeviceManager9 *d3d9_manager; IMFVideoSampleAllocator *allocator; - unsigned int i, buffer_count, token; - IDirect3DDevice9 *d3d9_device; - IMFDXGIDeviceManager *manager; + unsigned int buffer_count; IMFSample *sample, *sample2; - IMFDXGIBuffer *dxgi_buffer; IMFAttributes *attributes; - D3D11_TEXTURE2D_DESC desc; - ID3D11Texture2D *texture; IMFMediaBuffer *buffer; - ID3D11Device *device; LONG refcount, count; - IDirect3D9 *d3d9; IUnknown *unk; HRESULT hr; - BYTE *data; - HWND window; - static const unsigned int usage[] = - { - D3D11_USAGE_DEFAULT, - D3D11_USAGE_IMMUTABLE, - D3D11_USAGE_DYNAMIC, - D3D11_USAGE_STAGING, - D3D11_USAGE_STAGING + 1, - }; - static const unsigned int sharing[] = - { - D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, - D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, - D3D11_RESOURCE_MISC_SHARED, - };
if (!pMFCreateVideoSampleAllocatorEx) - { - win_skip("MFCreateVideoSampleAllocatorEx() is not available.\n"); return; - }
hr = pMFCreateVideoSampleAllocatorEx(&IID_IUnknown, (void **)&unk); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -7022,8 +6995,113 @@ todo_wine IMFVideoSampleAllocatorCallback_Release(allocator_cb); IMFVideoSampleAllocatorEx_Release(allocatorex); IMFAttributes_Release(attributes); +} + +static void test_sample_allocator_d3d9(void) +{ + IDirect3DDeviceManager9 *d3d9_manager; + IMFVideoSampleAllocator *allocator; + IDirect3DDevice9 *d3d9_device; + IMFMediaType *video_type; + IMFMediaBuffer *buffer; + unsigned int token; + IMFSample *sample; + IDirect3D9 *d3d9; + HWND window; + HRESULT hr; + + if (!pMFCreateVideoSampleAllocatorEx) + return; + + window = create_window(); + d3d9 = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d9, "Failed to create a D3D9 object.\n"); + if (!(d3d9_device = create_d3d9_device(d3d9, window))) + { + skip("Failed to create a D3D9 device, skipping tests.\n"); + goto done; + } + + hr = DXVA2CreateDirect3DDeviceManager9(&token, &d3d9_manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_ResetDevice(d3d9_manager, d3d9_device, token); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = pMFCreateVideoSampleAllocatorEx(&IID_IMFVideoSampleAllocator, (void **)&allocator); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, (IUnknown *)d3d9_manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + video_type = create_video_type(&MFVideoFormat_RGB32); + + /* Frame size is required. */ + hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 64 << 32 | 64); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 1, video_type); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + check_interface(sample, &IID_IMFTrackedSample, TRUE); + check_interface(sample, &IID_IMFDesiredSample, FALSE); + + hr = IMFSample_GetBufferByIndex(sample, 0, &buffer); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + check_interface(buffer, &IID_IMF2DBuffer, TRUE); + check_interface(buffer, &IID_IMF2DBuffer2, TRUE); + check_interface(buffer, &IID_IMFGetService, TRUE); + check_interface(buffer, &IID_IMFDXGIBuffer, FALSE); + + IMFSample_Release(sample); + IMFMediaBuffer_Release(buffer); + + IMFVideoSampleAllocator_Release(allocator); + IMFMediaType_Release(video_type); + +done: + IDirect3D9_Release(d3d9); + DestroyWindow(window); +} + +static void test_sample_allocator_d3d11(void) +{ + IMFMediaType *video_type; + IMFVideoSampleAllocatorEx *allocatorex; + IMFVideoSampleAllocator *allocator; + unsigned int i, token; + IMFDXGIDeviceManager *manager; + IMFSample *sample; + IMFDXGIBuffer *dxgi_buffer; + IMFAttributes *attributes; + D3D11_TEXTURE2D_DESC desc; + ID3D11Texture2D *texture; + IMFMediaBuffer *buffer; + ID3D11Device *device; + HRESULT hr; + BYTE *data; + static const unsigned int usage[] = + { + D3D11_USAGE_DEFAULT, + D3D11_USAGE_IMMUTABLE, + D3D11_USAGE_DYNAMIC, + D3D11_USAGE_STAGING, + D3D11_USAGE_STAGING + 1, + }; + static const unsigned int sharing[] = + { + D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, + D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, + D3D11_RESOURCE_MISC_SHARED, + }; + + if (!pMFCreateVideoSampleAllocatorEx) + return;
- /* Using device manager */ if (!(device = create_d3d11_device())) { skip("Failed to create a D3D11 device, skipping tests.\n"); @@ -7044,8 +7122,9 @@ todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); EXPECT_REF(manager, 2);
- hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 0, video_type); - ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + video_type = create_video_type(&MFVideoFormat_RGB32); + hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 64 << 32 | 64); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 1, video_type); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -7068,18 +7147,18 @@ todo_wine ok(hr == S_OK, "Failed to get resource, hr %#x.\n", hr);
ID3D11Texture2D_GetDesc(texture, &desc); - ok(desc.Width == 320, "Unexpected width %u.\n", desc.Width); - ok(desc.Height == 240, "Unexpected height %u.\n", desc.Height); + ok(desc.Width == 64, "Unexpected width %u.\n", desc.Width); + ok(desc.Height == 64, "Unexpected height %u.\n", desc.Height); ok(desc.MipLevels == 1, "Unexpected miplevels %u.\n", desc.MipLevels); ok(desc.ArraySize == 1, "Unexpected array size %u.\n", desc.ArraySize); ok(desc.Format == DXGI_FORMAT_B8G8R8X8_UNORM, "Unexpected format %u.\n", desc.Format); ok(desc.SampleDesc.Count == 1, "Unexpected sample count %u.\n", desc.SampleDesc.Count); - ok(desc.SampleDesc.Quality == 0, "Unexpected sample quality %u.\n", desc.SampleDesc.Quality); + ok(!desc.SampleDesc.Quality, "Unexpected sample quality %u.\n", desc.SampleDesc.Quality); ok(desc.Usage == D3D11_USAGE_DEFAULT, "Unexpected usage %u.\n", desc.Usage); ok(desc.BindFlags == (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET), "Unexpected bind flags %#x.\n", desc.BindFlags); - ok(desc.CPUAccessFlags == 0, "Unexpected CPU access flags %#x.\n", desc.CPUAccessFlags); - ok(desc.MiscFlags == 0, "Unexpected misc flags %#x.\n", desc.MiscFlags); + ok(!desc.CPUAccessFlags, "Unexpected CPU access flags %#x.\n", desc.CPUAccessFlags); + ok(!desc.MiscFlags, "Unexpected misc flags %#x.\n", desc.MiscFlags);
ID3D11Texture2D_Release(texture); IMFDXGIBuffer_Release(dxgi_buffer); @@ -7139,7 +7218,7 @@ todo_wine { ok(desc.BindFlags == (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET), "Unexpected bind flags %#x.\n", desc.BindFlags); - ok(desc.CPUAccessFlags == 0, "Unexpected CPU access flags %#x.\n", desc.CPUAccessFlags); + ok(!desc.CPUAccessFlags, "Unexpected CPU access flags %#x.\n", desc.CPUAccessFlags); } else if (usage[i] == D3D11_USAGE_DYNAMIC) { @@ -7148,11 +7227,11 @@ todo_wine } else if (usage[i] == D3D11_USAGE_STAGING) { - ok(desc.BindFlags == 0, "Unexpected bind flags %#x.\n", desc.BindFlags); + ok(!desc.BindFlags, "Unexpected bind flags %#x.\n", desc.BindFlags); ok(desc.CPUAccessFlags == (D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ), "Unexpected CPU access flags %#x.\n", desc.CPUAccessFlags); } - ok(desc.MiscFlags == 0, "Unexpected misc flags %#x.\n", desc.MiscFlags); + ok(!desc.MiscFlags, "Unexpected misc flags %#x.\n", desc.MiscFlags);
ID3D11Texture2D_Release(texture); IMFDXGIBuffer_Release(dxgi_buffer); @@ -7228,55 +7307,6 @@ todo_wine
IMFDXGIDeviceManager_Release(manager); ID3D11Device_Release(device); - - /* Use D3D9 device manager. */ - window = create_window(); - d3d9 = Direct3DCreate9(D3D_SDK_VERSION); - ok(!!d3d9, "Failed to create a D3D9 object.\n"); - if (!(d3d9_device = create_device(d3d9, window))) - { - skip("Failed to create a D3D9 device, skipping tests.\n"); - goto done; - } - - hr = DXVA2CreateDirect3DDeviceManager9(&token, &d3d9_manager); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - hr = IDirect3DDeviceManager9_ResetDevice(d3d9_manager, d3d9_device, token); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - hr = pMFCreateVideoSampleAllocatorEx(&IID_IMFVideoSampleAllocator, (void **)&allocator); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, (IUnknown *)d3d9_manager); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 1, video_type); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - check_interface(sample, &IID_IMFTrackedSample, TRUE); - check_interface(sample, &IID_IMFDesiredSample, FALSE); - - hr = IMFSample_GetBufferByIndex(sample, 0, &buffer); - ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - - check_interface(buffer, &IID_IMF2DBuffer, TRUE); - check_interface(buffer, &IID_IMF2DBuffer2, TRUE); - check_interface(buffer, &IID_IMFGetService, TRUE); - check_interface(buffer, &IID_IMFDXGIBuffer, FALSE); - - IMFSample_Release(sample); - IMFMediaBuffer_Release(buffer); - - IMFVideoSampleAllocator_Release(allocator); - IMFMediaType_Release(media_type); - -done: - IDirect3D9_Release(d3d9); - DestroyWindow(window); }
static void test_MFLockSharedWorkQueue(void) @@ -7510,6 +7540,9 @@ START_TEST(mfplat) return; }
+ if (!pMFCreateVideoSampleAllocatorEx) + win_skip("MFCreateVideoSampleAllocatorEx() is not available. Some tests will be skipped.\n"); + CoInitialize(NULL);
test_startup(); @@ -7558,7 +7591,9 @@ START_TEST(mfplat) test_MFFrameRateToAverageTimePerFrame(); test_MFMapDXGIFormatToDX9Format(); test_dxgi_surface_buffer(); - test_sample_allocator(); + test_sample_allocator_sysmem(); + test_sample_allocator_d3d9(); + test_sample_allocator_d3d11(); test_MFMapDX9FormatToDXGIFormat(); test_MFllMulDiv(); test_shared_dxgi_device_manager();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 654467a0bdb..cec27c2c23f 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -48,6 +48,10 @@ #include "ks.h" #include "ksmedia.h" #include "dxva2api.h" +#include "d3d12.h" +#undef EXTERN_GUID +#define EXTERN_GUID DEFINE_GUID +#include "mfd3d12.h"
DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19); DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21); @@ -220,6 +224,8 @@ static DWORD get_d3d11_texture_color(ID3D11Texture2D *texture, unsigned int x, u static HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, ID3D11Device **device_out, D3D_FEATURE_LEVEL *obtained_feature_level, ID3D11DeviceContext **immediate_context); +static HRESULT (WINAPI *pD3D12CreateDevice)(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level, + REFIID iid, void **device);
static HRESULT (WINAPI *pCoGetApartmentType)(APTTYPE *type, APTTYPEQUALIFIER *qualifier);
@@ -1025,6 +1031,11 @@ static void init_functions(void) X(D3D11CreateDevice); }
+ if ((mod = LoadLibraryA("d3d12.dll"))) + { + X(D3D12CreateDevice); + } + mod = GetModuleHandleA("ole32.dll");
X(CoGetApartmentType); @@ -6542,6 +6553,18 @@ static void update_d3d11_texture(ID3D11Texture2D *texture, unsigned int sub_reso ID3D11Device_Release(device); }
+static ID3D12Device *create_d3d12_device(void) +{ + ID3D12Device *device; + HRESULT hr; + + hr = pD3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); + if (FAILED(hr)) + return NULL; + + return device; +} + static void test_dxgi_surface_buffer(void) { DWORD max_length, cur_length, length, color; @@ -7309,6 +7332,96 @@ static void test_sample_allocator_d3d11(void) ID3D11Device_Release(device); }
+static void test_sample_allocator_d3d12(void) +{ + IMFVideoSampleAllocator *allocator; + IMFDXGIDeviceManager *manager; + IMFDXGIBuffer *dxgi_buffer; + IMFMediaType *video_type; + ID3D12Resource *resource; + D3D12_RESOURCE_DESC desc; + IMFMediaBuffer *buffer; + ID3D12Device *device; + unsigned int token; + IMFSample *sample; + HRESULT hr; + + if (!pD3D12CreateDevice) + { + skip("Missing d3d12 support, some tests will be skipped.\n"); + return; + } + + if (!(device = create_d3d12_device())) + { + skip("Failed to create a D3D12 device, skipping tests.\n"); + return; + } + + hr = pMFCreateDXGIDeviceManager(&token, &manager); + ok(hr == S_OK, "Failed to create device manager, hr %#x.\n", hr); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)device, token); + ok(hr == S_OK, "Failed to set a device, hr %#x.\n", hr); + + hr = pMFCreateVideoSampleAllocatorEx(&IID_IMFVideoSampleAllocator, (void **)&allocator); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + EXPECT_REF(manager, 1); + hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, (IUnknown *)manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + EXPECT_REF(manager, 2); + + video_type = create_video_type(&MFVideoFormat_RGB32); + hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 64 << 32 | 64); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMFMediaType_SetUINT32(video_type, &MF_MT_D3D_RESOURCE_VERSION, MF_D3D12_RESOURCE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 1, video_type); +todo_wine + ok(hr == S_OK || broken(hr == MF_E_UNEXPECTED) /* Some Win10 versions fail. */, "Unexpected hr %#x.\n", hr); + if (FAILED(hr)) goto done; + + hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFSample_GetBufferByIndex(sample, 0, &buffer); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + check_interface(buffer, &IID_IMF2DBuffer, TRUE); + check_interface(buffer, &IID_IMF2DBuffer2, TRUE); + check_interface(buffer, &IID_IMFDXGIBuffer, TRUE); + check_interface(buffer, &IID_IMFGetService, FALSE); + + hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFDXGIBuffer, (void **)&dxgi_buffer); + ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr); + + hr = IMFDXGIBuffer_GetResource(dxgi_buffer, &IID_ID3D12Resource, (void **)&resource); + ok(hr == S_OK, "Failed to get resource, hr %#x.\n", hr); + + resource->lpVtbl->GetDesc(resource, &desc); + ok(desc.Width == 64, "Unexpected width.\n"); + ok(desc.Height == 64, "Unexpected height.\n"); + ok(desc.DepthOrArraySize == 1, "Unexpected array size %u.\n", desc.DepthOrArraySize); + ok(desc.MipLevels == 1, "Unexpected miplevels %u.\n", desc.MipLevels); + ok(desc.Format == DXGI_FORMAT_B8G8R8X8_UNORM, "Unexpected format %u.\n", desc.Format); + ok(desc.SampleDesc.Count == 1, "Unexpected sample count %u.\n", desc.SampleDesc.Count); + ok(!desc.SampleDesc.Quality, "Unexpected sample quality %u.\n", desc.SampleDesc.Quality); + ok(!desc.Layout, "Unexpected layout %u.\n", desc.Layout); + ok(!desc.Flags, "Unexpected flags %#x.\n", desc.Flags); + + ID3D12Resource_Release(resource); + IMFDXGIBuffer_Release(dxgi_buffer); + IMFSample_Release(sample); + + IMFVideoSampleAllocator_Release(allocator); + +done: + IMFDXGIDeviceManager_Release(manager); + ID3D12Device_Release(device); +} + static void test_MFLockSharedWorkQueue(void) { DWORD taskid, queue, queue2; @@ -7594,6 +7707,7 @@ START_TEST(mfplat) test_sample_allocator_sysmem(); test_sample_allocator_d3d9(); test_sample_allocator_d3d11(); + test_sample_allocator_d3d12(); test_MFMapDX9FormatToDXGIFormat(); test_MFllMulDiv(); test_shared_dxgi_device_manager();
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=102791
Your paranoid android.
=== build (build log) ===
Makefile:91079: recipe for target 'dlls/mfplat/tests/mfplat.cross.o' failed Task: The exe32 Wine build failed
Nikolay Sivov nsivov@codeweavers.com writes:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/mfplat/tests/mfplat.c | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
This fails here:
tools/runtest -q -P wine -T . -M mfplat.dll -p dlls/mfplat/tests/mfplat_test.exe mfplat && touch dlls/mfplat/tests/mfplat.ok mfplat.c:7365: Test failed: Failed to set a device, hr 0x80070057. make: *** [Makefile:74293: dlls/mfplat/tests/mfplat.ok] Error 1