On Mon, Aug 23, 2021 at 10:22 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3dx10_43/sprite.c | 3 + dlls/d3dx10_43/tests/d3dx10.c | 194 ++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index b7834fb6f8a..7ed77a6406c 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2973,6 +2973,199 @@ todo_wine ID3DX10Font_Release(font); }
+static void test_sprite(void) +{
- ID3D10Device *device, *device2;
- ID3DX10Sprite *sprite;
- D3DXMATRIX mat, mat2;
- HRESULT hr;
- D3DX10_SPRITE sprite_desc;
- D3D10_TEXTURE2D_DESC texture_desc;
- ID3D10Texture2D *texture1, *texture2;
- ID3D10ShaderResourceView *srv1, *srv2;
- ULONG refcount;
- if (!(device = create_device()))
- {
skip("Failed to create device, skipping tests.\n");
return;
- }
- texture_desc.Width = 64;
- texture_desc.Height = 64;
- texture_desc.MipLevels = 1;
- texture_desc.ArraySize = 1;
- texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- texture_desc.SampleDesc.Count = 1;
- texture_desc.SampleDesc.Quality = 0;
- texture_desc.Usage = D3D10_USAGE_DEFAULT;
- texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
- texture_desc.CPUAccessFlags = 0;
- texture_desc.MiscFlags = 0;
- hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture1);
- ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
- hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture2);
- ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
- hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture1, NULL, &srv1);
- ok(SUCCEEDED(hr), "Failed to create srv, hr %#x.\n", hr);
- hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture1, NULL, &srv2);
- ok(SUCCEEDED(hr), "Failed to create srv, hr %#x.\n", hr);
- hr = D3DX10CreateSprite(device, 0, NULL);
- ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
- hr = D3DX10CreateSprite(NULL, 0, &sprite);
- ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
- hr = D3DX10CreateSprite(device, 0, &sprite);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- /* GetDevice */
- hr = ID3DX10Sprite_GetDevice(sprite, NULL);
- ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
- hr = ID3DX10Sprite_GetDevice(sprite, &device2);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(device == device2, "Unexpected device.\n");
- ID3D10Device_Release(device2);
- /* Projection transform */
- hr = ID3DX10Sprite_GetProjectionTransform(sprite, NULL);
+todo_wine
- ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
- hr = ID3DX10Sprite_GetProjectionTransform(sprite, &mat);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
We could test what the initial projection transform matrix looks like. I expect it to be just the identity matrix of course, but... Same for the view matrix.
- hr = ID3DX10Sprite_Begin(sprite, 0);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- memset(&sprite_desc, 0, sizeof(sprite_desc));
- hr = ID3DX10Sprite_DrawSpritesBuffered(sprite, &sprite_desc, 1);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- sprite_desc.pTexture = srv1;
- hr = ID3DX10Sprite_DrawSpritesBuffered(sprite, &sprite_desc, 1);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = ID3DX10Sprite_Flush(sprite);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = ID3DX10Sprite_Flush(sprite);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = ID3DX10Sprite_End(sprite);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- /* D3DX10_SPRITE_ADDREF_TEXTURES */
- hr = ID3DX10Sprite_Begin(sprite, D3DX10_SPRITE_ADDREF_TEXTURES);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- memset(&sprite_desc, 0, sizeof(sprite_desc));
- sprite_desc.pTexture = srv1;
- refcount = get_refcount(srv1);
- hr = ID3DX10Sprite_DrawSpritesBuffered(sprite, &sprite_desc, 1);
+todo_wine {
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(get_refcount(srv1) > refcount, "Unexpected refcount.\n");
+}
- hr = ID3DX10Sprite_Flush(sprite);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(get_refcount(srv1) == refcount, "Unexpected refcount.\n");
- hr = ID3DX10Sprite_End(sprite);
+todo_wine
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
The docs suggest that you must call Flush() before End() to make sure that the sprites are actually drawn on the screen. Some testing around that would be nice. FWIW it would be pretty surprising to me if End() doesn't flush on its own anyway.