Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unadvertised/unimplemented D3D8 device caps #164

Closed
WinterSnowfall opened this issue May 23, 2023 · 6 comments
Closed

Unadvertised/unimplemented D3D8 device caps #164

WinterSnowfall opened this issue May 23, 2023 · 6 comments

Comments

@WinterSnowfall
Copy link

WinterSnowfall commented May 23, 2023

There are quite a few things we are not advertising at the moment as part of GetDeviceCaps() calls (some for good reason, but some only because d3d9 does not advertise them or include them).

Since some applications apparently depend on what we report here and may or may not enable some features based on it (e.g. character shadows in Unreal Tournament 2004), or rely on it for proper functionality (e.g. D3DPRASTERCAPS_ZBIAS and SW: Republic Commando), we should try to match native d3d8 as much as possible.

I'll keep track of everything I find here:

Caps2:

  • D3DCAPS2_NO2DDURING3DSCENE (unadvertised, which is probably what we want anyway, also unadvertised by WineD3D, not a part of d3d9)

When the D3DCAPS2_NO2DDURING3DSCENE capability is set by the driver, it means that 2-D operations cannot be performed between calls to IDirect3DDevice8::BeginScene and IDirect3DDevice8::EndScene.

DevCaps:

  • D3DDEVCAPS_QUINTICRTPATCHES
  • D3DDEVCAPS_RTPATCHES
  • D3DDEVCAPS_RTPATCHHANDLEZERO
  • D3DDEVCAPS_NPATCHES

All of the above are currently not advertised by d9vk and unimplemented, but are most likely needed for ATI TruForm/Curved Surfaces support. All these are also part of the d3d9 spec.

PrimitiveMiscCaps:

  • D3DPMISCCAPS_LINEPATTERNREP (unadvertised and unimplemented by d8vk (dependent on D3DPRASTERCAPS_PAT), aslo not advertised by WineD3D, not a part of d3d9)

The driver can handle values other than 1 in the wRepeatFactor member of the D3DLINEPATTERN structure. (This applies only to line-drawing primitives.)

RasterCaps:

  • D3DPRASTERCAPS_ANTIALIASEDGES (unadvertised and unimplemented by d8vk, also unadvertised by WineD3D, not a part of d3d9)

Device can antialias lines forming the convex outline of objects.

  • D3DPRASTERCAPS_PAT (unadvertised and unimplemented by d8vk, advertised by WineD3D, not a part of d3d9)

The driver can perform patterned drawing lines or fills with D3DRS_LINEPATTERN for the primitive being queried.

  • D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE (unadvertised, which is probably what we want anyway, also unadvertised by WineD3D, not a part of d3d9)

Device provides limited multisample support through a stretch-blt implementation. When this capability is set, D3DRS_MULTISAMPLEANTIALIAS cannot be turned on and off in the middle of a scene. Multisample masking cannot be performed if this flag is set.

VertexProcessingCaps:

  • D3DVTXPCAPS_NO_VSDT_UBYTE4 (unadvertised, which is probably what we want anyway, also unadvertised by WineD3D, not a part of d3d9)

Device does not support the D3DVSDT_UBYTE4 vertex declaration type.

@WinterSnowfall
Copy link
Author

WinterSnowfall commented May 23, 2023

I wrote some tests for the above as well, and thanks to @Blisto91 we also have some results from the fabled land of Windows.

  • Windows 11 (AMD):
Running Device capabilities tests:
  ~ The D3DCAPS2_NO2DDURING3DSCENE capability is not supported
  ~ The D3DDEVCAPS_QUINTICRTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHHANDLEZERO capability is not supported
  ~ The D3DDEVCAPS_NPATCHES capability is not supported
  - The D3DPRASTERCAPS_ANTIALIASEDGES test has failed
  - The D3DPRASTERCAPS_PAT test has failed
  + The D3DPRASTERCAPS_ZBIAS test has passed
  ~ The D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE capability is not supported
  ~ The D3DVTXPCAPS_NO_VSDT_UBYTE4 capability is not supported
  + The Vertex Shader Version test has passed (1.1)
  + The Max Vertex Shader Const test has passed (96)
  + The Pixel Shader Version test has passed (1.4)
  • WineD3D (Nvidia):
Running Device capabilities tests:
  ~ The D3DCAPS2_NO2DDURING3DSCENE capability is not supported
  ~ The D3DDEVCAPS_QUINTICRTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHHANDLEZERO capability is not supported
  ~ The D3DDEVCAPS_NPATCHES capability is not supported
  - The D3DPRASTERCAPS_ANTIALIASEDGES test has failed
  + The D3DPRASTERCAPS_PAT test has passed
  + The D3DPRASTERCAPS_ZBIAS test has passed
  ~ The D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE capability is not supported
  ~ The D3DVTXPCAPS_NO_VSDT_UBYTE4 capability is not supported
  + The Vertex Shader Version test has passed (1.1)
  + The Max Vertex Shader Const test has passed (256)
  + The Pixel Shader Version test has passed (1.4)
  • D8VK 1.0 (Nvidia):
