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

Add extension information to instructions #183

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

khyperia
Copy link
Collaborator

The spirv spec JSON has, for example, this information:

{
  "opname" : "OpDemoteToHelperInvocationEXT",
  "class"  : "Reserved",
  "opcode" : 5380,
  "capabilities" : [ "DemoteToHelperInvocationEXT" ],
  "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ],
  "version" : "None"
},
{
  "enumerant" : "DemoteToHelperInvocationEXT",
  "value" : 5379,
  "capabilities" : [ "Shader" ],
  "extensions" : [ "SPV_EXT_demote_to_helper_invocation" ],
  "version" : "None"
},

This exposes the extensions json field in both inst.class.extensions, as well as, for example, capability.required_extensions() (both those two types of JSON extension information). This is useful for various things in rust-gpu.

Pretty much just blindly copy-pasted the existing generation code for capability except swapped it out for strings instead. Handily, we don't ever have to allocate a String, through the magic of &'static str.

@Jasper-Bekkers
Copy link
Collaborator

Looks alright - just to sanity check required_extensions can return several extensions, for example

             | BuiltIn::IncomingRayFlagsNV => &["SPV_NV_ray_tracing", "SPV_KHR_ray_tracing"],

And so the result of this should be interpreted as "either SPV_NV_ray_tracing, or SPV_KHR_ray_tracing" (both wouldn't make sense).

@khyperia
Copy link
Collaborator Author

yeah, it's really unclear to me in the spec whether there's an AND or an OR in some of these places - does OpPtrDiff require Addresses AND VariablePointers, or OR? so I just did the same ambiguous confusion that's already there and just copied in the JSON data directly, haha.

@Jasper-Bekkers
Copy link
Collaborator

Jasper-Bekkers commented Jan 15, 2021

I think it's OR in that case as well though it's not or badly documented in SPIR-V or their respective extensions.

@khyperia khyperia merged commit 7111e6c into master Jan 15, 2021
@khyperia khyperia deleted the add-extension-information branch January 15, 2021 13:56
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

Successfully merging this pull request may close these issues.

2 participants