Class AMDShaderInfo
While this extension provides a mechanism for extracting this information, the details regarding the contents or format of this information are not specified by this extension and may be provided by the vendor externally.
Furthermore, all information types are optionally supported, and users should not assume every implementation supports querying every type of information.
Examples
This example extracts the register usage of a fragment shader within a particular graphics pipeline:
extern VkDevice device;
extern VkPipeline gfxPipeline;
PFN_vkGetShaderInfoAMD pfnGetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)vkGetDeviceProcAddr(
device, "vkGetShaderInfoAMD");
VkShaderStatisticsInfoAMD statistics = {};
size_t dataSize = sizeof(statistics);
if (pfnGetShaderInfoAMD(device,
gfxPipeline,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_INFO_TYPE_STATISTICS_AMD,
&dataSize,
&statistics) == VK_SUCCESS)
{
printf("VGPR usage: %d\n", statistics.resourceUsage.numUsedVgprs);
printf("SGPR usage: %d\n", statistics.resourceUsage.numUsedSgprs);
}
The following example continues the previous example by subsequently attempting to query and print shader disassembly about the fragment shader:
// Query disassembly size (if available)
if (pfnGetShaderInfoAMD(device,
gfxPipeline,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD,
&dataSize,
nullptr) == VK_SUCCESS)
{
printf("Fragment shader disassembly:\n");
void* disassembly = malloc(dataSize);
// Query disassembly and print
if (pfnGetShaderInfoAMD(device,
gfxPipeline,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD,
&dataSize,
disassembly) == VK_SUCCESS)
{
printf((char*)disassembly);
}
free(disassembly);
}
- Name String
VK_AMD_shader_info- Extension Type
- Device extension
- Registered Extension Number
- 43
- Revision
- 1
- Special Use
- Contact
- Jaakko Konttinen jaakkoamd
Other Extension Metadata
- Last Modified Date
- 2017-10-09
- IP Status
- No known IP claims.
- Contributors
- Jaakko Konttinen, AMD
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe extension name.static final intThe extension specification version.static final intVkShaderInfoTypeAMD - Enum specifying which type of shader information to querystatic final intVkShaderInfoTypeAMD - Enum specifying which type of shader information to querystatic final intVkShaderInfoTypeAMD - Enum specifying which type of shader information to query -
Method Summary
Modifier and TypeMethodDescriptionstatic intnvkGetShaderInfoAMD(org.lwjgl.vulkan.VkDevice device, long pipeline, int shaderStage, int infoType, long pInfoSize, long pInfo) Unsafe version of:GetShaderInfoAMDstatic intvkGetShaderInfoAMD(org.lwjgl.vulkan.VkDevice device, long pipeline, int shaderStage, int infoType, org.lwjgl.PointerBuffer pInfoSize, @Nullable ByteBuffer pInfo) Get information about a shader in a pipeline.
-
Field Details
-
VK_AMD_SHADER_INFO_SPEC_VERSION
public static final int VK_AMD_SHADER_INFO_SPEC_VERSIONThe extension specification version.- See Also:
-
VK_AMD_SHADER_INFO_EXTENSION_NAME
The extension name.- See Also:
-
VK_SHADER_INFO_TYPE_STATISTICS_AMD
public static final int VK_SHADER_INFO_TYPE_STATISTICS_AMDVkShaderInfoTypeAMD - Enum specifying which type of shader information to queryDescription
SHADER_INFO_TYPE_STATISTICS_AMDspecifies that device resources used by a shader will be queried.SHADER_INFO_TYPE_BINARY_AMDspecifies that implementation-specific information will be queried.SHADER_INFO_TYPE_DISASSEMBLY_AMDspecifies that human-readable disassembly of a shader.
See Also
- See Also:
-
VK_SHADER_INFO_TYPE_BINARY_AMD
public static final int VK_SHADER_INFO_TYPE_BINARY_AMDVkShaderInfoTypeAMD - Enum specifying which type of shader information to queryDescription
SHADER_INFO_TYPE_STATISTICS_AMDspecifies that device resources used by a shader will be queried.SHADER_INFO_TYPE_BINARY_AMDspecifies that implementation-specific information will be queried.SHADER_INFO_TYPE_DISASSEMBLY_AMDspecifies that human-readable disassembly of a shader.
See Also
- See Also:
-
VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD
public static final int VK_SHADER_INFO_TYPE_DISASSEMBLY_AMDVkShaderInfoTypeAMD - Enum specifying which type of shader information to queryDescription
SHADER_INFO_TYPE_STATISTICS_AMDspecifies that device resources used by a shader will be queried.SHADER_INFO_TYPE_BINARY_AMDspecifies that implementation-specific information will be queried.SHADER_INFO_TYPE_DISASSEMBLY_AMDspecifies that human-readable disassembly of a shader.
See Also
- See Also:
-
-
Method Details
-
nvkGetShaderInfoAMD
public static int nvkGetShaderInfoAMD(org.lwjgl.vulkan.VkDevice device, long pipeline, int shaderStage, int infoType, long pInfoSize, long pInfo) Unsafe version of:GetShaderInfoAMD- Parameters:
pInfoSize- a pointer to a value related to the amount of data the query returns, as described below.
-
vkGetShaderInfoAMD
public static int vkGetShaderInfoAMD(org.lwjgl.vulkan.VkDevice device, long pipeline, int shaderStage, int infoType, org.lwjgl.PointerBuffer pInfoSize, @Nullable ByteBuffer pInfo) Get information about a shader in a pipeline.C Specification
Information about a particular shader that has been compiled as part of a pipeline object can be extracted by calling:
VkResult vkGetShaderInfoAMD( VkDevice device, VkPipeline pipeline, VkShaderStageFlagBits shaderStage, VkShaderInfoTypeAMD infoType, size_t* pInfoSize, void* pInfo);Description
If
pInfoisNULL, then the maximum size of the information that can be retrieved about the shader, in bytes, is returned inpInfoSize. Otherwise,pInfoSizemust point to a variable set by the application to the size of the buffer, in bytes, pointed to bypInfo, and on return the variable is overwritten with the amount of data actually written topInfo. IfpInfoSizeis less than the maximum size that can be retrieved by the pipeline cache, then at mostpInfoSizebytes will be written topInfo, andINCOMPLETEwill be returned, instead ofSUCCESS, to indicate that not all required of the pipeline cache was returned.Not all information is available for every shader and implementations may not support all kinds of information for any shader. When a certain type of information is unavailable, the function returns
ERROR_FEATURE_NOT_PRESENT.If information is successfully and fully queried, the function will return
SUCCESS.For
infoTypeSHADER_INFO_TYPE_STATISTICS_AMD, aVkShaderStatisticsInfoAMDstructure will be written to the buffer pointed to bypInfo. This structure will be populated with statistics regarding the physical device resources used by that shader along with other miscellaneous information and is described in further detail below.For
infoTypeSHADER_INFO_TYPE_DISASSEMBLY_AMD,pInfois a pointer to a null-terminated UTF-8 string containing human-readable disassembly. The exact formatting and contents of the disassembly string are vendor-specific.The formatting and contents of all other types of information, including
infoTypeSHADER_INFO_TYPE_BINARY_AMD, are left to the vendor and are not further specified by this extension.Valid Usage (Implicit)
devicemust be a validVkDevicehandlepipelinemust be a validVkPipelinehandleshaderStagemust be a validVkShaderStageFlagBitsvalueinfoTypemust be a validVkShaderInfoTypeAMDvaluepInfoSizemust be a valid pointer to asize_tvalue- If the value referenced by
pInfoSizeis not 0, andpInfois notNULL,pInfomust be a valid pointer to an array ofpInfoSizebytes pipelinemust have been created, allocated, or retrieved fromdevice
Return Codes
- On success, this command returns
- On failure, this command returns
- Parameters:
device- the device that createdpipeline.pipeline- the target of the query.shaderStage- aVkShaderStageFlagBitsspecifying the particular shader within the pipeline about which information is being queried.infoType- describes what kind of information is being queried.pInfoSize- a pointer to a value related to the amount of data the query returns, as described below.pInfo- eitherNULLor a pointer to a buffer.
-