Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d9/d3d9_private.h | 19 +++++++++-------- dlls/d3d9/device.c | 46 +++++++++++++++++++++++++++++++++------- dlls/d3d9/directx.c | 2 +- dlls/wined3d/directx.c | 4 ---- include/wine/wined3d.h | 4 ---- 5 files changed, 49 insertions(+), 26 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index a0daaf42880..7f0901805b0 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -52,15 +52,6 @@
extern const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops DECLSPEC_HIDDEN;
-HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; -D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; -unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; -void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters, - const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN; -void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN; - struct d3d9 { IDirect3D9Ex IDirect3D9Ex_iface; @@ -71,6 +62,16 @@ struct d3d9 BOOL extended; };
+HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; +D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; +void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters, + const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN; +void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps, + const struct d3d9 *d3d9, unsigned int adapter_ordinal) DECLSPEC_HIDDEN; + BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) DECLSPEC_HIDDEN;
struct fvf_declaration diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index b4887dff450..393069d6b9e 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -360,7 +360,8 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch return TRUE; }
-void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) +void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps, + const struct d3d9 *d3d9, unsigned int adapter_ordinal) { static const DWORD ps_minor_version[] = {0, 4, 0, 0}; static const DWORD vs_minor_version[] = {0, 1, 0, 0}; @@ -370,9 +371,12 @@ void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MAGFLINEAR |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD| D3DPTFILTERCAPS_MAGFGAUSSIANQUAD; + struct wined3d_output *wined3d_output, *master_output; + struct wined3d_adapter *wined3d_adapter; + unsigned int output_idx, output_count;
caps->DeviceType = (D3DDEVTYPE)wined3d_caps->DeviceType; - caps->AdapterOrdinal = wined3d_caps->AdapterOrdinal; + caps->AdapterOrdinal = adapter_ordinal; caps->Caps = wined3d_caps->Caps; caps->Caps2 = wined3d_caps->Caps2; caps->Caps3 = wined3d_caps->Caps3; @@ -426,9 +430,6 @@ void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d caps->PixelShader1xMaxValue = wined3d_caps->PixelShader1xMaxValue; caps->DevCaps2 = wined3d_caps->DevCaps2; caps->MaxNpatchTessellationLevel = wined3d_caps->MaxNpatchTessellationLevel; - caps->MasterAdapterOrdinal = wined3d_caps->MasterAdapterOrdinal; - caps->AdapterOrdinalInGroup = wined3d_caps->AdapterOrdinalInGroup; - caps->NumberOfAdaptersInGroup = wined3d_caps->NumberOfAdaptersInGroup; caps->DeclTypes = wined3d_caps->DeclTypes; caps->NumSimultaneousRTs = wined3d_caps->NumSimultaneousRTs; caps->StretchRectFilterCaps = wined3d_caps->StretchRectFilterCaps; @@ -520,6 +521,33 @@ void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d DWORD major = caps->VertexShaderVersion; caps->VertexShaderVersion = D3DVS_VERSION(major, vs_minor_version[major]); } + + /* Get adapter group information */ + output_idx = adapter_ordinal; + wined3d_output = d3d9->wined3d_outputs[output_idx]; + wined3d_adapter = wined3d_output_get_adapter(wined3d_output); + + master_output = wined3d_adapter_get_output(wined3d_adapter, 0); + for (output_idx = 0; output_idx < d3d9->wined3d_output_count; ++output_idx) + { + if (master_output == d3d9->wined3d_outputs[output_idx]) + { + caps->MasterAdapterOrdinal = output_idx; + break; + } + } + + output_count = wined3d_adapter_get_output_count(wined3d_adapter); + for (output_idx = 0; output_idx < output_count; ++output_idx) + { + if (wined3d_output == wined3d_adapter_get_output(wined3d_adapter, output_idx)) + { + caps->AdapterOrdinalInGroup = output_idx; + break; + } + } + + caps->NumberOfAdaptersInGroup = caps->AdapterOrdinalInGroup ? 0 : output_count; }
static void device_reset_viewport_state(struct d3d9_device *device) @@ -709,7 +737,7 @@ static HRESULT WINAPI d3d9_device_GetDeviceCaps(IDirect3DDevice9Ex *iface, D3DCA hr = wined3d_device_get_device_caps(device->wined3d_device, &wined3d_caps); wined3d_mutex_unlock();
- d3dcaps_from_wined3dcaps(caps, &wined3d_caps); + d3dcaps_from_wined3dcaps(caps, &wined3d_caps, device->d3d_parent, device->adapter_ordinal);
return hr; } @@ -4592,9 +4620,10 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine struct wined3d_swapchain_desc *swapchain_desc; struct wined3d_adapter *wined3d_adapter; struct d3d9_swapchain *d3d_swapchain; - struct wined3d_caps caps; + struct wined3d_caps wined3d_caps; unsigned int output_idx; unsigned i, count = 1; + D3DCAPS9 caps; HRESULT hr;
static const enum wined3d_feature_level feature_levels[] = @@ -4633,7 +4662,8 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine return hr; }
- wined3d_get_device_caps(wined3d_adapter, device_type, &caps); + wined3d_get_device_caps(wined3d_adapter, device_type, &wined3d_caps); + d3dcaps_from_wined3dcaps(&caps, &wined3d_caps, parent, adapter); device->max_user_clip_planes = caps.MaxUserClipPlanes; device->vs_uniform_count = caps.MaxVertexShaderConst; if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index d79b32515fa..3d4e2392719 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -439,7 +439,7 @@ static HRESULT WINAPI d3d9_GetDeviceCaps(IDirect3D9Ex *iface, UINT adapter, D3DD hr = wined3d_get_device_caps(wined3d_adapter, device_type, &wined3d_caps); wined3d_mutex_unlock();
- d3dcaps_from_wined3dcaps(caps, &wined3d_caps); + d3dcaps_from_wined3dcaps(caps, &wined3d_caps, d3d9, adapter);
return hr; } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 8cf0d77e821..2fefb20a3e3 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1889,7 +1889,6 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d_adapter *adapter, d3d_info = &adapter->d3d_info;
caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF; - caps->AdapterOrdinal = adapter->ordinal;
caps->Caps = 0; caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED | @@ -2079,9 +2078,6 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d_adapter *adapter, caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET | WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET; caps->MaxNpatchTessellationLevel = 0; - caps->MasterAdapterOrdinal = 0; - caps->AdapterOrdinalInGroup = 0; - caps->NumberOfAdaptersInGroup = 1;
caps->NumSimultaneousRTs = d3d_info->limits.max_rt_count;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index affeb891e75..c0a03e41f8f 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1911,7 +1911,6 @@ struct wined3d_ddraw_caps struct wined3d_caps { enum wined3d_device_type DeviceType; - UINT AdapterOrdinal;
DWORD Caps; DWORD Caps2; @@ -1979,9 +1978,6 @@ struct wined3d_caps
float MaxNpatchTessellationLevel;
- UINT MasterAdapterOrdinal; - UINT AdapterOrdinalInGroup; - UINT NumberOfAdaptersInGroup; DWORD DeclTypes; DWORD NumSimultaneousRTs; DWORD StretchRectFilterCaps;
On Fri, 13 Mar 2020 at 13:07, Zhiyi Zhang zzhang@codeweavers.com wrote:
-HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; -D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; -unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; -void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN;
-void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN;
struct d3d9 { IDirect3D9Ex IDirect3D9Ex_iface; @@ -71,6 +62,16 @@ struct d3d9 BOOL extended; };
+HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; +D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; +void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN;
+void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps,
const struct d3d9 *d3d9, unsigned int adapter_ordinal) DECLSPEC_HIDDEN;
If you're going to move these, you may as well fix the parameter names. On the other hand, you could also consider doing something like the following:
void d3d9_caps_from_wined3dcaps(const struct d3d9 *d3d9, unsigned int adapter_ordinal, D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN;
and just leaving the other declarations where they are.
- /* Get adapter group information */
- output_idx = adapter_ordinal;
- wined3d_output = d3d9->wined3d_outputs[output_idx];
- wined3d_adapter = wined3d_output_get_adapter(wined3d_output);
- master_output = wined3d_adapter_get_output(wined3d_adapter, 0);
- for (output_idx = 0; output_idx < d3d9->wined3d_output_count; ++output_idx)
- {
if (master_output == d3d9->wined3d_outputs[output_idx])
{
caps->MasterAdapterOrdinal = output_idx;
break;
}
- }
- output_count = wined3d_adapter_get_output_count(wined3d_adapter);
- for (output_idx = 0; output_idx < output_count; ++output_idx)
- {
if (wined3d_output == wined3d_adapter_get_output(wined3d_adapter, output_idx))
{
caps->AdapterOrdinalInGroup = output_idx;
break;
}
- }
- caps->NumberOfAdaptersInGroup = caps->AdapterOrdinalInGroup ? 0 : output_count;
}
If you store the output ordinal in the wined3d_output_desc structure, the above would become:
caps->MasterAdapterOrdinal = output_idx - output_desc.orindal; caps->AdapterOrdinalInGroup = output_desc.ordinal;
On 3/16/20 8:02 PM, Henri Verbeet wrote:
On Fri, 13 Mar 2020 at 13:07, Zhiyi Zhang zzhang@codeweavers.com wrote:
-HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; -D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; -enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; -unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; -void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN;
-void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN;
struct d3d9 { IDirect3D9Ex IDirect3D9Ex_iface; @@ -71,6 +62,16 @@ struct d3d9 BOOL extended; };
+HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; +D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +BOOL is_gdi_compat_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; +enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; +unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage) DECLSPEC_HIDDEN; +void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc, DWORD presentation_interval) DECLSPEC_HIDDEN;
+void d3dcaps_from_wined3dcaps(D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps,
const struct d3d9 *d3d9, unsigned int adapter_ordinal) DECLSPEC_HIDDEN;
If you're going to move these, you may as well fix the parameter names. On the other hand, you could also consider doing something like the following:
void d3d9_caps_from_wined3dcaps(const struct d3d9 *d3d9, unsigned
int adapter_ordinal, D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN;
and just leaving the other declarations where they are.
So, only moving this function up?
- /* Get adapter group information */
- output_idx = adapter_ordinal;
- wined3d_output = d3d9->wined3d_outputs[output_idx];
- wined3d_adapter = wined3d_output_get_adapter(wined3d_output);
- master_output = wined3d_adapter_get_output(wined3d_adapter, 0);
- for (output_idx = 0; output_idx < d3d9->wined3d_output_count; ++output_idx)
- {
if (master_output == d3d9->wined3d_outputs[output_idx])
{
caps->MasterAdapterOrdinal = output_idx;
break;
}
- }
- output_count = wined3d_adapter_get_output_count(wined3d_adapter);
- for (output_idx = 0; output_idx < output_count; ++output_idx)
- {
if (wined3d_output == wined3d_adapter_get_output(wined3d_adapter, output_idx))
{
caps->AdapterOrdinalInGroup = output_idx;
break;
}
- }
- caps->NumberOfAdaptersInGroup = caps->AdapterOrdinalInGroup ? 0 : output_count;
}
If you store the output ordinal in the wined3d_output_desc structure, the above would become:
caps->MasterAdapterOrdinal = output_idx - output_desc.orindal; caps->AdapterOrdinalInGroup = output_desc.ordinal;
Will do. Thanks.
On Mon, 16 Mar 2020 at 17:02, Zhiyi Zhang zzhang@codeweavers.com wrote:
On 3/16/20 8:02 PM, Henri Verbeet wrote:
If you're going to move these, you may as well fix the parameter names. On the other hand, you could also consider doing something like the following:
void d3d9_caps_from_wined3dcaps(const struct d3d9 *d3d9, unsigned
int adapter_ordinal, D3DCAPS9 *caps, const struct wined3d_caps *wined3d_caps) DECLSPEC_HIDDEN;
and just leaving the other declarations where they are.
So, only moving this function up?
Down, and changing it to be a "d3d9_" function, but yes.