Commit Graph

17 Commits

Author SHA1 Message Date
Natalie Chouinard
0045b01ff9
opt: Add VulkanMemoryModelDeviceScope to trim (#5544)
Add the VulkanMemoryModelDeviceScope capability to the capability
trimming pass. According the the spec, "If the Vulkan memory model is
declared and any instruction uses Device scope, the
VulkanMemoryModelDeviceScope capability must be declared." Since this
case, based on the type of an operand, is not covered by the JSON
grammar, it is added explicitly.
2024-01-25 14:05:04 -05:00
Nathan Gauër
c7affa1707
opt: add Int16 and Float16 to capability trim pass (#5519)
Add support for Int16 and Float16 trim.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-01-04 20:01:03 +01:00
Nathan Gauër
f43c464d53
opt: add PhysicalStorageBufferAddresses to trim (#5476)
The PhysicalStorageBufferAddresses capability can now be
trimmed. From the spec, it seems any instruction enabled by this
required some operand to have the PhysicalStorageBuffer storage class.
This means checking the storage class is enough.

Now, because the pass uses the grammar, we don't need to add any
new logic.

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-11-14 12:49:04 -05:00
Nathan Gauër
c91e9d09b5
opt: add StorageImageReadWithoutFormat to cap trim (#5475)
The StorageImageReadWithoutFormat capability is only required when
an image type with the format set to Unknown is used with some specific
OpImageRead or OpImageSparseRead instructions.

This patch adds the required code to the capability trimming pass to
remove the StorageImageReadWithoutFormat capability when not required.

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-11-14 09:29:31 -05:00
Steven Perron
5bb595091b
Add ComputeDerivativeGroup*NV capabilities to trim capabilities pass. (#5430)
* Add ComputeDerivativeGroup*NV capabilities to trim capabilities pass.

* Add SPV_NV_compute_shader_derivatives to allow lists

No tests needed for this. The code path is well tested. Just adding new
data.
2023-10-16 19:03:33 +00:00
Cassandra Beckley
023a8c79e9
opt: add Float64 capability to trim pass (#5428) 2023-10-05 11:12:09 +02:00
Nathan Gauër
4e0b94ed7a
opt: add ImageMSArray capability to trim pass. (#5395)
From the Capability's text in the SPIRV spec:

```
An MS operand in OpTypeImage indicates multisampled, used with an
OpTypeImage having Sampled == 2 and Arrayed == 1.
```

Adding this logic to the capability trimming pass.
2023-09-05 18:36:03 +00:00
Nathan Gauër
1f07f483ef
opt: add raytracing/rayquery to trim pass (#5397)
Adds the RayTracingKHR and RayQueryKHR capabilities to
the supported capabilities list (this includes the linked extension).
(NV and KHR capabilities/extensions shared the same IDs, so it also
works for NV flavors of those).
2023-09-05 14:36:14 +00:00
Nathan Gauër
1121c23198
opt: add Int64 capability to trim pass (#5398)
Adds support for Int64 capability trimming.
2023-09-05 09:47:46 -04:00
Nathan Gauër
3cc7e1c4c3
NFC: rename tests using capability as prefix (#5396) 2023-09-04 14:32:28 -07:00
Cassandra Beckley
4c16c35b16
opt: add FragmentShader*InterlockEXT to capability trim pass (#5390)
* opt: add FragmentShader*InterlockEXT to capability trim pass

* move to addInstructionRequirementsForOpcode
2023-09-04 11:27:56 +02:00
Nathan Gauër
0f17d05c48
opt: add bitmask support for capability trimming (#5372)
Some operands are not simple values, but bitmasks.
The lookup in the table for required decomposing the mask into
single values.
This commit adds support for such operands, like MinLod|Offset.
2023-08-15 09:50:57 -04:00
Nathan Gauër
8714d7fad2
enable StorageUniform16 (#5371)
Adds support for the StorageUniform16 capability.
2023-08-10 13:54:31 -04:00
Nathan Gauër
4788ff1578
opt: add StorageUniformBufferBlock16 to trim pass (#5367)
Add StorageUniformBufferBlock16 to the list of enabled capabilities.
2023-08-10 14:21:35 +00:00
Nathan Gauër
ebda56e352
opt: add StoragePushConstant16 to trim pass (#5366)
* opt: add StoragePushConstant16 to trim pass

* fix comment
2023-08-10 12:34:46 +00:00
Nathan Gauër
60e684fe71
opt: fix StorageInputOutput16 trimming. (#5359)
* opt: fix StorageInputOutput16 trimming.

While integrating this pass into DXC, I found a lot of missing
cases. This PR fixes a few issues centered around this capability
while laying out fondations for more fixes.

1. The grammar can define extensions in operand & opcode tables.
   - opcode can rely on common capabilities, but require a new
     extension.
   - opcode can also rely on a capability which requires an extension.
   Sometimes, the extension is listed twice, in the opcode, and
   capability. But this redundancy is not guaranteed.

2. minVersion check. The condition was flipped: we added the extension
   when the minVersion was less than current.
   Didn't noticed the issue as I only tests on the default env.

3. Capability/Extension instructions were not ignored.
   - `OpCapability Foo` will require the `Foo` capability.
   - it doesn't mean the module requires the `Foo` capability.
   Same for extensions.

This commit adds disabled tests, for fixes which are too large to
be brought into this already large PR.
2023-08-09 06:30:23 -04:00
Nathan Gauër
35d8b05de4
opt: add capability trimming pass (not default). (#5278)
This commit adds a new optimization which tries to remove unnecessary
capabilities from a SPIR-V module.

When compiling a SPIR-V module, you may have some dead-code using
features gated by a capability.
DCE will remove this code, but the capability will remain. This means
your module would still require some capability, even if it doesn't
require it. Calling this pass on your module would remove obsolete
capabilities.

This pass wouldn't be enabled by default, and would only be usable
from the API (at least for now).

NOTE: this commit only adds the basic skeleton/structure, and
doesn't mark as supported many capabilities it could support.
I'll add them as supported as I write tests.

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-07-25 16:52:41 +02:00