Running Device capabilities tests:
  ~ The D3DCAPS2_NO2DDURING3DSCENE capability is not supported
  ~ The D3DDEVCAPS_QUINTICRTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHHANDLEZERO capability is not supported
  ~ The D3DDEVCAPS_NPATCHES capability is not supported
  - The D3DPRASTERCAPS_ANTIALIASEDGES test has failed
  - The D3DPRASTERCAPS_PAT test has failed
  - The D3DPRASTERCAPS_ZBIAS test has failed
  ~ The D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE capability is not supported
  ~ The D3DVTXPCAPS_NO_VSDT_UBYTE4 capability is not supported
  - The Vertex Shader Version test has failed (1.4)
  + The Max Vertex Shader Const test has passed (256)
  + The Pixel Shader Version test has passed (1.4)
Running Device capabilities tests:
  ~ The D3DCAPS2_NO2DDURING3DSCENE capability is not supported
  ~ The D3DDEVCAPS_QUINTICRTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHES capability is not supported
  ~ The D3DDEVCAPS_RTPATCHHANDLEZERO capability is not supported
  ~ The D3DDEVCAPS_NPATCHES capability is not supported
  - The D3DPRASTERCAPS_ANTIALIASEDGES test has failed
  - The D3DPRASTERCAPS_PAT test has failed
  + The D3DPRASTERCAPS_ZBIAS test has passed
  ~ The D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE capability is not supported
  ~ The D3DVTXPCAPS_NO_VSDT_UBYTE4 capability is not supported
  + The Vertex Shader Version test has passed (1.1)
  + The Max Vertex Shader Const test has passed (256)
  + The Pixel Shader Version test has passed (1.4)

@WinterSnowfall
Copy link
Author

On a side note, I have checked dgVoodoo2, and it seems to be advertising only D3DDEVCAPS_NPATCHES in order to expose support for ATI TruForm. We'll probably need to advertise it as well once we add support for N-Patches (see #148).

@WinterSnowfall
Copy link
Author

WinterSnowfall commented May 30, 2023

Also looked at the limit values (thanks again @Blisto91 and @K0bin):

AMD (Windows):

Listing device capability limits:
  ~ MaxTextureWidth: 16384
  ~ MaxTextureHeight: 16384
  ~ MaxVolumeExtent: 8192
  ~ MaxTextureRepeat: 8192
  ~ MaxTextureAspectRatio: 8192
  ~ MaxAnisotropy: 16
  ~ MaxVertexW: 1e+10
  ~ GuardBandLeft: -32768
  ~ GuardBandTop: -32768
  ~ GuardBandRight: 32768
  ~ GuardBandBottom: 32768
  ~ ExtentsAdjust: 0
  ~ MaxTextureBlendStages: 8
  ~ MaxSimultaneousTextures: 8
  ~ MaxActiveLights: 8 (I), 4294967295 (SWVP), 10 (HWVP)
  ~ MaxUserClipPlanes: 6 (I), 6 (SWVP), 6 (HWVP)
  ~ MaxVertexBlendMatrices: 4 (I), 4 (SWVP), 4 (HWVP)
  ~ MaxVertexBlendMatrixIndex: 0 (I), 255 (SWVP), 8 (HWVP)
  ~ MaxPointSize: 256
  ~ MaxPrimitiveCount: 5592405
  ~ MaxVertexIndex: 16777215
  ~ MaxStreams: 16
  ~ MaxStreamStride: 508
  ~ MaxVertexShaderConst: 256
  ~ MaxPixelShaderValue: 3.40282e+38

Nvidia (Windows):

Listing device capability limits:
  ~ MaxTextureWidth: 16384
  ~ MaxTextureHeight: 16384
  ~ MaxVolumeExtent: 2048
  ~ MaxTextureRepeat: 8192
  ~ MaxTextureAspectRatio: 16384
  ~ MaxAnisotropy: 16
  ~ MaxVertexW: 1e+10
  ~ GuardBandLeft: -1e+08
  ~ GuardBandTop: -1e+08
  ~ GuardBandRight: 1e+08
  ~ GuardBandBottom: 1e+08
  ~ ExtentsAdjust: 0
  ~ MaxTextureBlendStages: 8
  ~ MaxSimultaneousTextures: 8
  ~ MaxActiveLights: 8 (I), 255 (SWVP), 10 (HWVP)
  ~ MaxUserClipPlanes: 8 (I), 6 (SWVP), 8 (HWVP)
  ~ MaxVertexBlendMatrices: 4 (I), 4 (SWVP), 4 (HWVP)
  ~ MaxVertexBlendMatrixIndex: 0 (I), 255 (SWVP), 8 (HWVP)
  ~ MaxPointSize: 8192
  ~ MaxPrimitiveCount: 16777215
  ~ MaxVertexIndex: 16777215
  ~ MaxStreams: 16
  ~ MaxStreamStride: 255
  ~ MaxVertexShaderConst: 256
  ~ MaxPixelShaderValue: 65504

WineD3D:

