-
Notifications
You must be signed in to change notification settings - Fork 69
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
XGL cache creator tool #64
Comments
This might not be so easy. PAL makes use of the internal pipeline cache hash, and they expect it to be 64-bits. Changing that would be a big change. |
Can you modify amdllpc to output the 128 bit hash in addition to the elf? Then the input to xgl_cache_creator would be a set of 128 bit hash and elf pairs. Not really tied to this proposal but it is a bit concerning that we have two different mechanisms for calculating a hash that is stored in the same cache. I'm not sure if this is going to cause issues. I think the refactoring you mention should be fine. Are you planning to keep the code in the same files they are now or put them in a separate file to minimize what needs to be compiled into xgl_cache_creator? |
If you are thinking of amdllpc output two separate files then I would not like that idea. I want to the hash to somehow be included in the elf file so that less book keeping needs to be down both other tools. However, I am will to do that if that is what you want. My preference would be to do something like add a new section to the elf that contains the hash, or a new pal metadata entry. The elf section would partially do what you want, "minimize what needs to be compiled into xlg_cache_creator", because the tool won't need to read the pal metadata.
I would like a separate file, but I'm not too concerned about that. |
You can have a section of the elf that PAL ignores. GetGenericSection() and SetGenericSection() are the functions to do that in PAL. |
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See GPUOpen-Drivers#64 for more details on the high-level direction.
This refactoring in preparation to be able to use PipelineBinaryCache in an offline tool, without having to run with a Vulkan device installed. See #64 for more details on the high-level direction.
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------|
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------|
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------|
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` V1: Remove dependency of `util`, `llpc` from `lgc` to fix build failure. V2: Fix typo "PiplineHashCode" -> "PipelineHashCode".
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a seperate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new ".note" section and its section header for cache hash: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| ==> |-------------| | Section | | Section | | headers | | headers | | ... | | ... | |-------------| |-------------| | Sections | | New section | | ... |---| | header for | |-------------| | | hash note | This new section header's | | section +|--| offset must be the new Remaining | |-------------| | note section for cache hash sections after | | New note | | section header | | section for |<-/ table must be | | cache hash | shifted | |-------------| \--->| Sections | | ... | |-------------| ``` The new note section for the cache hash will contain two note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), the new note section will be ``` .note (size = 80 bytes) Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
When LLPC checks shader and pipeline caches, it uses the hash for the identifier to check if required ELF files exist in the cache file. Since the cache file keeps the mapping between the hashes and the ELF files, we do not keep the hash value in the ELF file. On the other hand, we need the cache creator proposed in GPUOpen-Drivers/xgl#64 to build the cache for relocatable shader ELFs, but the cache creator does not have any information about the hash. It is because the hash is generated by LLPC (or amdllpc) and the cache creator is a separate program. We want to let the LLPC compiler create a new note section for the cache hash. It can be used for the cache creator to create the cache file with the correct mapping between the hash and ELF. ELF layouts before/after adding new note entries for cache hash and LLPC version to the existing note section: ``` |-------------| |-------------| | ELF header | | ELF header | |-------------| |-------------| | Sections | | Sections | | ... | | ... | |-------------| |-------------| | Note section| ==> | Note section| | ... | | | |-------------|<--(Will be | + New note | | ... | Shifted) | entries | |-------------| | | | ... | | Section | | \->|-------------| | headers | V | ... | | ... | |-------------| | Section | | headers | | ... | ``` New note entries: 1. Note name with "llpc_cache_hash" and note description with the cache hash used for the cache lookup. 2. Note name with "llpc_version" and note description with the LLPC version - both major and minor. The LLPC version information will help us to understand the hash generation algorithm. We have to use a correct hash algorithm for the cache lookup. For example, if the hash is "4EDBED25 ADF15238 B8C92579 423DA423" and the LLPC version is 45.4 (the major version is 45=0x2D and the minor version is 4=0x04), two new note entries will be ``` Unknown(0) (name = llpc_cache_hash size = 16) 0:4EDBED25 ADF15238 B8C92579 423DA423 Unknown(0) (name = llpc_version size = 8) 0:0000002D 00000004 ```
Background
There has been a lot of work in LLPC over the past 9 months to implement relocatable shaders. These were intended to provide a way to compile shaders “offline”, that is without running a vulkan application. However for that to be useful, there must be a way for a vulkan application to make use of the precompiled shaders.
To this end, we want to write a tool that will take the precompiled shaders and build a file whose contents can be passed as the initial data to
vkCreatePipelineCache
. This tool should live in the XGL repository because XGL controls the format of the cache when it is serialized byvkGetPipelineCacheData
.This will be a standalone tool that will have its own subdirectory in the tools directory.
Implementation details
Prerequisites
amdllpc
to compile shaders and get an elf file.XGL cache creator
Command line interface
Algorithm
vkGetPipelineCacheData
Task list
llpc_cache_hash
contianing the 128-bit hash for the ELF file being generated.PhysicalDevice::InitializePlatformKey
so:PhysicalDevice
.CalculateHashId
:pInstance
parameter with the allocation and deallocation functions, so that anInstance
is not needed.vkGetPipelineCacheData
code that writes the header into a function (WriteVkCacheHeader
?) the cache creator tool can call.InitializePlatformKey
,CalculateHashId
, andWriteVkCacheHeader
.ElfReader
to read the elf and extract the PAL metadata.MsgPackReader
to read the PAL metadata to get the hash.The text was updated successfully, but these errors were encountered: