Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
February 2020
- 80 participants
- 745 discussions
[PATCH 1/2] shell32: Fix SHCNE_UPDATEIMAGE and SHCNE_UPDATEITEM number of items
by Serge Gautherie 26 Feb '20
by Serge Gautherie 26 Feb '20
26 Feb '20
Signed-off-by: Serge Gautherie <winehq-git_serge_180711(a)gautherie.fr>
---
Based on MS docs and ReactOS uses.
---
dlls/shell32/changenotify.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/changenotify.c b/dlls/shell32/changenotify.c
index 2efb297..6c77a6c 100644
--- a/dlls/shell32/changenotify.c
+++ b/dlls/shell32/changenotify.c
@@ -64,10 +64,13 @@ static LONG next_id;
SHCNE_DRIVEADDGUI | SHCNE_DRIVEREMOVED | SHCNE_FREESPACE | \
SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_MKDIR | \
SHCNE_NETSHARE | SHCNE_NETUNSHARE | SHCNE_RMDIR | \
- SHCNE_SERVERDISCONNECT | SHCNE_UPDATEDIR | SHCNE_UPDATEIMAGE )
+ SHCNE_SERVERDISCONNECT | SHCNE_UPDATEDIR | SHCNE_UPDATEITEM )
+
+#define SHCNE_SECONDITEMEVENTS ( \
+ SHCNE_UPDATEIMAGE )
#define SHCNE_TWOITEMEVENTS ( \
- SHCNE_RENAMEFOLDER | SHCNE_RENAMEITEM | SHCNE_UPDATEITEM )
+ SHCNE_RENAMEFOLDER | SHCNE_RENAMEITEM )
/* for dumping events */
static const char * DumpEvent( LONG event )
--
2.10.0.windows.1
1
0
[PATCH v2 1/3] d3dcompiler/tests: Rewrite to use a separate d3d9 device for each test.
by Zebediah Figura 26 Feb '20
by Zebediah Figura 26 Feb '20
26 Feb '20
This brings the d3dcompiler tests more in line with existing d3d9 tests, and
allows potentially running the tests in parallel.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/d3dcompiler_43/tests/Makefile.in | 2 +-
dlls/d3dcompiler_43/tests/hlsl.c | 701 --------------------------
dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 679 +++++++++++++++++++++++++
dlls/d3dcompiler_47/tests/Makefile.in | 2 +-
4 files changed, 681 insertions(+), 703 deletions(-)
delete mode 100644 dlls/d3dcompiler_43/tests/hlsl.c
create mode 100644 dlls/d3dcompiler_43/tests/hlsl_d3d9.c
diff --git a/dlls/d3dcompiler_43/tests/Makefile.in b/dlls/d3dcompiler_43/tests/Makefile.in
index 51b1f934836..f00d8560826 100644
--- a/dlls/d3dcompiler_43/tests/Makefile.in
+++ b/dlls/d3dcompiler_43/tests/Makefile.in
@@ -5,5 +5,5 @@ EXTRADEFS = -DD3D_COMPILER_VERSION=43
C_SRCS = \
asm.c \
blob.c \
- hlsl.c \
+ hlsl_d3d9.c \
reflection.c
diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
deleted file mode 100644
index 868693838cc..00000000000
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * Copyright (C) 2010 Travis Athougies
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-#define COBJMACROS
-#include "wine/test.h"
-#include "d3dx9.h"
-#include "d3dcompiler.h"
-
-#include <math.h>
-
-static pD3DCompile ppD3DCompile;
-
-static HRESULT (WINAPI *pD3DXGetShaderConstantTable)(const DWORD *byte_code, ID3DXConstantTable **constant_table);
-static D3DMATRIX *(WINAPI *pD3DXMatrixOrthoLH)(D3DXMATRIX *pout, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf);
-
-struct vertex
-{
- float x, y, z;
- float tx, ty;
-};
-
-/* Tells compute_shader_probe* which pixels should be what colors */
-struct hlsl_probe_info
-{
- unsigned int x, y;
- /* The expected values in this region */
- D3DXCOLOR c;
- /* The max error for any value */
- float epsilon;
- /* An error message to print if this test fails */
- const char *message;
-};
-
-static HWND create_window(void)
-{
- WNDCLASSA wc = {0};
- wc.lpfnWndProc = DefWindowProcA;
- wc.lpszClassName = "d3d9_test_wc";
- RegisterClassA(&wc);
-
- return CreateWindowA("d3d9_test_wc", "d3d9_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
-}
-
-static IDirect3DDevice9 *init_d3d9(IDirect3DVertexDeclaration9 **vdeclaration,
- IDirect3DVertexBuffer9 **quad_geometry, IDirect3DVertexShader9 **vshader_passthru)
-{
- static const struct vertex quad_vertices[4] =
- {
- {-1.0f, -1.0f, 0.0f, 0.0f, 1.0f},
- {-1.0f, 1.0f, 0.0f, 0.0f, 0.0f},
- { 1.0f, -1.0f, 0.0f, 1.0f, 1.0f},
- { 1.0f, 1.0f, 0.0f, 1.0f, 0.0f}
- };
-
- static const D3DVERTEXELEMENT9 vdeclelements[] =
- {
- {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
- {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
- D3DDECL_END()
- };
-
- static const char *vshader_passthru_hlsl =
- "float4 vshader(float4 pos: POSITION, inout float2 texcoord: TEXCOORD0): POSITION\n"
- "{\n"
- " return pos;\n"
- "}";
-
- IDirect3D9 *d3d9_ptr;
- IDirect3DDevice9 *device_ptr = NULL;
- D3DPRESENT_PARAMETERS present_parameters;
-
- void *temp_geometry_vertices;
-
- ID3D10Blob *compiled = NULL;
- ID3D10Blob *errors = NULL;
-
- HRESULT hr;
-
- d3d9_ptr = Direct3DCreate9(D3D_SDK_VERSION);
- if (!d3d9_ptr)
- {
- skip("could not create D3D9\n");
- return NULL;
- }
-
- hr = IDirect3D9_CheckDeviceFormat(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
- 0, D3DRTYPE_SURFACE, D3DFMT_A32B32G32R32F);
- if (FAILED(hr))
- {
- skip("A32B32G32R32F format not available on this device\n");
- IDirect3D9_Release(d3d9_ptr);
- return NULL;
- }
-
- ZeroMemory(&present_parameters, sizeof(present_parameters));
- present_parameters.Windowed = TRUE;
- present_parameters.hDeviceWindow = create_window();
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
-
- hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL,
- D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
- IDirect3D9_Release(d3d9_ptr);
- if (FAILED(hr))
- {
- skip("could not create Direct3D9 device\n");
- return NULL;
- }
-
- /* Create the quad geometry */
- hr = IDirect3DDevice9_CreateVertexBuffer(device_ptr, 4 * sizeof(struct vertex),
- D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, quad_geometry, NULL);
- ok(SUCCEEDED(hr),
- "Could not create vertex buffer, IDirect3DDevice9_CreateVertexBuffer returned: %08x\n", hr);
-
- hr = IDirect3DVertexBuffer9_Lock(*quad_geometry, 0, sizeof(quad_vertices), &temp_geometry_vertices, 0);
- ok(SUCCEEDED(hr), "IDirect3DVertexBuffer9_Lock returned: %08x\n", hr);
- memcpy(temp_geometry_vertices, quad_vertices, sizeof(quad_vertices));
- IDirect3DVertexBuffer9_Unlock(*quad_geometry);
-
- hr = IDirect3DDevice9_CreateVertexDeclaration(device_ptr, vdeclelements, vdeclaration);
- ok(SUCCEEDED(hr), "Could not create vertex declaration: "
- "IDirect3DDevice9_CreateVertexDeclaration returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_SetVertexDeclaration(device_ptr, *vdeclaration);
- ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned: %08x\n", hr);
-
- /* Create a simple vertex shader to just pass through the values */
- hr = ppD3DCompile(vshader_passthru_hlsl, strlen(vshader_passthru_hlsl), NULL,
- NULL, NULL, "vshader", "vs_1_1", 0, 0, &compiled, &errors);
- if (FAILED(hr))
- {
- skip("not compiling vertex shader due to lacking wine HLSL support!\n");
- if (errors)
- ID3D10Blob_Release(errors);
- return NULL;
- }
-
- hr = IDirect3DDevice9_CreateVertexShader(device_ptr, ID3D10Blob_GetBufferPointer(compiled),
- vshader_passthru);
- ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexShader returned: %08x\n", hr);
- ID3D10Blob_Release(compiled);
-
- return device_ptr;
-}
-
-/* Convenience functions */
-static void set_float4_d3d9(IDirect3DDevice9 *device, ID3DXConstantTable *constants, const char *name,
- float x, float y, float z, float w)
-{
- D3DXVECTOR4 vector;
- vector.x = x;
- vector.y = y;
- vector.z = z;
- vector.w = w;
- ID3DXConstantTable_SetVector(constants, device, name, &vector);
-}
-
-/* Compile our pixel shader and get back the compiled version and a constant table */
-static IDirect3DPixelShader9 *compile_pixel_shader9(IDirect3DDevice9 *device, const char *shader,
- const char *profile, ID3DXConstantTable **constants)
-{
- ID3D10Blob *compiled = NULL;
- ID3D10Blob *errors = NULL;
- IDirect3DPixelShader9 *pshader;
- HRESULT hr;
-
- hr = ppD3DCompile(shader, strlen(shader), NULL, NULL,
- NULL, "test", profile, /* test is the name of the entry point of our shader */
- 0, 0, &compiled, &errors);
- ok(hr == D3D_OK, "Pixel shader %s compilation failed: %s\n", shader,
- errors ? (char *)ID3D10Blob_GetBufferPointer(errors) : "");
- if (FAILED(hr)) return NULL;
-
- hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(compiled), constants);
- ok(hr == D3D_OK, "Could not get constant table from compiled pixel shader\n");
-
- hr = IDirect3DDevice9_CreatePixelShader(device, ID3D10Blob_GetBufferPointer(compiled), &pshader);
- ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader returned: %08x\n", hr);
- ID3D10Blob_Release(compiled);
- return pshader;
-}
-
-/* Draw a full screen quad */
-static void draw_quad_with_shader9(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry)
-{
- HRESULT hr;
- D3DXMATRIX projection_matrix;
-
- pD3DXMatrixOrthoLH(&projection_matrix, 2.0f, 2.0f, 0.0f, 1.0f);
- IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &projection_matrix);
-
- hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
- ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_BeginScene(device);
- ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_SetStreamSource(device, 0, quad_geometry, 0, sizeof(struct vertex));
- ok(hr == D3D_OK, "IDirect3DDevice9_SetStreamSource returned: %08x\n", hr);
- hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2);
- ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitive returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_EndScene(device);
- ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned: %08x\n", hr);
-}
-
-static void setup_device9(IDirect3DDevice9 *device, IDirect3DSurface9 **render_target,
- IDirect3DSurface9 **readback, D3DFORMAT format, unsigned int width, unsigned int height,
- IDirect3DVertexShader9 *vshader, IDirect3DPixelShader9 *pshader)
-{
- HRESULT hr;
- hr = IDirect3DDevice9_CreateRenderTarget(device, width, height, format,
- D3DMULTISAMPLE_NONE, 0, FALSE, render_target, NULL);
- ok(hr == D3D_OK, "IDirect3DDevice9_CreateRenderTarget returned: %08x\n", hr);
-
- /* The Direct3D 9 docs state that we cannot lock a render target surface,
- instead we must copy the render target onto this surface to lock it */
- hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, format,
- D3DPOOL_SYSTEMMEM, readback, NULL);
- ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_SetRenderTarget(device, 0, *render_target);
- ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderTarget returned: %08x\n", hr);
-
- hr = IDirect3DDevice9_SetVertexShader(device, vshader);
- ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned: %08x\n", hr);
- hr = IDirect3DDevice9_SetPixelShader(device, pshader);
- ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned: %08x\n", hr);
-}
-
-static BOOL colors_match(D3DXCOLOR a, D3DXCOLOR b, float epsilon)
-{
- return (fabs(a.r - b.r) < epsilon && fabs(a.g - b.g) < epsilon && fabs(a.b - b.b) < epsilon &&
- fabs(a.a - b.a) < epsilon);
-}
-
-/* Compute a shader on a width by height buffer and probes certain locations
- to see if they are as expected. */
-static void compute_shader_probe9(IDirect3DDevice9 *device, IDirect3DVertexShader9 *vshader,
- IDirect3DPixelShader9 *pshader, IDirect3DVertexBuffer9 *quad_geometry,
- const struct hlsl_probe_info *probes, unsigned int count,
- unsigned int width, unsigned int height, unsigned int line_number)
-{
- IDirect3DSurface9 *render_target;
- IDirect3DSurface9 *readback;
-
- HRESULT hr;
- D3DLOCKED_RECT lr;
- D3DXCOLOR *pbits_data;
- unsigned int i;
-
- setup_device9(device, &render_target, &readback, D3DFMT_A32B32G32R32F,
- width, height, vshader, pshader);
-
- /* Draw the quad with the shader and read back the data */
- draw_quad_with_shader9(device, quad_geometry);
- IDirect3DDevice9_GetRenderTargetData(device, render_target, readback);
- hr = IDirect3DSurface9_LockRect(readback, &lr, NULL, D3DLOCK_READONLY);
- ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned: %08x\n", hr);
- pbits_data = lr.pBits;
-
- /* Now go through the probes and check each one */
- for (i = 0; i < count; i++, probes++) {
- int index = probes->x + (probes->y * lr.Pitch / sizeof(D3DXCOLOR));
- ok(colors_match(probes->c, pbits_data[index], probes->epsilon),
- "Line %d: At (%d, %d): %s: Expected (%.04f,%.04f,%.04f, %.04f), got "
- "(%.04f,%.04f,%.04f,%.04f)\n", line_number, probes->x, probes->y, probes->message,
- probes->c.r, probes->c.g, probes->c.b, probes->c.a, pbits_data[index].r,
- pbits_data[index].g, pbits_data[index].b, pbits_data[index].a);
- }
-
- hr = IDirect3DSurface9_UnlockRect(readback);
- ok(hr == D3D_OK, "IDirect3DSurface9_UnlockRect returned: %08x\n", hr);
-
- /* We now present the scene. This is mostly for debugging purposes, since GetRenderTargetData
- also waits for drawing commands to complete. The reason this call is here and not in a
- draw function is because the contents of the render target surface are invalidated after
- this call. */
- hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
- ok(hr == D3D_OK, "IDirect3DDevice9_Present returned: %08x\n", hr);
-
- IDirect3DSurface9_Release(render_target);
- IDirect3DSurface9_Release(readback);
-}
-
-/* Now the actual test functions */
-static void test_swizzle(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- static const struct hlsl_probe_info probes[] =
- {
- {0, 0, {0.0101f, 0.0303f, 0.0202f, 0.0404f}, 0.0001f, "swizzle_test"}
- };
-
- static const char *swizzle_test_shader =
- "uniform float4 color;\n"
- "float4 test(): COLOR\n"
- "{\n"
- " float4 ret = color;\n"
- " ret.gb = ret.ra;\n"
- " ret.ra = float2(0.0101, 0.0404);\n"
- " return ret;\n"
- "}";
-
- ID3DXConstantTable *constants;
- IDirect3DPixelShader9 *pshader;
-
- pshader = compile_pixel_shader9(device, swizzle_test_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- set_float4_d3d9(device, constants, "color", 0.0303f, 0.0f, 0.0f, 0.0202f);
-
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
- probes, ARRAY_SIZE(probes), 1, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-}
-
-static void test_math(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- /* Tests order of operations */
- static const float u = 2.5f, v = 0.3f, w = 0.2f, x = 0.7f, y = 0.1f, z = 1.5f;
-
- static const struct hlsl_probe_info probes[] =
- {
- {0, 0, {-12.4300f, 9.8333f, 1.6000f, 34.9999f}, 0.0001f,
- "order of operations test"}
- };
-
- static const char *order_of_operations_shader =
- "float4 test(uniform float u, uniform float v, uniform float w, uniform float x,\n"
- " uniform float y, uniform float z): COLOR\n"
- "{\n"
- " return float4(x * y - z / w + --u / -v,\n"
- " z * x / y + w / -v,\n"
- " u + v - w,\n"
- " x / y / w);\n"
- "}";
-
- ID3DXConstantTable *constants;
- IDirect3DPixelShader9 *pshader;
-
- pshader = compile_pixel_shader9(device, order_of_operations_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- ID3DXConstantTable_SetFloat(constants, device, "$u", u);
- ID3DXConstantTable_SetFloat(constants, device, "$v", v);
- ID3DXConstantTable_SetFloat(constants, device, "$w", w);
- ID3DXConstantTable_SetFloat(constants, device, "$x", x);
- ID3DXConstantTable_SetFloat(constants, device, "$y", y);
- ID3DXConstantTable_SetFloat(constants, device, "$z", z);
-
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
- probes, ARRAY_SIZE(probes), 1, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-}
-
-static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- static const struct hlsl_probe_info if_greater_probes[] =
- {
- { 0, 0, {0.9f, 0.8f, 0.7f, 0.6f}, 0.0001f, "if greater test"},
- { 5, 0, {0.9f, 0.8f, 0.7f, 0.6f}, 0.0001f, "if greater test"},
- {10, 0, {0.9f, 0.8f, 0.7f, 0.6f}, 0.0001f, "if greater test"},
- {15, 0, {0.9f, 0.8f, 0.7f, 0.6f}, 0.0001f, "if greater test"},
- {25, 0, {0.1f, 0.2f, 0.3f, 0.4f}, 0.0001f, "if greater test"},
- {30, 0, {0.1f, 0.2f, 0.3f, 0.4f}, 0.0001f, "if greater test"}
- };
-
- static const char *if_greater_shader =
- "float4 test(float2 pos: TEXCOORD0): COLOR\n"
- "{\n"
- " if((pos.x * 32.0) > 20.0)\n"
- " return float4(0.1, 0.2, 0.3, 0.4);\n"
- " else\n"
- " return float4(0.9, 0.8, 0.7, 0.6);\n"
- "}";
-
- static const struct hlsl_probe_info ternary_operator_probes[] =
- {
- {0, 0, {0.50f, 0.25f, 0.50f, 0.75f}, 0.00001f, "ternary operator test"},
- {1, 0, {0.50f, 0.25f, 0.50f, 0.75f}, 0.00001f, "ternary operator test"},
- {2, 0, {0.50f, 0.25f, 0.50f, 0.75f}, 0.00001f, "ternary operator test"},
- {3, 0, {0.50f, 0.25f, 0.50f, 0.75f}, 0.00001f, "ternary operator test"},
- {4, 0, {0.60f, 0.80f, 0.10f, 0.20f}, 0.00001f, "ternary operator test"},
- {5, 0, {0.60f, 0.80f, 0.10f, 0.20f}, 0.00001f, "ternary operator test"},
- {6, 0, {0.60f, 0.80f, 0.10f, 0.20f}, 0.00001f, "ternary operator test"},
- {7, 0, {0.60f, 0.80f, 0.10f, 0.20f}, 0.00001f, "ternary operator test"}
- };
-
- static const char *ternary_operator_shader =
- "float4 test(float2 pos: TEXCOORD0): COLOR\n"
- "{\n"
- " return (pos.x < 0.5?float4(0.5, 0.25, 0.5, 0.75):float4(0.6, 0.8, 0.1, 0.2));\n"
- "}";
-
- ID3DXConstantTable *constants;
- IDirect3DPixelShader9 *pshader;
-
- pshader = compile_pixel_shader9(device, if_greater_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, if_greater_probes,
- ARRAY_SIZE(if_greater_probes), 32, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-
- pshader = compile_pixel_shader9(device, ternary_operator_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, ternary_operator_probes,
- ARRAY_SIZE(ternary_operator_probes), 8, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-}
-
-static void test_float_vectors(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- static const struct hlsl_probe_info vec4_indexing_test1_probes[] =
- {
- {0, 0, {0.020f, 0.245f, 0.351f, 1.000f}, 0.0001f, "vec4 indexing test 1"}
- };
-
- static const char *vec4_indexing_test1_shader =
- "float4 test(): COLOR\n"
- "{\n"
- " float4 color;\n"
- " color[0] = 0.020;\n"
- " color[1] = 0.245;\n"
- " color[2] = 0.351;\n"
- " color[3] = 1.0;\n"
- " return color;\n"
- "}";
-
- static const struct hlsl_probe_info vec4_indexing_test2_probes[] =
- {
- {0, 0, {0.5f, 0.3f, 0.8f, 0.2f}, 0.0001f, "vec4 indexing test 2"}
- };
-
- /* We have this uniform i here so the compiler can't optimize */
- static const char *vec4_indexing_test2_shader =
- "uniform int i;\n"
- "float4 test(): COLOR\n"
- "{\n"
- " float4 color = float4(0.5, 0.4, 0.3, 0.2);\n"
- " color.g = color[i];\n"
- " color.b = 0.8;\n"
- " return color;\n"
- "}";
-
- ID3DXConstantTable *constants;
- IDirect3DPixelShader9 *pshader;
-
- pshader = compile_pixel_shader9(device, vec4_indexing_test1_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, vec4_indexing_test1_probes,
- ARRAY_SIZE(vec4_indexing_test1_probes), 1, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-
- pshader = compile_pixel_shader9(device, vec4_indexing_test2_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- ID3DXConstantTable_SetInt(constants, device, "i", 2);
-
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, vec4_indexing_test2_probes,
- ARRAY_SIZE(vec4_indexing_test2_probes), 32, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-}
-
-static void test_trig(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- static const struct hlsl_probe_info sincos_probes[] =
- {
- {0, 0, {0.5000f, 1.0000f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {1, 0, {0.5975f, 0.9904f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {2, 0, {0.6913f, 0.9620f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {3, 0, {0.7778f, 0.9160f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {4, 0, {0.8536f, 0.8536f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {5, 0, {0.9157f, 0.7778f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {6, 0, {0.9620f, 0.6913f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {7, 0, {0.9904f, 0.5975f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {8, 0, {1.0000f, 0.5000f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {9, 0, {0.9904f, 0.4025f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {10, 0, {0.9619f, 0.3087f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {11, 0, {0.9157f, 0.2222f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {12, 0, {0.8536f, 0.1464f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {13, 0, {0.7778f, 0.0843f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {14, 0, {0.6913f, 0.0381f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {15, 0, {0.5975f, 0.0096f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {16, 0, {0.5000f, 0.0000f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {17, 0, {0.4025f, 0.0096f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {18, 0, {0.3087f, 0.0381f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {19, 0, {0.2222f, 0.0843f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {20, 0, {0.1464f, 0.1464f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {21, 0, {0.0843f, 0.2222f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {22, 0, {0.0381f, 0.3087f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {23, 0, {0.0096f, 0.4025f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {24, 0, {0.0000f, 0.5000f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {25, 0, {0.0096f, 0.5975f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {26, 0, {0.0381f, 0.6913f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {27, 0, {0.0843f, 0.7778f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {28, 0, {0.1464f, 0.8536f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {29, 0, {0.2222f, 0.9157f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {30, 0, {0.3087f, 0.9619f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- {31, 0, {0.4025f, 0.9904f, 0.0f, 0.0f}, 0.001f, "sin/cos test"},
- };
-
- static const char *sincos_shader =
- "float4 test(float x: TEXCOORD0): COLOR\n"
- "{\n"
- " const float pi2 = 6.2831853;\n"
- " float calcd_sin = (sin(x * pi2) + 1)/2;\n"
- " float calcd_cos = (cos(x * pi2) + 1)/2;\n"
- " return float4(calcd_sin, calcd_cos, 0, 0);\n"
- "}";
-
- ID3DXConstantTable *constants;
- IDirect3DPixelShader9 *pshader;
-
- pshader = compile_pixel_shader9(device, sincos_shader, "ps_2_0", &constants);
- if (pshader != NULL)
- {
- compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, sincos_probes,
- ARRAY_SIZE(sincos_probes), 32, 1, __LINE__);
-
- ID3DXConstantTable_Release(constants);
- IDirect3DPixelShader9_Release(pshader);
- }
-}
-
-static void test_fail(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *qquad_geometry,
- IDirect3DVertexShader9 *vshader_passthru)
-{
- static const char *tests[] =
- {
- "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
- "{\n"
- " return y;\n"
- "}",
-
- "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
- "{\n"
- " float4 x = float4(0, 0, 0, 0);\n"
- " x.xzzx = float4(1, 2, 3, 4);\n"
- " return x;\n"
- "}",
-
- "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
- "{\n"
- " float4 x = pos;\n"
- " return x;\n"
- "}",
-
- "float4 test(float2 pos, TEXCOORD0) ; COLOR\n"
- "{\n"
- " pos = float4 x;\n"
- " mul(float4(5, 4, 3, 2), mvp) = x;\n"
- " return float4;\n"
- "}",
-
- "float4 563r(float2 45s: TEXCOORD0) : COLOR\n"
- "{\n"
- " float2 x = 45s;\n"
- " return float4(x.x, x.y, 0, 0);\n"
- "}",
-
- "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
- "{\n"
- " struct { int b,c; } x = {0};\n"
- " return y;\n"
- "}",
-
- "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
- "{\n"
- " struct {} x = {};\n"
- " return y;\n"
- "}",
- };
-
- ID3D10Blob *compiled, *errors;
- unsigned int i;
- HRESULT hr;
-
- for (i = 0; i < ARRAY_SIZE(tests); ++i)
- {
- compiled = errors = NULL;
- hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", "ps_2_0", 0, 0, &compiled, &errors);
- ok(hr == E_FAIL, "Test %u, got unexpected hr %#x.\n", i, hr);
- ok(!!errors, "Test %u, expected non-NULL error blob.\n", i);
- ok(!compiled, "Test %u, expected no compiled shader blob.\n", i);
- ID3D10Blob_Release(errors);
- }
-}
-
-static BOOL load_d3dcompiler(void)
-{
- HMODULE module;
-
-#if D3D_COMPILER_VERSION == 47
- if (!(module = LoadLibraryA("d3dcompiler_47.dll"))) return FALSE;
-#else
- if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
-#endif
-
- ppD3DCompile = (void*)GetProcAddress(module, "D3DCompile");
- return TRUE;
-}
-
-START_TEST(hlsl)
-{
- D3DCAPS9 caps;
- ULONG refcount;
- IDirect3DDevice9 *device;
- IDirect3DVertexDeclaration9 *vdeclaration;
- IDirect3DVertexBuffer9 *quad_geometry;
- IDirect3DVertexShader9 *vshader_passthru;
- HMODULE mod;
-
- if (!load_d3dcompiler())
- {
- win_skip("Could not load DLL.\n");
- return;
- }
-
- if (!(mod = LoadLibraryA("d3dx9_36.dll")))
- {
- win_skip("Failed to load d3dx9_36.dll.\n");
- return;
- }
- pD3DXGetShaderConstantTable = (void *)GetProcAddress(mod, "D3DXGetShaderConstantTable");
- pD3DXMatrixOrthoLH = (void *)GetProcAddress(mod, "D3DXMatrixOrthoLH");
-
- device = init_d3d9(&vdeclaration, &quad_geometry, &vshader_passthru);
- if (!device) return;
-
- /* Make sure we support pixel shaders, before trying to compile them! */
- /* Direct3D 9 (Shader model 1-3 tests) */
- IDirect3DDevice9_GetDeviceCaps(device, &caps);
- if (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0))
- {
- todo_wine
- {
- test_swizzle(device, quad_geometry, vshader_passthru);
- test_math(device, quad_geometry, vshader_passthru);
- test_conditionals(device, quad_geometry, vshader_passthru);
- test_float_vectors(device, quad_geometry, vshader_passthru);
- test_trig(device, quad_geometry, vshader_passthru);
- test_fail(device, quad_geometry, vshader_passthru);
- }
- } else skip("no pixel shader support\n");
-
- /* Reference counting sanity checks */
- if (vshader_passthru)
- {
- refcount = IDirect3DVertexShader9_Release(vshader_passthru);
- ok(!refcount, "Pass-through vertex shader has %u references left\n", refcount);
- }
-
- refcount = IDirect3DVertexBuffer9_Release(quad_geometry);
- ok(!refcount, "Vertex buffer has %u references left\n", refcount);
-
- refcount = IDirect3DVertexDeclaration9_Release(vdeclaration);
- ok(!refcount, "Vertex declaration has %u references left\n", refcount);
-
- refcount = IDirect3DDevice9_Release(device);
- ok(!refcount, "Device has %u references left\n", refcount);
-}
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
new file mode 100644
index 00000000000..6e2672175b9
--- /dev/null
+++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
@@ -0,0 +1,679 @@
+/*
+ * Copyright (C) 2010 Travis Athougies
+ * Copyright (C) 2020 Zebediah Figura for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#define COBJMACROS
+#include "wine/test.h"
+#include "d3dx9.h"
+#include "d3dcompiler.h"
+
+#include <math.h>
+
+static pD3DCompile ppD3DCompile;
+
+static HRESULT (WINAPI *pD3DXGetShaderConstantTable)(const DWORD *byte_code, ID3DXConstantTable **constant_table);
+
+struct vec2
+{
+ float x, y;
+};
+
+struct vec4
+{
+ float x, y, z, w;
+};
+
+#define compile_shader(a, b) compile_shader_(__LINE__, a, b)
+static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const char *target)
+{
+ ID3D10Blob *blob = NULL, *errors = NULL;
+ HRESULT hr;
+
+ hr = ppD3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, 0, 0, &blob, &errors);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to compile shader, hr %#x.\n", hr);
+ if (errors)
+ {
+ if (winetest_debug > 1)
+ trace_(__FILE__, line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
+ ID3D10Blob_Release(errors);
+ }
+ return blob;
+}
+
+static IDirect3DDevice9 *create_device(HWND window)
+{
+ D3DPRESENT_PARAMETERS present_parameters =
+ {
+ .Windowed = TRUE,
+ .hDeviceWindow = window,
+ .SwapEffect = D3DSWAPEFFECT_DISCARD,
+ .BackBufferWidth = 640,
+ .BackBufferHeight = 480,
+ .BackBufferFormat = D3DFMT_A8R8G8B8,
+ };
+ IDirect3DDevice9 *device;
+ IDirect3DSurface9 *rt;
+ IDirect3D9 *d3d;
+ D3DCAPS9 caps;
+ HRESULT hr;
+
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
+ IDirect3D9_Release(d3d);
+ if (FAILED(hr))
+ {
+ skip("Failed to create a 3D device, hr %#x.\n", hr);
+ return NULL;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(hr == D3D_OK, "Failed to get device caps, hr %#x.\n", hr);
+ if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0) || caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
+ {
+ skip("No shader model 2 support.\n");
+ IDirect3DDevice9_Release(device);
+ return NULL;
+ }
+
+ if (FAILED(hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A32B32G32R32F,
+ D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL)))
+ {
+ skip("Failed to create an A32B32G32R32F surface, hr %#x.\n", hr);
+ IDirect3DDevice9_Release(device);
+ return NULL;
+ }
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
+ ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
+ IDirect3DSurface9_Release(rt);
+
+ return device;
+}
+
+struct test_context
+{
+ IDirect3DDevice9 *device;
+ HWND window;
+};
+
+#define init_test_context(a) init_test_context_(__LINE__, a)
+static BOOL init_test_context_(unsigned int line, struct test_context *context)
+{
+ WNDCLASSA wc = {0};
+ wc.lpfnWndProc = DefWindowProcA;
+ wc.lpszClassName = "d3dcompiler_test_wc";
+ RegisterClassA(&wc);
+
+ context->window = CreateWindowA("d3dcompiler_test_wc", "d3dcompiler_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ ok(!!context->window, "Failed to create a window.\n");
+
+ if (!(context->device = create_device(context->window)))
+ {
+ DestroyWindow(context->window);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#define release_test_context(context) release_test_context_(__LINE__, context)
+static void release_test_context_(unsigned int line, struct test_context *context)
+{
+ ULONG ref = IDirect3DDevice9_Release(context->device);
+ ok_(__FILE__, line)(!ref, "Device has %u references left.\n", ref);
+ DestroyWindow(context->window);
+}
+
+#define draw_quad(device, ps_code) draw_quad_(__LINE__, device, ps_code)
+static void draw_quad_(unsigned int line, IDirect3DDevice9 *device, ID3D10Blob *ps_code)
+{
+ IDirect3DVertexDeclaration9 *vertex_declaration;
+ IDirect3DVertexShader9 *vs;
+ IDirect3DPixelShader9 *ps;
+ ID3D10Blob *vs_code;
+ HRESULT hr;
+
+ static const D3DVERTEXELEMENT9 decl_elements[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 8, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
+ D3DDECL_END()
+ };
+
+ static const struct
+ {
+ struct vec2 position;
+ struct vec2 t0;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f}, {0.0f, 1.0f}},
+ {{-1.0f, 1.0f}, {0.0f, 0.0f}},
+ {{ 1.0f, -1.0f}, {1.0f, 1.0f}},
+ {{ 1.0f, 1.0f}, {1.0f, 0.0f}},
+ };
+
+ static const char vs_source[] =
+ "float4 main(float4 pos : POSITION, inout float2 texcoord : TEXCOORD0) : POSITION\n"
+ "{\n"
+ " return pos;\n"
+ "}";
+
+ hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to create vertex declaration, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to set vertex declaration, hr %#x.\n", hr);
+
+ vs_code = compile_shader(vs_source, "vs_2_0");
+
+ hr = IDirect3DDevice9_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), &vs);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to create vertex shader, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_SetVertexShader(device, vs);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to set vertex shader, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_CreatePixelShader(device, ID3D10Blob_GetBufferPointer(ps_code), &ps);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to create pixel shader, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_SetPixelShader(device, ps);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to set pixel shader, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to draw, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to draw, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_EndScene(device);
+ ok_(__FILE__, line)(hr == D3D_OK, "Failed to draw, hr %#x.\n", hr);
+
+ IDirect3DVertexDeclaration9_Release(vertex_declaration);
+ IDirect3DVertexShader9_Release(vs);
+ IDirect3DPixelShader9_Release(ps);
+ ID3D10Blob_Release(vs_code);
+}
+
+struct readback
+{
+ IDirect3DSurface9 *surface;
+ D3DLOCKED_RECT rect;
+};
+
+static void init_readback(IDirect3DDevice9 *device, struct readback *rb)
+{
+ IDirect3DSurface9 *rt;
+ D3DSURFACE_DESC desc;
+ HRESULT hr;
+
+ hr = IDirect3DDevice9Ex_GetRenderTarget(device, 0, &rt);
+ ok(hr == D3D_OK, "Failed to get render target, hr %#x.\n", hr);
+
+ hr = IDirect3DSurface9_GetDesc(rt, &desc);
+ ok(hr == D3D_OK, "Failed to get surface desc, hr %#x.\n", hr);
+ hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, desc.Width, desc.Height,
+ desc.Format, D3DPOOL_SYSTEMMEM, &rb->surface, NULL);
+ ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9Ex_GetRenderTargetData(device, rt, rb->surface);
+ ok(hr == D3D_OK, "Failed to get render target data, hr %#x.\n", hr);
+
+ hr = IDirect3DSurface9_LockRect(rb->surface, &rb->rect, NULL, D3DLOCK_READONLY);
+ ok(hr == D3D_OK, "Failed to lock surface, hr %#x.\n", hr);
+
+ IDirect3DSurface9_Release(rt);
+}
+
+static const struct vec4 *get_readback_vec4(const struct readback *rb, unsigned int x, unsigned int y)
+{
+ return (struct vec4 *)((BYTE *)rb->rect.pBits + y * rb->rect.Pitch + x * sizeof(struct vec4));
+}
+
+static void release_readback(struct readback *rb)
+{
+ IDirect3DSurface9_UnlockRect(rb->surface);
+ IDirect3DSurface9_Release(rb->surface);
+}
+
+static struct vec4 get_color_vec4(IDirect3DDevice9 *device, unsigned int x, unsigned int y)
+{
+ struct readback rb;
+ struct vec4 ret;
+
+ init_readback(device, &rb);
+ ret = *get_readback_vec4(&rb, x, y);
+ release_readback(&rb);
+
+ return ret;
+}
+
+static BOOL compare_float(float f, float g, unsigned int ulps)
+{
+ int x = *(int *)&f;
+ int y = *(int *)&g;
+
+ if (x < 0)
+ x = INT_MIN - x;
+ if (y < 0)
+ y = INT_MIN - y;
+
+ if (abs(x - y) > ulps)
+ return FALSE;
+
+ return TRUE;
+}
+
+static BOOL compare_vec4(const struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)
+{
+ return compare_float(vec->x, x, ulps)
+ && compare_float(vec->y, y, ulps)
+ && compare_float(vec->z, z, ulps)
+ && compare_float(vec->w, w, ulps);
+}
+
+static void test_swizzle(void)
+{
+ static const D3DXVECTOR4 color = {0.0303f, 0.0f, 0.0f, 0.0202f};
+ struct test_context test_context;
+ ID3DXConstantTable *constants;
+ ID3D10Blob *ps_code = NULL;
+ IDirect3DDevice9 *device;
+ struct vec4 v;
+ HRESULT hr;
+
+ static const char ps_source[] =
+ "uniform float4 color;\n"
+ "float4 main() : COLOR\n"
+ "{\n"
+ " float4 ret = color;\n"
+ " ret.gb = ret.ra;\n"
+ " ret.ra = float2(0.0101, 0.0404);\n"
+ " return ret;\n"
+ "}";
+
+ if (!init_test_context(&test_context))
+ return;
+ device = test_context.device;
+
+ todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
+ if (ps_code)
+ {
+ hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+ ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetVector(constants, device, "color", &color);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ ID3DXConstantTable_Release(constants);
+
+ draw_quad(device, ps_code);
+
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, 0.0101f, 0.0303f, 0.0202f, 0.0404f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+
+ ID3D10Blob_Release(ps_code);
+ }
+ release_test_context(&test_context);
+}
+
+static void test_math(void)
+{
+ struct test_context test_context;
+ ID3DXConstantTable *constants;
+ ID3D10Blob *ps_code = NULL;
+ IDirect3DDevice9 *device;
+ struct vec4 v;
+ HRESULT hr;
+
+ static const char ps_source[] =
+ "float4 main(uniform float u, uniform float v, uniform float w, uniform float x,\n"
+ " uniform float y, uniform float z): COLOR\n"
+ "{\n"
+ " return float4(x * y - z / w + --u / -v,\n"
+ " z * x / y + w / -v,\n"
+ " u + v - w,\n"
+ " x / y / w);\n"
+ "}";
+
+ if (!init_test_context(&test_context))
+ return;
+ device = test_context.device;
+
+ todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
+ if (ps_code)
+ {
+ hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+ ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$u", 2.5f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$v", 0.3f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$w", 0.2f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$x", 0.7f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$y", 0.1f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$z", 1.5f);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ ID3DXConstantTable_Release(constants);
+
+ draw_quad(device, ps_code);
+
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, -12.43f, 9.833333f, 1.6f, 35.0f, 1),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+
+ ID3D10Blob_Release(ps_code);
+ }
+ release_test_context(&test_context);
+}
+
+static void test_conditionals(void)
+{
+ struct test_context test_context;
+ ID3D10Blob *ps_code = NULL;
+ IDirect3DDevice9 *device;
+ const struct vec4 *v;
+ struct readback rb;
+ unsigned int i;
+
+ static const char ps_if_source[] =
+ "float4 main(float2 pos : TEXCOORD0) : COLOR\n"
+ "{\n"
+ " if((pos.x * 640.0) > 200.0)\n"
+ " return float4(0.1, 0.2, 0.3, 0.4);\n"
+ " else\n"
+ " return float4(0.9, 0.8, 0.7, 0.6);\n"
+ "}";
+
+ static const char ps_ternary_source[] =
+ "float4 main(float2 pos : TEXCOORD0) : COLOR\n"
+ "{\n"
+ " return (pos.x < 0.5 ? float4(0.5, 0.25, 0.5, 0.75) : float4(0.6, 0.8, 0.1, 0.2));\n"
+ "}";
+
+ if (!init_test_context(&test_context))
+ return;
+ device = test_context.device;
+
+ todo_wine ps_code = compile_shader(ps_if_source, "ps_2_0");
+ if (ps_code)
+ {
+ draw_quad(device, ps_code);
+ init_readback(device, &rb);
+
+ for (i = 0; i < 200; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ for (i = 240; i < 640; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ release_readback(&rb);
+ ID3D10Blob_Release(ps_code);
+ }
+
+ todo_wine ps_code = compile_shader(ps_ternary_source, "ps_2_0");
+ if (ps_code)
+ {
+ draw_quad(device, ps_code);
+ init_readback(device, &rb);
+
+ for (i = 0; i < 320; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.5f, 0.25f, 0.5f, 0.75f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ for (i = 360; i < 640; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.6f, 0.8f, 0.1f, 0.2f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ release_readback(&rb);
+ ID3D10Blob_Release(ps_code);
+ }
+
+ release_test_context(&test_context);
+}
+
+static void test_float_vectors(void)
+{
+ struct test_context test_context;
+ ID3DXConstantTable *constants;
+ ID3D10Blob *ps_code = NULL;
+ IDirect3DDevice9 *device;
+ struct vec4 v;
+ HRESULT hr;
+
+ static const char ps_indexing_source[] =
+ "float4 main() : COLOR\n"
+ "{\n"
+ " float4 color;\n"
+ " color[0] = 0.020;\n"
+ " color[1] = 0.245;\n"
+ " color[2] = 0.351;\n"
+ " color[3] = 1.0;\n"
+ " return color;\n"
+ "}";
+
+ /* A uniform index is used so that the compiler can't optimize. */
+ static const char ps_uniform_indexing_source[] =
+ "uniform int i;\n"
+ "float4 main() : COLOR\n"
+ "{\n"
+ " float4 color = float4(0.5, 0.4, 0.3, 0.2);\n"
+ " color.g = color[i];\n"
+ " color.b = 0.8;\n"
+ " return color;\n"
+ "}";
+
+ if (!init_test_context(&test_context))
+ return;
+ device = test_context.device;
+
+ todo_wine ps_code = compile_shader(ps_indexing_source, "ps_2_0");
+ if (ps_code)
+ {
+ draw_quad(device, ps_code);
+
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, 0.02f, 0.245f, 0.351f, 1.0f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+
+ ID3D10Blob_Release(ps_code);
+ }
+
+ todo_wine ps_code = compile_shader(ps_uniform_indexing_source, "ps_2_0");
+ if (ps_code)
+ {
+ hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+ ok(hr == D3D_OK, "Failed to get constants, hr %#x.\n", hr);
+ hr = ID3DXConstantTable_SetInt(constants, device, "i", 2);
+ ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr);
+ ID3DXConstantTable_Release(constants);
+ draw_quad(device, ps_code);
+
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, 0.5f, 0.3f, 0.8f, 0.2f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+
+ ID3D10Blob_Release(ps_code);
+ }
+
+ release_test_context(&test_context);
+}
+
+static void test_trig(void)
+{
+ struct test_context test_context;
+ ID3D10Blob *ps_code = NULL;
+ IDirect3DDevice9 *device;
+ const struct vec4 *v;
+ struct readback rb;
+ unsigned int i;
+
+ static const char ps_source[] =
+ "float4 main(float x : TEXCOORD0) : COLOR\n"
+ "{\n"
+ " const float pi2 = 6.2831853;\n"
+ " float calcd_sin = (sin(x * pi2) + 1)/2;\n"
+ " float calcd_cos = (cos(x * pi2) + 1)/2;\n"
+ " return float4(calcd_sin, calcd_cos, 0, 0);\n"
+ "}";
+
+ if (!init_test_context(&test_context))
+ return;
+ device = test_context.device;
+
+ todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
+ if (ps_code)
+ {
+ draw_quad(device, ps_code);
+ init_readback(device, &rb);
+
+ for (i = 0; i < 32; ++i)
+ {
+ float expect_x = (sinf(i * 2 * M_PI / 32) + 1.0f) / 2.0f;
+ float expect_y = (cosf(i * 2 * M_PI / 32) + 1.0f) / 2.0f;
+ v = get_readback_vec4(&rb, i * 640 / 32, 0);
+ ok(compare_vec4(v, expect_x, expect_y, 0.0f, 0.0f, 4096),
+ "Test %u: Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
+ i, v->x, v->y, v->z, v->w, expect_x, expect_y, 0.0f, 0.0f);
+ }
+
+ release_readback(&rb);
+ ID3D10Blob_Release(ps_code);
+ }
+ release_test_context(&test_context);
+}
+
+static void test_fail(void)
+{
+ static const char *tests[] =
+ {
+ "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " return y;\n"
+ "}",
+
+ "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " float4 x = float4(0, 0, 0, 0);\n"
+ " x.xzzx = float4(1, 2, 3, 4);\n"
+ " return x;\n"
+ "}",
+
+ "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " float4 x = pos;\n"
+ " return x;\n"
+ "}",
+
+ "float4 test(float2 pos, TEXCOORD0) ; COLOR\n"
+ "{\n"
+ " pos = float4 x;\n"
+ " mul(float4(5, 4, 3, 2), mvp) = x;\n"
+ " return float4;\n"
+ "}",
+
+ "float4 563r(float2 45s: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " float2 x = 45s;\n"
+ " return float4(x.x, x.y, 0, 0);\n"
+ "}",
+
+ "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " struct { int b,c; } x = {0};\n"
+ " return y;\n"
+ "}",
+
+ "float4 test(float2 pos: TEXCOORD0) : COLOR\n"
+ "{\n"
+ " struct {} x = {};\n"
+ " return y;\n"
+ "}",
+ };
+
+ ID3D10Blob *compiled, *errors;
+ unsigned int i;
+ HRESULT hr;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ compiled = errors = NULL;
+ hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", "ps_2_0", 0, 0, &compiled, &errors);
+ todo_wine ok(hr == E_FAIL, "Test %u, got unexpected hr %#x.\n", i, hr);
+ todo_wine_if (i == 1) ok(!!errors, "Test %u, expected non-NULL error blob.\n", i);
+ ok(!compiled, "Test %u, expected no compiled shader blob.\n", i);
+ if (errors)
+ ID3D10Blob_Release(errors);
+ }
+}
+
+static BOOL load_d3dcompiler(void)
+{
+ HMODULE module;
+
+#if D3D_COMPILER_VERSION == 47
+ if (!(module = LoadLibraryA("d3dcompiler_47.dll"))) return FALSE;
+#else
+ if (!(module = LoadLibraryA("d3dcompiler_43.dll"))) return FALSE;
+#endif
+
+ ppD3DCompile = (void*)GetProcAddress(module, "D3DCompile");
+ return TRUE;
+}
+
+START_TEST(hlsl_d3d9)
+{
+ HMODULE mod;
+
+ if (!load_d3dcompiler())
+ {
+ win_skip("Could not load DLL.\n");
+ return;
+ }
+
+ if (!(mod = LoadLibraryA("d3dx9_36.dll")))
+ {
+ win_skip("Failed to load d3dx9_36.dll.\n");
+ return;
+ }
+ pD3DXGetShaderConstantTable = (void *)GetProcAddress(mod, "D3DXGetShaderConstantTable");
+
+ test_swizzle();
+ test_math();
+ test_conditionals();
+ test_float_vectors();
+ test_trig();
+ test_fail();
+}
diff --git a/dlls/d3dcompiler_47/tests/Makefile.in b/dlls/d3dcompiler_47/tests/Makefile.in
index 401ed30b0f1..032e16fdb8f 100644
--- a/dlls/d3dcompiler_47/tests/Makefile.in
+++ b/dlls/d3dcompiler_47/tests/Makefile.in
@@ -6,5 +6,5 @@ PARENTSRC = ../../d3dcompiler_43/tests
C_SRCS = \
asm.c \
blob.c \
- hlsl.c \
+ hlsl_d3d9.c \
reflection.c
--
2.25.0
1
2
[PATCH] dstyle: IDirectMusicStyle8 GetDefaultBand return S_FALSE
by Alistair Leslie-Hughes 26 Feb '20
by Alistair Leslie-Hughes 26 Feb '20
26 Feb '20
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48648
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/dmstyle/style.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/dmstyle/style.c b/dlls/dmstyle/style.c
index 3e480028b9e..31bf1118809 100644
--- a/dlls/dmstyle/style.c
+++ b/dlls/dmstyle/style.c
@@ -153,9 +153,12 @@ static HRESULT WINAPI IDirectMusicStyle8Impl_EnumBand(IDirectMusicStyle8 *iface,
static HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultBand(IDirectMusicStyle8 *iface,
IDirectMusicBand **ppBand)
{
- IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
- FIXME("(%p, %p): stub\n", This, ppBand);
- return S_OK;
+ IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
+ FIXME("(%p, %p): stub\n", This, ppBand);
+
+ *ppBand = NULL;
+
+ return S_FALSE;
}
static HRESULT WINAPI IDirectMusicStyle8Impl_EnumMotif(IDirectMusicStyle8 *iface, DWORD index,
--
2.25.0
1
0
Hello, thanks for reviewing my patches! I've addressed your comments in the
new version.
On Mon, 24 Feb 2020 14:21:32 -0600 Zebediah Figura wrote:
> Hello Anton, thanks for the patch! I have a few comments inlined below:
>
> On 2/24/20 12:03 PM, Anton Baskanov wrote:
> > Signed-off-by: Anton Baskanov <baskanov(a)gmail.com>
> > ---
> > dlls/amstream/audiostream.c | 8 +-
> > dlls/amstream/tests/amstream.c | 336 +++++++++++++++++++++++++++++++++
> > 2 files changed, 342 insertions(+), 2 deletions(-)
> >
> > diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c
> > index 2875e1f59b..8a16512dcd 100644
> > --- a/dlls/amstream/audiostream.c
> > +++ b/dlls/amstream/audiostream.c
> > @@ -499,13 +499,17 @@ static HRESULT WINAPI
> > audio_IAudioMediaStream_GetFormat(IAudioMediaStream *iface
> > {
> > struct audio_stream *This = impl_from_IAudioMediaStream(iface);
> >
> > - FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current);
> > + TRACE("(%p/%p)->(%p)\n", iface, This, wave_format_current);
> >
> > if (!wave_format_current)
> > return E_POINTER;
> >
> > - return MS_E_NOSTREAM;
> > + if (!This->peer)
> > + return MS_E_NOSTREAM;
> >
> > + *wave_format_current = *(WAVEFORMATEX *)This->mt.pbFormat;
> > +
> > + return S_OK;
>
> I suspect this should be protected by the stream's critical section.
>
> > }
> >
> > static HRESULT WINAPI
> > audio_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const
> > WAVEFORMATEX *wave_format)
> > diff --git a/dlls/amstream/tests/amstream.c
> b/dlls/amstream/tests/amstream.c
> > index 6497dde91c..1fb3cc239b 100644
> > --- a/dlls/amstream/tests/amstream.c
> > +++ b/dlls/amstream/tests/amstream.c
> > @@ -2293,6 +2293,340 @@ out_unknown:
> > IUnknown_Release(unknown);
> > }
> >
> > +static LONG filter_ref_count = 1;
> > +
> > +static HRESULT WINAPI filter_QueryInterface(IBaseFilter *iface,
> > REFIID riid, void **ret_iface)
> > +{
> > + if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersist,
> riid) ||
> > + IsEqualGUID(&IID_IMediaFilter, riid) ||
> > IsEqualGUID(&IID_IBaseFilter, riid))
> > + {
> > + *ret_iface = iface;
> > + IBaseFilter_AddRef(iface);
> > + return S_OK;
> > + }
> > + return E_NOINTERFACE;
> > +}
> > +
> > +static ULONG WINAPI filter_AddRef(IBaseFilter *iface)
> > +{
> > + return InterlockedIncrement(&filter_ref_count);
> > +}
> > +
> > +static ULONG WINAPI filter_Release(IBaseFilter *iface)
> > +{
> > + return InterlockedDecrement(&filter_ref_count);
> > +}
> > +
> > +static HRESULT WINAPI filter_GetClassID(IBaseFilter *iface, CLSID
> *clsid)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_Stop(IBaseFilter *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_Pause(IBaseFilter *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_Run(IBaseFilter *iface, REFERENCE_TIME
> start)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_GetState(IBaseFilter *iface, DWORD
> > timeout, FILTER_STATE *state)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_SetSyncSource(IBaseFilter *iface,
> > IReferenceClock *clock)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_GetSyncSource(IBaseFilter *iface,
> > IReferenceClock **clock)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_EnumPins(IBaseFilter *iface, IEnumPins
> > **enum_pins)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_FindPin(IBaseFilter *iface, const WCHAR
> > *id, IPin **out)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_QueryFilterInfo(IBaseFilter *iface,
> > FILTER_INFO *info)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_JoinFilterGraph(IBaseFilter *iface,
> > + IFilterGraph *graph, const WCHAR *name)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI filter_QueryVendorInfo(IBaseFilter *iface,
> > LPWSTR *vendor_info)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static const IBaseFilterVtbl filter_vtbl =
> > +{
> > + filter_QueryInterface,
> > + filter_AddRef,
> > + filter_Release,
> > + filter_GetClassID,
> > + filter_Stop,
> > + filter_Pause,
> > + filter_Run,
> > + filter_GetState,
> > + filter_SetSyncSource,
> > + filter_GetSyncSource,
> > + filter_EnumPins,
> > + filter_FindPin,
> > + filter_QueryFilterInfo,
> > + filter_JoinFilterGraph,
> > + filter_QueryVendorInfo,
> > +};
> > +
> > +static IBaseFilter filter = {&filter_vtbl};
> > +
> > +static LONG output_pin_ref_count = 1;
> > +
> > +static HRESULT WINAPI output_pin_QueryInterface(IPin *iface, REFIID
> > iid, void **out)
> > +{
> > + if (IsEqualGUID(&IID_IUnknown, iid) || IsEqualGUID(&IID_IPin, iid))
> > + {
> > + *out = iface;
> > + IPin_AddRef(iface);
> > + return S_OK;
> > + }
> > + return E_NOINTERFACE;
> > +}
> > +
> > +static ULONG WINAPI output_pin_AddRef(IPin *iface)
> > +{
> > + return InterlockedIncrement(&output_pin_ref_count);
> > +}
> > +
> > +static ULONG WINAPI output_pin_Release(IPin *iface)
> > +{
> > + return InterlockedDecrement(&output_pin_ref_count);
> > +}
> > +
> > +static HRESULT WINAPI output_pin_Connect(IPin *iface, IPin *peer,
> > const AM_MEDIA_TYPE *mt)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_ReceiveConnection(IPin *iface, IPin
> > *peer, const AM_MEDIA_TYPE *mt)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_Disconnect(IPin *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_ConnectedTo(IPin *iface, IPin **peer)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_ConnectionMediaType(IPin *iface,
> > AM_MEDIA_TYPE *mt)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_QueryPinInfo(IPin *iface, PIN_INFO
> *info)
> > +{
> > + if (winetest_debug > 1) trace("QueryPinInfo\n");
> > + info->pFilter = &filter;
> > + info->dir = PINDIR_OUTPUT;
> > + lstrcpyW(info->achName, L"output");
> > + IBaseFilter_AddRef(info->pFilter);
> > + return S_OK;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_QueryDirection(IPin *iface,
> > PIN_DIRECTION *dir)
> > +{
> > + if (winetest_debug > 1) trace("QueryDirection\n");
> > + *dir = PINDIR_OUTPUT;
> > + return S_OK;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_QueryId(IPin *iface, WCHAR **id)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_QueryAccept(IPin *iface, const
> > AM_MEDIA_TYPE *mt)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_EnumMediaTypes(IPin *iface,
> > IEnumMediaTypes **out)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_QueryInternalConnections(IPin
> > *iface, IPin **pins, ULONG *count)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_EndOfStream(IPin *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_BeginFlush(IPin *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_EndFlush(IPin *iface)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static HRESULT WINAPI output_pin_NewSegment(IPin *iface,
> > REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
> > +{
> > + ok(0, "Unexpected call.\n");
> > + return E_NOTIMPL;
> > +}
> > +
> > +static const IPinVtbl output_pin_vtbl =
> > +{
> > + output_pin_QueryInterface,
> > + output_pin_AddRef,
> > + output_pin_Release,
> > + output_pin_Connect,
> > + output_pin_ReceiveConnection,
> > + output_pin_Disconnect,
> > + output_pin_ConnectedTo,
> > + output_pin_ConnectionMediaType,
> > + output_pin_QueryPinInfo,
> > + output_pin_QueryDirection,
> > + output_pin_QueryId,
> > + output_pin_QueryAccept,
> > + output_pin_EnumMediaTypes,
> > + output_pin_QueryInternalConnections,
> > + output_pin_EndOfStream,
> > + output_pin_BeginFlush,
> > + output_pin_EndFlush,
> > + output_pin_NewSegment,
> > +};
> > +
> > +static IPin output_pin = {&output_pin_vtbl};
>
> I would suggest using strmbase for this instead of manually implementing
> the source pin and filter, similar to how it's done in the quartz
> renderer tests.
>
> > +
> > +static void test_audiostream_get_format(void)
> > +{
> > + IAMMultiMediaStream *mmstream = create_ammultimediastream();
> > + IMediaStream *stream = NULL;
> > + IAudioMediaStream *audio_stream = NULL;
> > + IPin *pin = NULL;
> > + WAVEFORMATEX stream_format = {0};
> > + WAVEFORMATEX media_type_format = {0};
> > + AM_MEDIA_TYPE media_type = {0};
> > + HRESULT hr;
> > +
> > + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL,
> > &MSPID_PrimaryAudio, 0, &stream);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
> > + hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream,
> > (void **)&audio_stream);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
> > + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
> > +
> > + hr = IAudioMediaStream_GetFormat(audio_stream, NULL);
> > + ok(hr == E_POINTER, "Got hr %#x.\n", hr);
> > +
> > + hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
> > + ok(hr == MS_E_NOSTREAM, "Got hr %#x.\n", hr);
> > +
> > + media_type_format.wFormatTag = WAVE_FORMAT_PCM;
> > + media_type_format.nChannels = 2;
> > + media_type_format.nSamplesPerSec = 44100;
> > + media_type_format.nAvgBytesPerSec = 176400;
> > + media_type_format.nBlockAlign = 4;
> > + media_type_format.wBitsPerSample = 16;
> > + media_type_format.cbSize = 0;
> > +
> > + media_type.majortype = MEDIATYPE_Audio;
> > + media_type.subtype = MEDIASUBTYPE_PCM;
> > + media_type.bFixedSizeSamples = TRUE;
> > + media_type.bTemporalCompression = FALSE;
> > + media_type.lSampleSize = 2;
> > + media_type.formattype = FORMAT_WaveFormatEx;
> > + media_type.pUnk = NULL;
> > + media_type.cbFormat = sizeof(media_type_format);
> > + media_type.pbFormat = (BYTE *)&media_type_format;
> > +
> > + hr = IPin_ReceiveConnection(pin, &output_pin, &media_type);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
>
> And similarly, this should use IFilterGraph2::ConnectDirect() with the
> multimedia stream's filter graph, unless there's a good reason not to.
>
> > +
> > + stream_format.wFormatTag = 0xdead;
> > + stream_format.nChannels = 0xdead;
> > + stream_format.nSamplesPerSec = 0xdeadbeef;
> > + stream_format.nAvgBytesPerSec = 0xdeadbeef;
> > + stream_format.nBlockAlign = 0xdead;
> > + stream_format.wBitsPerSample = 0xdead;
> > + stream_format.cbSize = 0xdead;
>
> memset(&stream_format, 0xcc, sizeof(stream_format)) would probably be
> easier.
>
> > + hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
> > + ok(WAVE_FORMAT_PCM == stream_format.wFormatTag, "got %u\n",
> > stream_format.wFormatTag);
> > + ok(2 == stream_format.nChannels, "got %u\n",
> stream_format.nChannels);
> > + ok(44100 == stream_format.nSamplesPerSec, "got %u\n",
> > stream_format.nSamplesPerSec);
> > + ok(176400 == stream_format.nAvgBytesPerSec, "got %u\n",
> > stream_format.nAvgBytesPerSec);
> > + ok(4 == stream_format.nBlockAlign, "got %u\n",
> stream_format.nBlockAlign);
> > + ok(16 == stream_format.wBitsPerSample, "got %u\n",
> > stream_format.wBitsPerSample);
> > + ok(0 == stream_format.cbSize, "got %u\n", stream_format.cbSize);
>
> It's my stylistic preference (mostly borrowed from d3d) to put the
> constant on the right, and capitalize and punctuate trace messages.
> Adding a description (e.g. "Got alignment %u.") would probably also be
> appreciated.
>
> > +
> > + hr = IPin_Disconnect(pin);
> > + ok(hr == S_OK, "Got hr %#x.\n", hr);
> > +
> > + hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
> > + ok(hr == MS_E_NOSTREAM, "Got hr %#x.\n", hr);
> > +
> > + IPin_Release(pin);
> > + IAudioMediaStream_Release(audio_stream);
> > + IMediaStream_Release(stream);
> > + IAMMultiMediaStream_Release(mmstream);
>
> Can you please check that all references are released, as is done
> elsewhere?
>
> > +}
> > +
> > START_TEST(amstream)
> > {
> > HANDLE file;
> > @@ -2326,5 +2660,7 @@ START_TEST(amstream)
> > test_audiodata_get_format();
> > test_audiodata_set_format();
> >
> > + test_audiostream_get_format();
> > +
> > CoUninitialize();
> > }
> > --
> > 2.17.1
> >
>
1
0
25 Feb '20
Signed-off-by: Anton Baskanov <baskanov(a)gmail.com>
---
v2:
- Protect access to stream data by the stream's critical section
- Use strmbase to implement the test pin and filter.
- Use IGraphBuilder::ConnectDirect to connect the pins in the test
- Use IGraphBuilder::Disconnect to disconnect the pins in tests the test
- Use memset instead of manual assignment of debug pattern in the test
- Check that all references are released at the end of the test
- Improve test trace messages
---
dlls/amstream/audiostream.c | 15 +++-
dlls/amstream/tests/Makefile.in | 2 +-
dlls/amstream/tests/amstream.c | 152 ++++++++++++++++++++++++++++++++
3 files changed, 166 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c
index 2875e1f59b..e4161fa3e6 100644
--- a/dlls/amstream/audiostream.c
+++ b/dlls/amstream/audiostream.c
@@ -499,13 +499,24 @@ static HRESULT WINAPI audio_IAudioMediaStream_GetFormat(IAudioMediaStream *iface
{
struct audio_stream *This = impl_from_IAudioMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current);
+ TRACE("(%p/%p)->(%p)\n", iface, This, wave_format_current);
if (!wave_format_current)
return E_POINTER;
- return MS_E_NOSTREAM;
+ EnterCriticalSection(&This->cs);
+ if (!This->peer)
+ {
+ LeaveCriticalSection(&This->cs);
+ return MS_E_NOSTREAM;
+ }
+
+ *wave_format_current = *(WAVEFORMATEX *)This->mt.pbFormat;
+
+ LeaveCriticalSection(&This->cs);
+
+ return S_OK;
}
static HRESULT WINAPI audio_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format)
diff --git a/dlls/amstream/tests/Makefile.in b/dlls/amstream/tests/Makefile.in
index 3a1a269fea..81eaed3c15 100644
--- a/dlls/amstream/tests/Makefile.in
+++ b/dlls/amstream/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = amstream.dll
-IMPORTS = strmiids uuid ddraw ole32 user32
+IMPORTS = strmbase strmiids uuid ddraw ole32 user32
C_SRCS = \
amstream.c
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 6497dde91c..1d1b7deb3f 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -27,6 +27,7 @@
#include "ks.h"
#include "initguid.h"
#include "ksmedia.h"
+#include "wine/strmbase.h"
static const WCHAR primary_video_sink_id[] = L"I{A35FF56A-9FDA-11D0-8FDF-00C04FD9189D}";
static const WCHAR primary_audio_sink_id[] = L"I{A35FF56B-9FDA-11D0-8FDF-00C04FD9189D}";
@@ -2293,6 +2294,155 @@ out_unknown:
IUnknown_Release(unknown);
}
+struct testfilter
+{
+ struct strmbase_filter filter;
+ struct strmbase_source source;
+};
+
+static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface)
+{
+ return CONTAINING_RECORD(iface, struct testfilter, filter);
+}
+
+static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, unsigned int index)
+{
+ struct testfilter *filter = impl_from_BaseFilter(iface);
+ if (!index)
+ return &filter->source.pin;
+ return NULL;
+}
+
+static void testfilter_destroy(struct strmbase_filter *iface)
+{
+ struct testfilter *filter = impl_from_BaseFilter(iface);
+ strmbase_source_cleanup(&filter->source);
+ strmbase_filter_cleanup(&filter->filter);
+}
+
+static const struct strmbase_filter_ops testfilter_ops =
+{
+ .filter_get_pin = testfilter_get_pin,
+ .filter_destroy = testfilter_destroy,
+};
+
+static HRESULT testsource_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
+{
+ return S_OK;
+}
+
+static HRESULT WINAPI testsource_DecideAllocator(struct strmbase_source *iface,
+ IMemInputPin *peer, IMemAllocator **allocator)
+{
+ return S_OK;
+}
+
+static const struct strmbase_source_ops testsource_ops =
+{
+ .base.pin_query_accept = testsource_query_accept,
+ .base.pin_get_media_type = strmbase_pin_get_media_type,
+ .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
+ .pfnDecideAllocator = testsource_DecideAllocator,
+};
+
+static void testfilter_init(struct testfilter *filter)
+{
+ static const GUID clsid = {0xabacab};
+ strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops);
+ strmbase_source_init(&filter->source, &filter->filter, L"", &testsource_ops);
+}
+
+static void test_audiostream_get_format(void)
+{
+ IAMMultiMediaStream *mmstream = create_ammultimediastream();
+ IGraphBuilder *graph = NULL;
+ struct testfilter source;
+ IMediaStream *stream = NULL;
+ IAudioMediaStream *audio_stream = NULL;
+ IPin *pin = NULL;
+ WAVEFORMATEX stream_format = {0};
+ WAVEFORMATEX media_type_format = {0};
+ AM_MEDIA_TYPE media_type = {0};
+ HRESULT hr;
+ ULONG ref;
+
+ hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(graph != NULL, "Expected non-null graph\n");
+
+ testfilter_init(&source);
+
+ hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioMediaStream_GetFormat(audio_stream, NULL);
+ ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+ hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
+ ok(hr == MS_E_NOSTREAM, "Got hr %#x.\n", hr);
+
+ media_type_format.wFormatTag = WAVE_FORMAT_PCM;
+ media_type_format.nChannels = 2;
+ media_type_format.nSamplesPerSec = 44100;
+ media_type_format.nAvgBytesPerSec = 176400;
+ media_type_format.nBlockAlign = 4;
+ media_type_format.wBitsPerSample = 16;
+ media_type_format.cbSize = 0;
+
+ media_type.majortype = MEDIATYPE_Audio;
+ media_type.subtype = MEDIASUBTYPE_PCM;
+ media_type.bFixedSizeSamples = TRUE;
+ media_type.bTemporalCompression = FALSE;
+ media_type.lSampleSize = 2;
+ media_type.formattype = FORMAT_WaveFormatEx;
+ media_type.pUnk = NULL;
+ media_type.cbFormat = sizeof(media_type_format);
+ media_type.pbFormat = (BYTE *)&media_type_format;
+
+ hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &media_type);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ memset(&stream_format, 0xcc, sizeof(stream_format));
+ hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(stream_format.wFormatTag == WAVE_FORMAT_PCM, "Got wFormatTag %u\n", stream_format.wFormatTag);
+ ok(stream_format.nChannels == 2, "Got nChannels %u\n", stream_format.nChannels);
+ ok(stream_format.nSamplesPerSec == 44100, "Got nSamplesPerSec %u\n", stream_format.nSamplesPerSec);
+ ok(stream_format.nAvgBytesPerSec == 176400, "Got nAvgBytesPerSec %u\n", stream_format.nAvgBytesPerSec);
+ ok(stream_format.nBlockAlign == 4, "Got nBlockAlign %u\n", stream_format.nBlockAlign);
+ ok(stream_format.wBitsPerSample == 16, "Got wBitsPerSample %u\n", stream_format.wBitsPerSample);
+ ok(stream_format.cbSize == 0, "Got cbSize %u\n", stream_format.cbSize);
+
+ hr = IGraphBuilder_Disconnect(graph, pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioMediaStream_GetFormat(audio_stream, &stream_format);
+ ok(hr == MS_E_NOSTREAM, "Got hr %#x.\n", hr);
+
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IGraphBuilder_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ IPin_Release(pin);
+ IAudioMediaStream_Release(audio_stream);
+ ref = IMediaStream_Release(stream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
START_TEST(amstream)
{
HANDLE file;
@@ -2326,5 +2476,7 @@ START_TEST(amstream)
test_audiodata_get_format();
test_audiodata_set_format();
+ test_audiostream_get_format();
+
CoUninitialize();
}
--
2.17.1
1
2
[PATCH v2] maintainers: Move d3d10 and d3d10_1 under Direct3D helper libraries.
by Matteo Bruni 25 Feb '20
by Matteo Bruni 25 Feb '20
25 Feb '20
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
v2: Fix typo, thanks Zebediah.
Supersedes patch 179579.
MAINTAINERS | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index c4f5b080b2d..93e89193b70 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -65,7 +65,7 @@ Direct3D
M: Henri Verbeet <hverbeet(a)codeweavers.com>
P: Stefan Dösinger <stefan(a)codeweavers.com>
P: Matteo Bruni <mbruni(a)codeweavers.com>
-F: dlls/d3d10*/
+F: dlls/d3d10core/
F: dlls/d3d11/
F: dlls/d3d12/
F: dlls/d3d8/
@@ -79,6 +79,8 @@ Direct3D helper libraries
M: Matteo Bruni <mbruni(a)codeweavers.com>
P: Henri Verbeet <hverbeet(a)codeweavers.com>
P: Stefan Dösinger <stefan(a)codeweavers.com>
+F: dlls/d3d10/
+F: dlls/d3d10_1/
F: dlls/d3dcompiler*/
F: dlls/d3dx10*/
F: dlls/d3dx11*/
--
2.24.1
1
0
25 Feb '20
Implement SetMatrix/SetMatrixArray and
SetMatrixTranspose/SetMatrixTransposeArray methods for the matrix effect
variable interface.
Signed-off-by: Connor McAdams <conmanx360(a)gmail.com>
---
dlls/d3d10/d3d10_private.h | 5 ++
dlls/d3d10/effect.c | 107 ++++++++++++++++++++++++++++++++++---
2 files changed, 104 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h
index 5c6c7a2d72..2be381f608 100644
--- a/dlls/d3d10/d3d10_private.h
+++ b/dlls/d3d10/d3d10_private.h
@@ -61,6 +61,11 @@ enum d3d10_effect_object_operation
D3D10_EOO_ANONYMOUS_SHADER = 7,
};
+struct d3d10_effect_matrix
+{
+ float m[4][4];
+};
+
struct d3d10_effect_object
{
struct d3d10_effect_pass *pass;
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c
index 93be257b81..1bc7968499 100644
--- a/dlls/d3d10/effect.c
+++ b/dlls/d3d10/effect.c
@@ -4967,8 +4967,87 @@ static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_
d3d10_effect_vector_variable_GetFloatVectorArray,
};
+static void write_matrix_to_buffer(struct d3d10_effect_variable *variable, float *buf,
+ struct d3d10_effect_matrix *matrix, BOOL transpose)
+{
+ unsigned int row, col;
+
+ if (variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS)
+ {
+ for (col = 0; col < variable->type->column_count; col++)
+ {
+ for (row = 0; row < variable->type->row_count; row++)
+ {
+ if (transpose)
+ buf[(col * 4) + row] = matrix->m[col][row];
+ else
+ buf[(col * 4) + row] = matrix->m[row][col];
+ }
+ }
+ }
+ else
+ {
+ for (col = 0; col < variable->type->column_count; col++)
+ {
+ for (row = 0; row < variable->type->row_count; row++)
+ {
+ if (transpose)
+ buf[(row * 4) + col] = matrix->m[col][row];
+ else
+ buf[(row * 4) + col] = matrix->m[row][col];
+ }
+ }
+ }
+}
+
+static void write_matrix_variable_to_buffer(struct d3d10_effect_variable *variable, void *data, BOOL transpose)
+{
+ char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
+
+ write_matrix_to_buffer(variable, (float *)buf, data, transpose);
+
+ variable->buffer->u.buffer.changed = 1;
+}
+
+static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *data, UINT offset,
+ UINT count, BOOL transpose)
+{
+ char *buf = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
+ struct d3d10_effect_matrix *input_data = data;
+ unsigned int i;
+
+ if (!variable->type->element_count)
+ {
+ write_matrix_variable_to_buffer(variable, data, transpose);
+ return;
+ }
+
+ if (offset >= variable->type->element_count)
+ return;
+
+ if (count > variable->type->element_count - offset)
+ count = variable->type->element_count - offset;
+
+ if (offset)
+ buf += variable->type->stride * offset;
+
+ for (i = 0; i < count; i++)
+ {
+ write_matrix_to_buffer(variable, (float *)buf, &input_data[i], transpose);
+
+ buf += variable->type->stride;
+ }
+
+ variable->buffer->u.buffer.changed = 1;
+}
+
/* ID3D10EffectVariable methods */
+static inline struct d3d10_effect_variable *impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable *iface)
+{
+ return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
+}
+
static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface)
{
TRACE("iface %p\n", iface);
@@ -5125,9 +5204,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface,
float *data)
{
- FIXME("iface %p, data %p stub!\n", iface, data);
+ struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p.\n", iface, data);
+ write_matrix_variable_to_buffer(effect_var, data, FALSE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface,
@@ -5141,9 +5223,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10Ef
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
float *data, UINT offset, UINT count)
{
- FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
+ struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
+ write_matrix_variable_array_to_buffer(effect_var, data, offset, count, FALSE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface,
@@ -5157,9 +5242,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
float *data)
{
- FIXME("iface %p, data %p stub!\n", iface, data);
+ struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p.\n", iface, data);
+ write_matrix_variable_to_buffer(effect_var, data, TRUE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
@@ -5173,9 +5261,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
float *data, UINT offset, UINT count)
{
- FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
+ struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectMatrixVariable(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
+ write_matrix_variable_array_to_buffer(effect_var, data, offset, count, TRUE);
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
--
2.20.1
3
7
25 Feb '20
Tracing the handle values is not useful and increases the test report
size.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
dlls/gdi32/tests/metafile.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c
index f1caebbc9d0..5a64fe6d60a 100644
--- a/dlls/gdi32/tests/metafile.c
+++ b/dlls/gdi32/tests/metafile.c
@@ -179,8 +179,6 @@ static void test_ExtTextOut(void)
hdcDisplay = GetDC(hwnd);
ok(hdcDisplay != 0, "GetDC error %d\n", GetLastError());
- trace("hdcDisplay %p\n", hdcDisplay);
-
SetMapMode(hdcDisplay, MM_TEXT);
memset(&orig_lf, 0, sizeof(orig_lf));
@@ -207,8 +205,6 @@ static void test_ExtTextOut(void)
hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
-
ok(GetDeviceCaps(hdcMetafile, TECHNOLOGY) == DT_RASDISPLAY,
"GetDeviceCaps(TECHNOLOGY) has to return DT_RASDISPLAY for a display based EMF\n");
@@ -2057,7 +2053,6 @@ static void test_mf_Blank(void)
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
/* Tests on metafile initialization */
caps = GetDeviceCaps (hdcMetafile, TECHNOLOGY);
@@ -2094,7 +2089,6 @@ static void test_CopyMetaFile(void)
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
hMetafile = CloseMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseMetaFile error %d\n", GetLastError());
@@ -2141,7 +2135,6 @@ static void test_SetMetaFileBits(void)
METAHEADER *mh;
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS), MF_GRAPHICS_BITS);
- trace("hmf %p\n", hmf);
ok(hmf != 0, "SetMetaFileBitsEx error %d\n", GetLastError());
type = GetObjectType(hmf);
ok(type == OBJ_METAFILE, "SetMetaFileBitsEx created object with type %d\n", type);
@@ -2161,7 +2154,6 @@ static void test_SetMetaFileBits(void)
/* Now with zero size */
SetLastError(0xdeadbeef);
hmf = SetMetaFileBitsEx(0, MF_GRAPHICS_BITS);
- trace("hmf %p\n", hmf);
ok(!hmf, "SetMetaFileBitsEx should fail\n");
ok(GetLastError() == ERROR_INVALID_DATA ||
broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
@@ -2170,7 +2162,6 @@ static void test_SetMetaFileBits(void)
/* Now with odd size */
SetLastError(0xdeadbeef);
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS) - 1, MF_GRAPHICS_BITS);
- trace("hmf %p\n", hmf);
ok(!hmf, "SetMetaFileBitsEx should fail\n");
ok(GetLastError() == 0xdeadbeef /* XP SP1 */, "wrong error %d\n", GetLastError());
@@ -2184,7 +2175,6 @@ static void test_SetMetaFileBits(void)
mh->mtHeaderSize = 0;
SetLastError(0xdeadbeef);
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS), buf);
- trace("hmf %p\n", hmf);
ok(!hmf, "SetMetaFileBitsEx should fail\n");
ok(GetLastError() == ERROR_INVALID_DATA ||
broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
@@ -2196,7 +2186,6 @@ static void test_SetMetaFileBits(void)
/* corruption of mtSize doesn't lead to a failure */
mh->mtSize *= 2;
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS), buf);
- trace("hmf %p\n", hmf);
ok(hmf != 0, "SetMetaFileBitsEx error %d\n", GetLastError());
if (compare_mf_bits(hmf, MF_GRAPHICS_BITS, sizeof(MF_GRAPHICS_BITS), "mf_Graphics") != 0)
@@ -2215,7 +2204,6 @@ static void test_SetMetaFileBits(void)
/* zeroing mtSize doesn't lead to a failure */
mh->mtSize = 0;
hmf = SetMetaFileBitsEx(sizeof(MF_GRAPHICS_BITS), buf);
- trace("hmf %p\n", hmf);
ok(hmf != 0, "SetMetaFileBitsEx error %d\n", GetLastError());
if (compare_mf_bits(hmf, MF_GRAPHICS_BITS, sizeof(MF_GRAPHICS_BITS), "mf_Graphics") != 0)
@@ -2242,7 +2230,6 @@ static void test_mf_Graphics(void)
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
ret = MoveToEx(hdcMetafile, 1, 1, NULL);
ok( ret, "MoveToEx error %d.\n", GetLastError());
@@ -2301,7 +2288,6 @@ static void test_mf_PatternBrush(void)
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
hBrush = SelectObject(hdcMetafile, hBrush);
ok(hBrush != 0, "SelectObject error %d.\n", GetLastError());
@@ -2385,7 +2371,6 @@ static void test_mf_ExtTextOut_on_path(void)
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
- trace("hdcMetafile %p\n", hdcMetafile);
ret = BeginPath(hdcMetafile);
ok(!ret, "BeginPath on metafile DC should fail\n");
--
2.20.1
1
0
25 Feb '20
From: Connor McAdams <conmanx360(a)gmail.com>
Signed-off-by: Connor McAdams <conmanx360(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
v2: Clean it up a bit.
dlls/d3d10/d3d10_private.h | 10 ++++++
dlls/d3d10/effect.c | 62 ++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h
index 96020cd4a0c..f83ff0d4c94 100644
--- a/dlls/d3d10/d3d10_private.h
+++ b/dlls/d3d10/d3d10_private.h
@@ -114,6 +114,15 @@ struct d3d10_effect_state_object_variable
} object;
};
+struct d3d10_effect_buffer_variable
+{
+ ID3D10Buffer *buffer;
+ ID3D10ShaderResourceView *resource_view;
+
+ BOOL changed;
+ BYTE *local_buffer;
+};
+
/* ID3D10EffectType */
struct d3d10_effect_type
{
@@ -169,6 +178,7 @@ struct d3d10_effect_variable
{
struct d3d10_effect_state_object_variable state;
struct d3d10_effect_shader_variable shader;
+ struct d3d10_effect_buffer_variable buffer;
} u;
};
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c
index 91e713bdf54..3ee9bf7a35c 100644
--- a/dlls/d3d10/effect.c
+++ b/dlls/d3d10/effect.c
@@ -2096,6 +2096,55 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size,
return S_OK;
}
+static HRESULT create_variable_buffer(struct d3d10_effect_variable *v, D3D10_CBUFFER_TYPE type)
+{
+ D3D10_BUFFER_DESC buffer_desc;
+ D3D10_SUBRESOURCE_DATA subresource_data;
+ D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
+ ID3D10Device *device = v->effect->device;
+ HRESULT hr;
+
+ if (!(v->u.buffer.local_buffer = heap_alloc_zero(v->type->size_unpacked)))
+ {
+ ERR("Failed to allocate local constant buffer memory.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ buffer_desc.ByteWidth = v->type->size_unpacked;
+ buffer_desc.Usage = D3D10_USAGE_DEFAULT;
+ buffer_desc.CPUAccessFlags = 0;
+ buffer_desc.MiscFlags = 0;
+ if (type == D3D10_CT_CBUFFER)
+ buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
+ else
+ buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
+
+ subresource_data.pSysMem = v->u.buffer.local_buffer;
+ subresource_data.SysMemPitch = 0;
+ subresource_data.SysMemSlicePitch = 0;
+
+ if (FAILED(hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &subresource_data, &v->u.buffer.buffer)))
+ return hr;
+
+ if (type == D3D10_CT_TBUFFER)
+ {
+ srv_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
+ srv_desc.ViewDimension = D3D_SRV_DIMENSION_BUFFER;
+ srv_desc.Buffer.ElementOffset = 0;
+ srv_desc.Buffer.ElementWidth = v->type->size_unpacked / 16;
+ if (v->type->size_unpacked % 16)
+ WARN("Unexpected texture buffer size not a multiple of 16.\n");
+
+ if (FAILED(hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)v->u.buffer.buffer,
+ &srv_desc, &v->u.buffer.resource_view)))
+ return hr;
+ }
+ else
+ v->u.buffer.resource_view = NULL;
+
+ return S_OK;
+}
+
static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
const char **ptr, struct d3d10_effect_variable *l)
{
@@ -2282,6 +2331,12 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
+ if (l->type->size_unpacked)
+ {
+ if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
+ return hr;
+ }
+
return S_OK;
}
@@ -2760,6 +2815,13 @@ static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l)
}
heap_free(l->annotations);
}
+
+ heap_free(l->u.buffer.local_buffer);
+
+ if (l->u.buffer.buffer)
+ ID3D10Buffer_Release(l->u.buffer.buffer);
+ if (l->u.buffer.resource_view)
+ ID3D10ShaderResourceView_Release(l->u.buffer.resource_view);
}
/* IUnknown methods */
--
2.24.1
1
3
From: Zebediah Figura <zfigura(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/d3dcompiler_43/asmshader.y | 4 +--
dlls/d3dcompiler_43/bytecodewriter.c | 6 +---
dlls/d3dcompiler_43/d3dcompiler_private.h | 38 +++++++++++------------
dlls/d3dcompiler_43/utils.c | 8 ++---
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/dlls/d3dcompiler_43/asmshader.y b/dlls/d3dcompiler_43/asmshader.y
index 32b37d0885d..1b7a07313fc 100644
--- a/dlls/d3dcompiler_43/asmshader.y
+++ b/dlls/d3dcompiler_43/asmshader.y
@@ -1148,11 +1148,11 @@ swizzle: /* empty */
else {
DWORD last, i;
- $$ = $2.swizzle << BWRITERVS_SWIZZLE_SHIFT;
+ $$ = $2.swizzle;
/* Fill the swizzle by extending the last component */
last = ($2.swizzle >> 2 * ($2.idx - 1)) & 0x03;
for(i = $2.idx; i < 4; i++){
- $$ |= last << (BWRITERVS_SWIZZLE_SHIFT + 2 * i);
+ $$ |= last << (2 * i);
}
TRACE("Got a swizzle: %08x\n", $$);
}
diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c
index 14162ab212b..42013dfba3f 100644
--- a/dlls/d3dcompiler_43/bytecodewriter.c
+++ b/dlls/d3dcompiler_43/bytecodewriter.c
@@ -342,8 +342,6 @@ static void put_dword(struct bytecode_buffer *buffer, DWORD value) {
/* bwriter -> d3d9 conversion functions. */
static DWORD d3d9_swizzle(DWORD bwriter_swizzle)
{
- /* Currently a NOP, but this allows changing the internal definitions
- * without side effects. */
DWORD ret = 0;
if ((bwriter_swizzle & BWRITERVS_X_X) == BWRITERVS_X_X) ret |= D3DVS_X_X;
@@ -1270,9 +1268,7 @@ static void instr_ps_1_0123_texld(struct bc_writer *This,
This->funcs->dstreg(This, &instr->dst, buffer, instr->shift, instr->dstmod);
} else if(instr->src[0].type == BWRITERSPR_TEMP) {
- swizzlemask = (3 << BWRITERVS_SWIZZLE_SHIFT) |
- (3 << (BWRITERVS_SWIZZLE_SHIFT + 2)) |
- (3 << (BWRITERVS_SWIZZLE_SHIFT + 4));
+ swizzlemask = 3 | (3 << 2) | (3 << 4);
if((instr->src[0].u.swizzle & swizzlemask) == (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z)) {
TRACE("writing texreg2rgb\n");
This->funcs->opcode(This, instr, D3DSIO_TEXREG2RGB & D3DSI_OPCODE_MASK, buffer);
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 45dbff7225b..5fc3161f5f0 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -542,25 +542,25 @@ enum bwritershader_param_srcmod_type
#define BWRITERVS_SWIZZLE_SHIFT 16
#define BWRITERVS_SWIZZLE_MASK (0xFF << BWRITERVS_SWIZZLE_SHIFT)
-#define BWRITERVS_X_X (0 << BWRITERVS_SWIZZLE_SHIFT)
-#define BWRITERVS_X_Y (1 << BWRITERVS_SWIZZLE_SHIFT)
-#define BWRITERVS_X_Z (2 << BWRITERVS_SWIZZLE_SHIFT)
-#define BWRITERVS_X_W (3 << BWRITERVS_SWIZZLE_SHIFT)
-
-#define BWRITERVS_Y_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 2))
-#define BWRITERVS_Y_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 2))
-#define BWRITERVS_Y_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 2))
-#define BWRITERVS_Y_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 2))
-
-#define BWRITERVS_Z_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 4))
-#define BWRITERVS_Z_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 4))
-#define BWRITERVS_Z_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 4))
-#define BWRITERVS_Z_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 4))
-
-#define BWRITERVS_W_X (0 << (BWRITERVS_SWIZZLE_SHIFT + 6))
-#define BWRITERVS_W_Y (1 << (BWRITERVS_SWIZZLE_SHIFT + 6))
-#define BWRITERVS_W_Z (2 << (BWRITERVS_SWIZZLE_SHIFT + 6))
-#define BWRITERVS_W_W (3 << (BWRITERVS_SWIZZLE_SHIFT + 6))
+#define BWRITERVS_X_X (0)
+#define BWRITERVS_X_Y (1)
+#define BWRITERVS_X_Z (2)
+#define BWRITERVS_X_W (3)
+
+#define BWRITERVS_Y_X (0 << 2)
+#define BWRITERVS_Y_Y (1 << 2)
+#define BWRITERVS_Y_Z (2 << 2)
+#define BWRITERVS_Y_W (3 << 2)
+
+#define BWRITERVS_Z_X (0 << 4)
+#define BWRITERVS_Z_Y (1 << 4)
+#define BWRITERVS_Z_Z (2 << 4)
+#define BWRITERVS_Z_W (3 << 4)
+
+#define BWRITERVS_W_X (0 << 6)
+#define BWRITERVS_W_Y (1 << 6)
+#define BWRITERVS_W_Z (2 << 6)
+#define BWRITERVS_W_W (3 << 6)
#define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 1436ed6bf3e..b2b1e25bbdc 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -291,10 +291,10 @@ static const char *debug_print_swizzle(DWORD arg)
return ".w";
}
- swizzle[0] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 0)) & 0x03;
- swizzle[1] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 2)) & 0x03;
- swizzle[2] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 4)) & 0x03;
- swizzle[3] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 6)) & 0x03;
+ swizzle[0] = arg & 3;
+ swizzle[1] = (arg >> 2) & 3;
+ swizzle[2] = (arg >> 4) & 3;
+ swizzle[3] = (arg >> 6) & 3;
ret[0] = '.';
for (i = 0; i < 4; ++i)
--
2.25.0
4
13