Top Description Fields Constructors Methods
org.lwjgl.vulkan

public Class AMDShaderInfo

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.*, org.lwjgl.system.*

This extension adds a way to query certain information about a compiled shader which is part of a pipeline. This information may include shader disassembly, shader binary and various statistics about a shader’s resource usage.

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);
}
VK_AMD_shader_info
Name String
VK_AMD_shader_info
Extension Type
Device extension
Registered Extension Number
43
Revision
1
Special Use
Contact
Other Extension Metadata
Last Modified Date
2017-10-09
IP Status
No known IP claims.
Contributors
  • Jaakko Konttinen, AMD

Field Summary

Modifier and TypeField and Description
public static final String
public static final int
VK_AMD_SHADER_INFO_SPEC_VERSION

The extension specification version.

public static final int
VK_SHADER_INFO_TYPE_BINARY_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query Description

public static final int
VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query Description

public static final int
VK_SHADER_INFO_TYPE_STATISTICS_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query Description

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static int
nvkGetShaderInfoAMD(VkDevice device, long pipeline, int shaderStage, int infoType, long
a pointer to a value related to the amount of data the query returns, as described below.
pInfoSize
,
long pInfo)

Unsafe version of: GetShaderInfoAMD

public static int
vkGetShaderInfoAMD(VkDevice
the device that created pipeline.
device
,
long
the target of the query.
pipeline
,
int
a VkShaderStageFlagBits specifying the particular shader within the pipeline about which information is being queried.
shaderStage
,
int
describes what kind of information is being queried.
infoType
,
PointerBuffer
a pointer to a value related to the amount of data the query returns, as described below.
pInfoSize
,
ByteBuffer
either NULL or a pointer to a buffer.
pInfo
)

Get information about a shader in a pipeline.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

VK_AMD_SHADER_INFO_EXTENSION_NAMEback to summary
public static final String VK_AMD_SHADER_INFO_EXTENSION_NAME

The extension name.

VK_AMD_SHADER_INFO_SPEC_VERSIONback to summary
public static final int VK_AMD_SHADER_INFO_SPEC_VERSION

The extension specification version.

VK_SHADER_INFO_TYPE_BINARY_AMDback to summary
public static final int VK_SHADER_INFO_TYPE_BINARY_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query

Description
See Also

GetShaderInfoAMD

VK_SHADER_INFO_TYPE_DISASSEMBLY_AMDback to summary
public static final int VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query

Description
See Also

GetShaderInfoAMD

VK_SHADER_INFO_TYPE_STATISTICS_AMDback to summary
public static final int VK_SHADER_INFO_TYPE_STATISTICS_AMD

VkShaderInfoTypeAMD - Enum specifying which type of shader information to query

Description
See Also

GetShaderInfoAMD

Constructor Detail

AMDShaderInfoback to summary
protected AMDShaderInfo()

Method Detail

nvkGetShaderInfoAMDback to summary
public static int nvkGetShaderInfoAMD(VkDevice device, long pipeline, int shaderStage, int infoType, long pInfoSize, long pInfo)

Unsafe version of: GetShaderInfoAMD

Parameters
pInfoSize:long

a pointer to a value related to the amount of data the query returns, as described below.

vkGetShaderInfoAMDback to summary
public static int vkGetShaderInfoAMD(VkDevice device, long pipeline, int shaderStage, int infoType, PointerBuffer pInfoSize, 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 pInfo is NULL, then the maximum size of the information that can be retrieved about the shader, in bytes, is returned in pInfoSize. Otherwise, pInfoSize must point to a variable set by the user to the size of the buffer, in bytes, pointed to by pInfo, and on return the variable is overwritten with the amount of data actually written to pInfo. If pInfoSize is less than the maximum size that can be retrieved by the pipeline cache, then at most pInfoSize bytes will be written to pInfo, and INCOMPLETE will be returned, instead of SUCCESS, 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 infoType SHADER_INFO_TYPE_STATISTICS_AMD, a VkShaderStatisticsInfoAMD structure will be written to the buffer pointed to by pInfo. 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 infoType SHADER_INFO_TYPE_DISASSEMBLY_AMD, pInfo is a pointer to a UTF-8 null-terminated 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 infoType SHADER_INFO_TYPE_BINARY_AMD, are left to the vendor and are not further specified by this extension.

Valid Usage (Implicit)
  • device must be a valid VkDevice handle
  • pipeline must be a valid VkPipeline handle
  • shaderStage must be a valid VkShaderStageFlagBits value
  • infoType must be a valid VkShaderInfoTypeAMD value
  • pInfoSize must be a valid pointer to a size_t value
  • If the value referenced by pInfoSize is not 0, and pInfo is not NULL, pInfo must be a valid pointer to an array of pInfoSize bytes
  • pipeline must have been created, allocated, or retrieved from device
Return Codes
On success, this command returns
On failure, this command returns
Parameters
device:VkDevice

the device that created pipeline.

pipeline:long

the target of the query.

shaderStage:int

a VkShaderStageFlagBits specifying the particular shader within the pipeline about which information is being queried.

infoType:int

describes what kind of information is being queried.

pInfoSize:PointerBuffer

a pointer to a value related to the amount of data the query returns, as described below.

pInfo:ByteBuffer

either NULL or a pointer to a buffer.

Annotations
@NativeType:VkResult