On 24 November 2015 at 22:18, Stefan Dösinger stefan@codeweavers.com wrote:
+static void test_multisample_init(void) +{
- D3D10_TEXTURE2D_DESC desc;
- ID3D10Texture2D *single, *multi;
- ID3D10Device *device;
- ULONG refcount;
- DWORD color;
- HRESULT hr;
- unsigned int x, y;
- struct texture_readback rb;
- BOOL all_zero = TRUE;
- if (!(device = create_device()))
- {
skip("Failed to create device, skipping tests.\n");
return;
- }
- desc.Width = 640;
- desc.Height = 480;
- desc.MipLevels = 1;
- desc.ArraySize = 1;
- desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- desc.SampleDesc.Count = 2;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D10_USAGE_DEFAULT;
- desc.BindFlags = D3D10_BIND_RENDER_TARGET;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
- hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &multi);
- ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
You should check if the sample count is supported with CheckMultisampleQualityLevels().
- /* CopyResource from a multisampled to a sysmem texture works, but leaks memory on Windows
* (Nvidia, not checked on AMD). Use a single sampled buffer to work around. */
Direct3D 10+ doesn't have sysmem textures. You can make resources accessible to the CPU, but you can't prevent the GPU from reading from them. How did you verify that the CopyResource() works?
- desc.SampleDesc.Count = 1;
- hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &single);
- ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
Note that you're creating a texture here, contrary to what the comment above claims.
- ID3D10Device_CopyResource(device, (ID3D10Resource *)single, (ID3D10Resource *)multi);
At least according to the documentation, CopyResource() doesn't work at all with multi-sampled resources, and this should use ResolveSubresource() instead. It's possible the documentation is wrong about that, but that would need a more convincing test. Right now it looks like the test only tests that the initial contents of "single" are zeroes.