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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Am 2015-11-25 um 13:44 schrieb Henri Verbeet:
You should check if the sample count is supported with CheckMultisampleQualityLevels().
My impression was that d3d10 mandates at least 4x MSAA support, though MSDN talks about FEATURE_LEVEL_10_1 devices. I guess it's a good idea to check anyway.
- /* 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?
An early version of this test called get_texture_color 640x480 times and died with E_OUTOFMEMORY on Windows. Adding the extra CopyResource step made the out of memory error go away.
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.
Good point. I think I tested the code by clearing the multisampled texture and checking if I get a non-zero readback, but I'm not sure any more if I did this in the d3d10 version as well or only in the d3d9 version.