d3d11/tests: Test creating and rendering to a swapchain on the desktop window.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ae89bc8a9b
commit
ee163e350b
|
@ -29290,6 +29290,85 @@ static void test_standard_pattern(void)
|
|||
release_test_context(&test_context);
|
||||
}
|
||||
|
||||
static void test_desktop_window(void)
|
||||
{
|
||||
ID3D11RenderTargetView *backbuffer_rtv;
|
||||
DXGI_SWAP_CHAIN_DESC swapchain_desc;
|
||||
ID3D11DeviceContext *context;
|
||||
ID3D11Texture2D *backbuffer;
|
||||
IDXGISwapChain *swapchain;
|
||||
IDXGIDevice *dxgi_device;
|
||||
IDXGIAdapter *adapter;
|
||||
IDXGIFactory *factory;
|
||||
ID3D11Device *device;
|
||||
ULONG refcount;
|
||||
HRESULT hr;
|
||||
|
||||
static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
if (!(device = create_device(NULL)))
|
||||
{
|
||||
skip("Failed to create device.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
|
||||
ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
|
||||
hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter);
|
||||
ok(SUCCEEDED(hr), "Failed to get adapter, hr %#x.\n", hr);
|
||||
IDXGIDevice_Release(dxgi_device);
|
||||
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
|
||||
ok(SUCCEEDED(hr), "Failed to get factory, hr %#x.\n", hr);
|
||||
IDXGIAdapter_Release(adapter);
|
||||
|
||||
swapchain_desc.BufferDesc.Width = 640;
|
||||
swapchain_desc.BufferDesc.Height = 480;
|
||||
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
|
||||
swapchain_desc.BufferDesc.RefreshRate.Denominator = 1;
|
||||
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
swapchain_desc.SampleDesc.Count = 1;
|
||||
swapchain_desc.SampleDesc.Quality = 0;
|
||||
swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapchain_desc.BufferCount = 1;
|
||||
swapchain_desc.OutputWindow = GetDesktopWindow();
|
||||
swapchain_desc.Windowed = TRUE;
|
||||
swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
swapchain_desc.Flags = 0;
|
||||
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
|
||||
todo_wine ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Not available on all Windows versions. */,
|
||||
"Failed to create swapchain, hr %#x.\n", hr);
|
||||
IDXGIFactory_Release(factory);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ID3D11Device_Release(device);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_ID3D11Texture2D, (void **)&backbuffer);
|
||||
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)backbuffer, NULL, &backbuffer_rtv);
|
||||
ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
|
||||
|
||||
ID3D11Device_GetImmediateContext(device, &context);
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView(context, backbuffer_rtv, red);
|
||||
check_texture_color(backbuffer, 0xff0000ff, 1);
|
||||
|
||||
hr = IDXGISwapChain_Present(swapchain, 0, 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
ID3D11RenderTargetView_Release(backbuffer_rtv);
|
||||
ID3D11Texture2D_Release(backbuffer);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
ID3D11DeviceContext_Release(context);
|
||||
refcount = ID3D11Device_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(d3d11)
|
||||
{
|
||||
unsigned int argc, i;
|
||||
|
@ -29448,6 +29527,7 @@ START_TEST(d3d11)
|
|||
queue_test(test_staging_buffers);
|
||||
queue_test(test_render_a8);
|
||||
queue_test(test_standard_pattern);
|
||||
queue_test(test_desktop_window);
|
||||
|
||||
run_queued_tests();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue