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 Chapter - OpCopy* #27

Open
spencer-lunarg opened this issue Sep 6, 2024 · 1 comment
Open

Add Chapter - OpCopy* #27

spencer-lunarg opened this issue Sep 6, 2024 · 1 comment
Assignees

Comments

@spencer-lunarg
Copy link
Contributor

OpCopyObject/OpCopyLogical/OpCopyMemory

How are they used, can they be used anywhere, etc

@alan-baker
Copy link

OpCopyObject is meant to be largely usable anywhere with any object. It is essentially a value copy. It does not allow other validation rules to be side-stepped (e.g. image and sampler in same block as the OpSampledImage instruction). As an example, the SPIRV-Tools optimizer uses it when performing some peep hole optimizations to avoid updating def/use information.

OpCopyLogical is a variant of OpCopyObject specifically specifically designed to handle similar, but not identical aggregates (array or structure). It is especially useful in Vulkan SPIR-V when changing between two versions of the same aggregate that differ only in layout decorations. For example, when DXC loads an aggregate from a resource it will have layout decorations. It then copies it to a version without layout decorations. OpCopyLogical reduces the number of instructions necessary to perform this transform.

OpCopyMemory is actually a variant of memcpy from C. Instead of specifying a size in bytes (as in OpCopyMemorySized) though, the whole object is copied (via the pointee type). This operation operates directly on memory. It could be lowered to a series of OpLoad and OpStore instructions. Vulkan traditionally uses OpCopyMemory because it uses logical pointers.

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

No branches or pull requests

2 participants