org.lwjgl.vulkan.AMDShaderInfo Maven / Gradle / Ivy
Show all versions of lwjgl-vulkan Show documentation
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.vulkan;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* 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);
* }
*
*
* - Name String
* - {@code VK_AMD_shader_info}
* - Extension Type
* - Device extension
* - Registered Extension Number
* - 43
* - Revision
* - 1
* - Extension and Version Dependencies
*
* - Requires Vulkan 1.0
*
* - Contact
*
* - Jaakko Konttinen @jaakko
*
* - Last Modified Date
* - 2017-10-09
* - IP Status
* - No known IP claims.
* - Contributors
*
* - Jaakko Konttinen, AMD
*
*
*/
public class AMDShaderInfo {
/** The extension specification version. */
public static final int VK_AMD_SHADER_INFO_SPEC_VERSION = 1;
/** The extension name. */
public static final String VK_AMD_SHADER_INFO_EXTENSION_NAME = "VK_AMD_shader_info";
/**
* VkShaderInfoTypeAMD
*
* Enum values:
*
*
* - {@link #VK_SHADER_INFO_TYPE_STATISTICS_AMD SHADER_INFO_TYPE_STATISTICS_AMD}
* - {@link #VK_SHADER_INFO_TYPE_BINARY_AMD SHADER_INFO_TYPE_BINARY_AMD}
* - {@link #VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD SHADER_INFO_TYPE_DISASSEMBLY_AMD}
*
*/
public static final int
VK_SHADER_INFO_TYPE_STATISTICS_AMD = 0,
VK_SHADER_INFO_TYPE_BINARY_AMD = 1,
VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD = 2;
protected AMDShaderInfo() {
throw new UnsupportedOperationException();
}
static boolean isAvailable(VKCapabilitiesDevice caps) {
return checkFunctions(
caps.vkGetShaderInfoAMD
);
}
// --- [ vkGetShaderInfoAMD ] ---
/**
* Unsafe version of: {@link #vkGetShaderInfoAMD GetShaderInfoAMD}
*
* @param pInfoSize a pointer to a value related to the amount of data the query returns, as described below.
*/
public static int nvkGetShaderInfoAMD(VkDevice device, long pipeline, int shaderStage, int infoType, long pInfoSize, long pInfo) {
long __functionAddress = device.getCapabilities().vkGetShaderInfoAMD;
if (CHECKS) {
check(__functionAddress);
}
return callPJPPI(__functionAddress, device.address(), pipeline, shaderStage, infoType, pInfoSize, 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 {@code pInfo} is {@code NULL}, then the maximum size of the information that can be retrieved about the shader, in bytes, is returned in {@code pInfoSize}. Otherwise, {@code pInfoSize} must point to a variable set by the user to the size of the buffer, in bytes, pointed to by {@code pInfo}, and on return the variable is overwritten with the amount of data actually written to {@code pInfo}.
*
* If {@code pInfoSize} is less than the maximum size that can be retrieved by the pipeline cache, then at most {@code pInfoSize} bytes will be written to {@code pInfo}, and {@link #vkGetShaderInfoAMD GetShaderInfoAMD} will return {@link VK10#VK_INCOMPLETE INCOMPLETE}.
*
* 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 {@link VK10#VK_ERROR_FEATURE_NOT_PRESENT ERROR_FEATURE_NOT_PRESENT}.
*
* If information is successfully and fully queried, the function will return {@link VK10#VK_SUCCESS SUCCESS}.
*
* For {@link #VK_SHADER_INFO_TYPE_STATISTICS_AMD SHADER_INFO_TYPE_STATISTICS_AMD}, an instance of {@link VkShaderStatisticsInfoAMD} will be written to the buffer pointed to by {@code 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 {@link #VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD SHADER_INFO_TYPE_DISASSEMBLY_AMD}, {@code pInfo} points 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 {@link #VK_SHADER_INFO_TYPE_BINARY_AMD SHADER_INFO_TYPE_BINARY_AMD}, are left to the vendor and are not further specified by this extension.
*
* Valid Usage (Implicit)
*
*
* - {@code device} must be a valid {@code VkDevice} handle
* - {@code pipeline} must be a valid {@code VkPipeline} handle
* - {@code shaderStage} must be a valid {@code VkShaderStageFlagBits} value
* - {@code infoType} must be a valid {@code VkShaderInfoTypeAMD} value
* - {@code pInfoSize} must be a valid pointer to a {@code size_t} value
* - If the value referenced by {@code pInfoSize} is not 0, and {@code pInfo} is not {@code NULL}, {@code pInfo} must be a valid pointer to an array of {@code pInfoSize} bytes
* - {@code pipeline} must have been created, allocated, or retrieved from {@code device}
*
*
* Return Codes
*
*
* - On success, this command returns
*
* - {@link VK10#VK_SUCCESS SUCCESS}
* - {@link VK10#VK_INCOMPLETE INCOMPLETE}
*
* - On failure, this command returns
*
* - {@link VK10#VK_ERROR_FEATURE_NOT_PRESENT ERROR_FEATURE_NOT_PRESENT}
* - {@link VK10#VK_ERROR_OUT_OF_HOST_MEMORY ERROR_OUT_OF_HOST_MEMORY}
*
*
*
* @param device the device that created {@code pipeline}.
* @param pipeline the target of the query.
* @param shaderStage identifies the particular shader within the pipeline about which information is being queried.
* @param infoType describes what kind of information is being queried.
* @param pInfoSize a pointer to a value related to the amount of data the query returns, as described below.
* @param pInfo either NULL or a pointer to a buffer.
*/
@NativeType("VkResult")
public static int vkGetShaderInfoAMD(VkDevice device, @NativeType("VkPipeline") long pipeline, @NativeType("VkShaderStageFlagBits") int shaderStage, @NativeType("VkShaderInfoTypeAMD") int infoType, @NativeType("size_t *") PointerBuffer pInfoSize, @Nullable @NativeType("void *") ByteBuffer pInfo) {
if (CHECKS) {
check(pInfoSize, 1);
checkSafe(pInfo, pInfoSize.get(pInfoSize.position()));
}
return nvkGetShaderInfoAMD(device, pipeline, shaderStage, infoType, memAddress(pInfoSize), memAddressSafe(pInfo));
}
}