Listing device capability limits:
  ~ MaxTextureWidth: 32768
  ~ MaxTextureHeight: 32768
  ~ MaxVolumeExtent: 16384
  ~ MaxTextureRepeat: 32768
  ~ MaxTextureAspectRatio: 32768
  ~ MaxAnisotropy: 16
  ~ MaxVertexW: 1e+10
  ~ GuardBandLeft: -32768
  ~ GuardBandTop: -32768
  ~ GuardBandRight: 32768
  ~ GuardBandBottom: 32768
  ~ ExtentsAdjust: 0
  ~ MaxTextureBlendStages: 8
  ~ MaxSimultaneousTextures: 8
  ~ MaxActiveLights: 8 (I), 8 (SWVP), 8 (HWVP)
  ~ MaxUserClipPlanes: 8 (I), 8 (SWVP), 8 (HWVP)
  ~ MaxVertexBlendMatrices: 4 (I), 4 (SWVP), 4 (HWVP)
  ~ MaxVertexBlendMatrixIndex: 0 (I), 255 (SWVP), 8 (HWVP)
  ~ MaxPointSize: 2047
  ~ MaxPrimitiveCount: 5592405
  ~ MaxVertexIndex: 16777215
  ~ MaxStreams: 16
  ~ MaxStreamStride: 1024
  ~ MaxVertexShaderConst: 256
  ~ MaxPixelShaderValue: 3.40282e+38

d8vk (with doitsujin#3461):

Listing device capability limits:
  ~ MaxTextureWidth: 16384
  ~ MaxTextureHeight: 16384
  ~ MaxVolumeExtent: 8192
  ~ MaxTextureRepeat: 8192
  ~ MaxTextureAspectRatio: 8192
  ~ MaxAnisotropy: 16
  ~ MaxVertexW: 1e+10
  ~ GuardBandLeft: -32768
  ~ GuardBandTop: -32768
  ~ GuardBandRight: 32768
  ~ GuardBandBottom: 32768
  ~ ExtentsAdjust: 0
  ~ MaxTextureBlendStages: 8
  ~ MaxSimultaneousTextures: 8
  ~ MaxActiveLights: 8 (I), 8 (SWVP), 8 (HWVP)
  ~ MaxUserClipPlanes: 6 (I), 6 (SWVP), 6 (HWVP)
  ~ MaxVertexBlendMatrices: 4 (I), 4 (SWVP), 4 (HWVP)
  ~ MaxVertexBlendMatrixIndex: 0 (I), 255 (SWVP), 8 (HWVP)
  ~ MaxPointSize: 256
  ~ MaxPrimitiveCount: 5592405
  ~ MaxVertexIndex: 16777215
  ~ MaxStreams: 16
  ~ MaxStreamStride: 508
  ~ MaxVertexShaderConst: 256
  ~ MaxPixelShaderValue: 3.40282e+38

The only thing that stands out vs native & WineD3D is MaxVertexBlendMatrixIndex for SWVP, but I'm not sure if it's relevant in any way. Spec says:

DWORD value that specifies the maximum matrix index that can be indexed into using the per-vertex indices. The number of matrices is MaxVertexBlendMatrixIndex + 1, which is the size of the matrix palette. If normals are present in the vertex data that needs to be blended for lighting, then the number of matrices is half the number specified by this capability flag. If MaxVertexBlendMatrixIndex is set to zero, the driver does not support indexed vertex blending. If this value is not zero then the valid range of indices is zero through MaxVertexBlendMatrixIndex.

A zero value for MaxVertexBlendMatrixIndex indicates that the driver does not support indexed matrices.

When software vertex processing is used, 256 matrices could be used for indexed vertex blending, with or without normal blending.

For a given physical device, this capability may vary across Direct3DDevice objects depending on the parameters supplied to IDirect3D8::CreateDevice

@WinterSnowfall
Copy link
Author

WinterSnowfall commented May 30, 2023

Apparently the MaxVertexBlendMatrixIndex values do make a difference, as reporting this as native does fixes at least one crash in a d3d9 game (see doitsujin#3461). I'm not aware of any d3d8 games being affected so far, but who knows what monsters lurk beyond the world's edge.

@WinterSnowfall
Copy link
Author

WinterSnowfall commented Jun 26, 2023

Updated the post above with more detailed device cap information (capturing parameters that may vary depending on context). MaxVertexBlendMatrixIndex will be fixed on the next rebase, otherwise I'm not sure if we need/want to adjust anything.

I remember us scoring worse in the point sprite test in 3DMark2001 SE, and I see WineD3D (as well as native Nvidia) are advertising larger MaxPointSize values. Maybe that's worth checking out.

Also, I think we should bump the MaxActiveLights to the lowest common denominator of 255 (SWVP) and 10 (HWVP) to match what native is doing. Perhaps not a lot of games care about these limits, but aligning with native never hurt anyone.

Nevermind, lights in d9vk are shader based and it's only handling a max of 8 at the moment regardless of SWVP/HWVP, which is most likely fine (also what WineD3D is doing, so meh).

@WinterSnowfall
Copy link
Author

I think we've tapped out this pit and things are roughly where we want them to be in terms of reported caps. For posterity, there's still:

But both can be tracked separately and are already listed by d3d8 tests, so closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant