Commit Graph

18 Commits

Author SHA1 Message Date
Billy Laws
175ba11f07 Integrate BCeNabler support into QuirkManager
Allows using BCn format textures on devices where they are unsupported by the driver.
2022-04-14 14:14:52 +05:30
PixelyIon
6a831f6ed7 Add VK_EXT_shader_demote_to_helper_invocation Quirk
An assumption was hardcoded into `Shader::Profile` regarding devices supporting demotion of shader invocations to helpers. This assumption wasn't backed by enabling the `VK_EXT_shader_demote_to_helper_invocation` extension via a quirk leading to assertions when it was used by the shader compiler, a quirk has now been added for the extension and is supplied to the shader compiler accordingly.
2022-04-14 14:14:52 +05:30
PixelyIon
87c8dc94d2 Implement Maxwell3D Samplers
Maxwell3D `TextureSamplerControl` (TSC) are fully converted into Vulkan samplers with extension backing for all aspects that require them (border color/reduction mode) and approximations where Vulkan doesn't support certain functionality (sampler address mode) alongside cases where extensions may not be present (border color).
2022-04-14 14:14:52 +05:30
PixelyIon
23cdfe2139 Implement Maxwell3D Index Buffers
Adds support for index buffers including U8 index buffers via the `VK_EXT_index_type_uint8` extension which has been added as an optional quirk but an exception will be thrown if the guest utilizes it but the host doesn't support it.
2022-04-14 14:14:52 +05:30
PixelyIon
b09f28c0ba Implement Missing Shader Compiler Quirks
Introduces the `supportsShaderViewportIndexLayer` quirk and sets `Shader::Profile::support_int64_atomics` depending on if the `supportsAtomicInt64` quirk is available.
2022-04-14 14:14:52 +05:30
PixelyIon
f3e81094a2 Implement Shader Compiler Property Quirks
Introduces the `floatControls`, `supportsSubgroupVote` and `subgroupSize` quirks for the shader compiler which are based on Vulkan `PhysicalDevice` properties.
2022-04-14 14:14:52 +05:30
PixelyIon
0588a525b4 Implement Shader Compiler Extension/Feature Quirks
Introduces several quirks for optional features used by the shader compiler which are now reported in the `Shader::HostTranslateInfo` and `Shader::Profile` structure. There are still property-related quirks for the shader compiler which haven't been implemented in this commit.
2022-04-14 14:14:52 +05:30
PixelyIon
7df2670ece Fix QuirkManager's EXT_SET_V macro bug
`EXT_SET_V` would enable the extension regardless of if it was actually the correct extension or if the version was high enough as long as the hash matched.

Co-authored-by: Billy Laws <blaws05@gmail.com>
2022-04-14 14:14:52 +05:30
PixelyIon
e9ed771b48 Check for supportsMultipleViewports feature before usage
If the host only supports a single viewport then we set `viewportCount` and `scissorCount` in `VkPipelineViewportStateCreateInfo` to 1.
2022-04-14 14:14:52 +05:30
PixelyIon
841ee9fc15 Check for vertexAttributeInstanceRateZeroDivisor feature before usage
Check for `vertexAttributeInstanceRateZeroDivisor` in `VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT` when the Maxwell3D register corresponding to the vertex attribute divisor is set to 0. If it isn't then it logs a warning and sets the value anyway which could result in UB since the only alternative is an exception that stops emulation which might not be optimal if the game mostly works fine without this, we will add a user-facing warning when we intentionally allow UB like this in the future.
2022-04-14 14:14:52 +05:30
PixelyIon
c3895a8197 Support VkPhysicalDeviceFeatures2 Extensions
Implement the infrastructure to depend on `VkPhysicalDeviceFeatures2` extended feature structures which can be utilized to retrieve the specifics of features from extensions. It is implemented in the form of `vk::StructureChain` with `vk::PhysicalDeviceFeatures2` that can be extended with any extension feature structures.
2022-04-14 14:14:52 +05:30
PixelyIon
ff5515d4d1 Implement Maxwell3D Vertex Buffer Bindings
This implements everything in Maxwell3D vertex buffer bindings including vertex attribute divisors which require the extension `VK_EXT_vertex_attribute_divisor` to emulate them correctly, this has been implemented in the form of of a quirk. It is dynamically enabled/disabled based on if the host GPU supports it and a warning is provided when it is used by the guest but the host GPU doesn't support it.
2022-04-14 14:14:52 +05:30
PixelyIon
cd737fbdd8 Add Required VkDevice Features
A prior commit added the ability to utilize features with quirks but this implements the ability to require a feature be present on the host or an exception will be thrown. It allows us to make useful assumptions that result in a better architecture in certain cases.
2022-04-14 14:14:52 +05:30
PixelyIon
081d3277c1 Enable Quirk + Required VkDevice Extensions
Implements the infrastructure required to enable optional extensions set in `QuirkManager` alongside the required extensions in the `GPU` class. All extensions should be correctly resolved now and according to what the device supports.
2022-04-14 14:14:52 +05:30
PixelyIon
51659e1329 Enable VkDevice Features Selectively
We selectively enable GPU features that we require as enabling all of them might result in extra driver overhead in certain circumstances. Setting them is handled by `QuirkManager` with the new `FEAT_SET` function that ties a quirk with a feature.
2022-04-14 14:14:52 +05:30
PixelyIon
83ec99fa48 Print GPU Quirks At Startup
It is essential to know what quirks a certain GPU may have to debug an issue, these are now printed at startup into the log alongside all other GPU information. A new `QuirkManager::Summary` function was implemented to provide this functionality.
2022-04-14 14:14:52 +05:30
PixelyIon
01eb16e59a Implement Maxwell3D Color Logic Operations
Implements a basic part of Vulkan blending state which are color logic operations applied on the framebuffer after running the fragment shader. It is an optional feature in Vulkan and not supported on any mobile GPU vendor aside from ImgTec/NVIDIA by default.
2022-04-14 14:14:52 +05:30
PixelyIon
8ef225a37d Introduce QuirkManager for runtime GPU quirk tracking
We require a way to track certain host GPU features that are optional such as Vulkan extensions, this is what the `QuirkManager` class does as it checks for all quirks and holds them allowing other components to branch based off these quirks.
2022-04-14 14:14:52 +05:30