• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include::meta/VK_AMD_shader_info.txt[]
2
3*Last Modified Date*::
4    2017-10-09
5*IP Status*::
6    No known IP claims.
7*Contributors*::
8  - Jaakko Konttinen, AMD
9
10This extension adds a way to query certain information about a compiled
11shader which is part of a pipeline.
12This information may include shader disassembly, shader binary and various
13statistics about a shader's resource usage.
14
15While this extension provides a mechanism for extracting this information,
16the details regarding the contents or format of this information are not
17specified by this extension and may be provided by the vendor externally.
18
19Furthermore, all information types are optionally supported, and users
20should not assume every implementation supports querying every type of
21information.
22
23=== New Object Types
24
25None.
26
27=== New Enum Constants
28
29None.
30
31=== New Enums
32
33  * elink:VkShaderInfoTypeAMD
34
35=== New Structures
36
37  * slink:VkShaderStatisticsInfoAMD
38
39=== New Functions
40
41  * flink:vkGetShaderInfoAMD
42
43=== Examples
44
45This example extracts the register usage of a fragment shader within a
46particular graphics pipeline:
47
48[source,c++]
49----------------------------------------
50extern VkDevice device;
51extern VkPipeline gfxPipeline;
52
53PFN_vkGetShaderInfoAMD pfnGetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)vkGetDeviceProcAddr(
54    device, "vkGetShaderInfoAMD");
55
56VkShaderStatisticsInfoAMD statistics = {};
57
58size_t dataSize = sizeof(statistics);
59
60if (pfnGetShaderInfoAMD(device,
61    gfxPipeline,
62    VK_SHADER_STAGE_FRAGMENT_BIT,
63    VK_SHADER_INFO_TYPE_STATISTICS_AMD,
64    &dataSize,
65    &statistics) == VK_SUCCESS)
66{
67    printf("VGPR usage: %d\n", statistics.resourceUsage.numUsedVgprs);
68    printf("SGPR usage: %d\n", statistics.resourceUsage.numUsedSgprs);
69}
70----------------------------------------
71
72The following example continues the previous example by subsequently
73attempting to query and print shader disassembly about the fragment shader:
74
75[source,c++]
76----------------------------------------
77// Query disassembly size (if available)
78if (pfnGetShaderInfoAMD(device,
79    gfxPipeline,
80    VK_SHADER_STAGE_FRAGMENT_BIT,
81    VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD,
82    &dataSize,
83    nullptr) == VK_SUCCESS)
84{
85    printf("Fragment shader disassembly:\n");
86
87    void* disassembly = malloc(dataSize);
88
89    // Query disassembly and print
90    if (pfnGetShaderInfoAMD(device,
91        gfxPipeline,
92        VK_SHADER_STAGE_FRAGMENT_BIT,
93        VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD,
94        &dataSize,
95        disassembly) == VK_SUCCESS)
96    {
97        printf((char*)disassembly);
98    }
99
100    free(disassembly);
101}
102----------------------------------------
103
104
105=== Version History
106
107  * Revision 1, 2017-10-09 (Jaakko Konttinen)
108    - Initial revision
109