org.lwjgl.vulkan.KHRFragmentShadingRate 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.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.JNI.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* This extension adds the ability to change the rate at which fragments are shaded. Rather than the usual single fragment invocation for each pixel covered by a primitive, multiple pixels can be shaded by a single fragment shader invocation.
*
* Up to three methods are available to the application to change the fragment shading rate:
*
*
* - Pipeline Fragment Shading Rate, which allows the specification of a rate per-draw.
* - Primitive Fragment Shading Rate, which allows the specification of a rate per primitive, specified during shading.
* - Attachment Fragment Shading Rate, which allows the specification of a rate per-region of the framebuffer, specified in a specialized image attachment.
*
*
* Additionally, these rates can all be specified and combined in order to adjust the overall detail in the image at each point.
*
* This functionality can be used to focus shading efforts where higher levels of detail are needed in some parts of a scene compared to others. This can be particularly useful in high resolution rendering, or for XR contexts.
*
* This extension also adds support for the {@code SPV_KHR_fragment_shading_rate} extension which enables setting the primitive fragment shading rate, and allows querying the final shading rate from a fragment shader.
*
* VK_KHR_fragment_shading_rate
*
*
* - Name String
* - {@code VK_KHR_fragment_shading_rate}
* - Extension Type
* - Device extension
* - Registered Extension Number
* - 227
* - Revision
* - 2
* - Extension and Version Dependencies
*
* - Requires Vulkan 1.0
* - Requires {@link KHRCreateRenderpass2 VK_KHR_create_renderpass2}
* - Requires {@link KHRGetPhysicalDeviceProperties2 VK_KHR_get_physical_device_properties2}
*
* - Contact
*
* - Tobias Hector tobski
*
*
*
* Other Extension Metadata
*
*
* - Last Modified Date
* - 2021-09-30
* - Interactions and External Dependencies
*
* - This extension requires {@code SPV_KHR_fragment_shading_rate}.
*
* - Contributors
*
* - Tobias Hector, AMD
* - Guennadi Riguer, AMD
* - Matthaeus Chajdas, AMD
* - Pat Brown, Nvidia
* - Matthew Netsch, Qualcomm
* - Slawomir Grajewski, Intel
* - Jan-Harald Fredriksen, Arm
* - Jeff Bolz, Nvidia
* - Contributors to the VK_NV_shading_rate_image specification
* - Contributors to the VK_EXT_fragment_density_map specification
*
*
*/
public class KHRFragmentShadingRate {
/** The extension specification version. */
public static final int VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION = 2;
/** The extension name. */
public static final String VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME = "VK_KHR_fragment_shading_rate";
/** Extends {@code VkImageLayout}. */
public static final int VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003;
/** Extends {@code VkDynamicState}. */
public static final int VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR = 1000226000;
/**
* Extends {@code VkStructureType}.
*
* Enum values:
*
*
* - {@link #VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR}
* - {@link #VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR}
* - {@link #VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR}
* - {@link #VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR}
* - {@link #VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR}
*
*/
public static final int
VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000226000,
VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR = 1000226001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR = 1000226002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR = 1000226003,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR = 1000226004;
/** Extends {@code VkAccessFlagBits}. */
public static final int VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR = 0x800000;
/** Extends {@code VkImageUsageFlagBits}. */
public static final int VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x100;
/** Extends {@code VkPipelineStageFlagBits}. */
public static final int VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x400000;
/** Extends {@code VkFormatFeatureFlagBits}. */
public static final int VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000;
/** Extends {@code VkFormatFeatureFlagBits2KHR}. */
public static final long VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000L;
/**
* VkFragmentShadingRateCombinerOpKHR - Control how fragment shading rates are combined
*
* Description
*
*
* - {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR} specifies a combiner operation of
combine(Axy,Bxy) = Axy
.
* - {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR} specifies a combiner operation of
combine(Axy,Bxy) = Bxy
.
* - {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR} specifies a combiner operation of
combine(Axy,Bxy) = min(Axy,Bxy)
.
* - {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR} specifies a combiner operation of
combine(Axy,Bxy) = max(Axy,Bxy)
.
* - {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR} specifies a combiner operation of
combine(Axy,Bxy) = Axy*Bxy
.
*
*
* where combine(Axy,Bxy)
is the combine operation, and Axy
and Bxy
are the inputs to the operation.
*
* If {@code fragmentShadingRateStrictMultiplyCombiner} is {@link VK10#VK_FALSE FALSE}, using {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR} with values of 1 for both A and B in the same dimension results in the value 2 being produced for that dimension. See the definition of {@code fragmentShadingRateStrictMultiplyCombiner} for more information.
*
* These operations are performed in a component-wise fashion.
*
* See Also
*
* {@link VkPipelineFragmentShadingRateEnumStateCreateInfoNV}, {@link VkPipelineFragmentShadingRateStateCreateInfoKHR}, {@link NVFragmentShadingRateEnums#vkCmdSetFragmentShadingRateEnumNV CmdSetFragmentShadingRateEnumNV}, {@link #vkCmdSetFragmentShadingRateKHR CmdSetFragmentShadingRateKHR}
*/
public static final int
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR = 0,
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR = 1,
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR = 2,
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR = 3,
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR = 4;
protected KHRFragmentShadingRate() {
throw new UnsupportedOperationException();
}
// --- [ vkGetPhysicalDeviceFragmentShadingRatesKHR ] ---
/**
* Unsafe version of: {@link #vkGetPhysicalDeviceFragmentShadingRatesKHR GetPhysicalDeviceFragmentShadingRatesKHR}
*
* @param pFragmentShadingRateCount a pointer to an integer related to the number of fragment shading rates available or queried, as described below.
*/
public static int nvkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, long pFragmentShadingRateCount, long pFragmentShadingRates) {
long __functionAddress = physicalDevice.getCapabilities().vkGetPhysicalDeviceFragmentShadingRatesKHR;
if (CHECKS) {
check(__functionAddress);
}
return callPPPI(physicalDevice.address(), pFragmentShadingRateCount, pFragmentShadingRates, __functionAddress);
}
/**
* Get available shading rates for a physical device.
*
* C Specification
*
* To query available shading rates, call:
*
*
* VkResult vkGetPhysicalDeviceFragmentShadingRatesKHR(
* VkPhysicalDevice physicalDevice,
* uint32_t* pFragmentShadingRateCount,
* VkPhysicalDeviceFragmentShadingRateKHR* pFragmentShadingRates);
*
* Description
*
* If {@code pFragmentShadingRates} is {@code NULL}, then the number of fragment shading rates available is returned in {@code pFragmentShadingRateCount}. Otherwise, {@code pFragmentShadingRateCount} must point to a variable set by the user to the number of elements in the {@code pFragmentShadingRates} array, and on return the variable is overwritten with the number of structures actually written to {@code pFragmentShadingRates}. If {@code pFragmentShadingRateCount} is less than the number of fragment shading rates available, at most {@code pFragmentShadingRateCount} structures will be written, and {@link VK10#VK_INCOMPLETE INCOMPLETE} will be returned instead of {@link VK10#VK_SUCCESS SUCCESS}, to indicate that not all the available fragment shading rates were returned.
*
* The returned array of fragment shading rates must be ordered from largest {@code fragmentSize.width} value to smallest, and each set of fragment shading rates with the same {@code fragmentSize.width} value must be ordered from largest {@code fragmentSize.height} to smallest. Any two entries in the array must not have the same {@code fragmentSize} values.
*
* For any entry in the array, the following rules also apply:
*
*
* - The value of {@code fragmentSize.width} must be less than or equal to {@code maxFragmentSize.width}.
* - The value of {@code fragmentSize.width} must be greater than or equal to 1.
* - The value of {@code fragmentSize.width} must be a power-of-two.
* - The value of {@code fragmentSize.height} must be less than or equal to {@code maxFragmentSize.height}.
* - The value of {@code fragmentSize.height} must be greater than or equal to 1.
* - The value of {@code fragmentSize.height} must be a power-of-two.
* - The highest sample count in {@code sampleCounts} must be less than or equal to {@code maxFragmentShadingRateRasterizationSamples}.
* - The product of {@code fragmentSize.width}, {@code fragmentSize.height}, and the highest sample count in {@code sampleCounts} must be less than or equal to {@code maxFragmentShadingRateCoverageSamples}.
*
*
* Implementations must support at least the following shading rates:
*
*
* {@code sampleCounts} {@code fragmentSize}
*
* {@link VK10#VK_SAMPLE_COUNT_1_BIT SAMPLE_COUNT_1_BIT} | {@link VK10#VK_SAMPLE_COUNT_4_BIT SAMPLE_COUNT_4_BIT} {2,2}
* {@link VK10#VK_SAMPLE_COUNT_1_BIT SAMPLE_COUNT_1_BIT} | {@link VK10#VK_SAMPLE_COUNT_4_BIT SAMPLE_COUNT_4_BIT} {2,1}
* ~0 {1,1}
*
*
*
* If {@code framebufferColorSampleCounts}, includes {@link VK10#VK_SAMPLE_COUNT_2_BIT SAMPLE_COUNT_2_BIT}, the required rates must also include {@link VK10#VK_SAMPLE_COUNT_2_BIT SAMPLE_COUNT_2_BIT}.
*
* Note
*
* Including the {1,1} fragment size is done for completeness; it has no actual effect on the support of rendering without setting the fragment size. All sample counts and render pass transforms are supported for this rate.
*
*
* The returned set of fragment shading rates must be returned in the native (rotated) coordinate system. For rasterization using render pass {@code transform} not equal to {@link KHRSurface#VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR SURFACE_TRANSFORM_IDENTITY_BIT_KHR}, the application must transform the returned fragment shading rates into the current (unrotated) coordinate system to get the supported rates for that transform.
*
* Note
*
* For example, consider an implementation returning support for 4x2, but not 2x4 in the set of supported fragment shading rates. This means that for transforms {@link KHRSurface#VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR SURFACE_TRANSFORM_ROTATE_90_BIT_KHR} and {@link KHRSurface#VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR SURFACE_TRANSFORM_ROTATE_270_BIT_KHR}, 2x4 is a supported rate, but 4x2 is an unsupported rate.
*
*
* Valid Usage (Implicit)
*
*
* - {@code physicalDevice} must be a valid {@code VkPhysicalDevice} handle
* - {@code pFragmentShadingRateCount} must be a valid pointer to a {@code uint32_t} value
* - If the value referenced by {@code pFragmentShadingRateCount} is not 0, and {@code pFragmentShadingRates} is not {@code NULL}, {@code pFragmentShadingRates} must be a valid pointer to an array of {@code pFragmentShadingRateCount} {@link VkPhysicalDeviceFragmentShadingRateKHR} structures
*
*
* 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_OUT_OF_HOST_MEMORY ERROR_OUT_OF_HOST_MEMORY}
*
*
*
* See Also
*
* {@link VkPhysicalDeviceFragmentShadingRateKHR}
*
* @param physicalDevice the handle to the physical device whose properties will be queried.
* @param pFragmentShadingRateCount a pointer to an integer related to the number of fragment shading rates available or queried, as described below.
* @param pFragmentShadingRates either {@code NULL} or a pointer to an array of {@link VkPhysicalDeviceFragmentShadingRateKHR} structures.
*/
@NativeType("VkResult")
public static int vkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, @NativeType("uint32_t *") IntBuffer pFragmentShadingRateCount, @Nullable @NativeType("VkPhysicalDeviceFragmentShadingRateKHR *") VkPhysicalDeviceFragmentShadingRateKHR.Buffer pFragmentShadingRates) {
if (CHECKS) {
check(pFragmentShadingRateCount, 1);
checkSafe(pFragmentShadingRates, pFragmentShadingRateCount.get(pFragmentShadingRateCount.position()));
}
return nvkGetPhysicalDeviceFragmentShadingRatesKHR(physicalDevice, memAddress(pFragmentShadingRateCount), memAddressSafe(pFragmentShadingRates));
}
// --- [ vkCmdSetFragmentShadingRateKHR ] ---
/** Unsafe version of: {@link #vkCmdSetFragmentShadingRateKHR CmdSetFragmentShadingRateKHR} */
public static void nvkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, long pFragmentSize, long combinerOps) {
long __functionAddress = commandBuffer.getCapabilities().vkCmdSetFragmentShadingRateKHR;
if (CHECKS) {
check(__functionAddress);
}
callPPPV(commandBuffer.address(), pFragmentSize, combinerOps, __functionAddress);
}
/**
* Set pipeline fragment shading rate and combiner operation dynamically for a command buffer.
*
* C Specification
*
* To dynamically set the pipeline fragment shading rate and combiner operation, call:
*
*
* void vkCmdSetFragmentShadingRateKHR(
* VkCommandBuffer commandBuffer,
* const VkExtent2D* pFragmentSize,
* const VkFragmentShadingRateCombinerOpKHR combinerOps[2]);
*
* Description
*
* This command sets the pipeline fragment shading rate and combiner operation for subsequent drawing commands when the graphics pipeline is created with {@link #VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR} set in {@link VkPipelineDynamicStateCreateInfo}{@code ::pDynamicStates}. Otherwise, this state is specified by the {@link VkPipelineFragmentShadingRateStateCreateInfoKHR} values used to create the currently active pipeline.
*
* Valid Usage
*
*
* - If {@code pipelineFragmentShadingRate} is not enabled, {@code pFragmentSize→width} must be 1
* - If {@code pipelineFragmentShadingRate} is not enabled, {@code pFragmentSize→height} must be 1
* - One of {@code pipelineFragmentShadingRate}, {@code primitiveFragmentShadingRate}, or {@code attachmentFragmentShadingRate} must be enabled
* - If the {@code primitiveFragmentShadingRate} feature is not enabled, {@code combinerOps}[0] must be {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}
* - If the {@code attachmentFragmentShadingRate} feature is not enabled, {@code combinerOps}[1] must be {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}
* - If the {@code fragmentSizeNonTrivialCombinerOps} limit is not supported, elements of {@code combinerOps} must be either {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR} or {@link #VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR}
* - {@code pFragmentSize→width} must be greater than or equal to 1
* - {@code pFragmentSize→height} must be greater than or equal to 1
* - {@code pFragmentSize→width} must be a power-of-two value
* - {@code pFragmentSize→height} must be a power-of-two value
* - {@code pFragmentSize→width} must be less than or equal to 4
* - {@code pFragmentSize→height} must be less than or equal to 4
*
*
* Valid Usage (Implicit)
*
*
* - {@code commandBuffer} must be a valid {@code VkCommandBuffer} handle
* - {@code pFragmentSize} must be a valid pointer to a valid {@link VkExtent2D} structure
* - Any given element of {@code combinerOps} must be a valid {@code VkFragmentShadingRateCombinerOpKHR} value
* - {@code commandBuffer} must be in the recording state
* - The {@code VkCommandPool} that {@code commandBuffer} was allocated from must support graphics operations
*
*
* Host Synchronization
*
*
* - Host access to {@code commandBuffer} must be externally synchronized
* - Host access to the {@code VkCommandPool} that {@code commandBuffer} was allocated from must be externally synchronized
*
*
* Command Properties
*
*
* Command Buffer Levels Render Pass Scope Supported Queue Types
* Primary Secondary Both Graphics
*
*
* See Also
*
* {@link VkExtent2D}
*
* @param commandBuffer the command buffer into which the command will be recorded.
* @param pFragmentSize specifies the pipeline fragment shading rate for subsequent drawing commands.
* @param combinerOps specifies a {@code VkFragmentShadingRateCombinerOpKHR} determining how the pipeline, primitive, and attachment shading rates are combined for fragments generated by subsequent drawing commands.
*/
public static void vkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, @NativeType("VkExtent2D const *") VkExtent2D pFragmentSize, @NativeType("VkFragmentShadingRateCombinerOpKHR const *") IntBuffer combinerOps) {
if (CHECKS) {
check(combinerOps, 2);
}
nvkCmdSetFragmentShadingRateKHR(commandBuffer, pFragmentSize.address(), memAddress(combinerOps));
}
/** Array version of: {@link #vkGetPhysicalDeviceFragmentShadingRatesKHR GetPhysicalDeviceFragmentShadingRatesKHR} */
@NativeType("VkResult")
public static int vkGetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, @NativeType("uint32_t *") int[] pFragmentShadingRateCount, @Nullable @NativeType("VkPhysicalDeviceFragmentShadingRateKHR *") VkPhysicalDeviceFragmentShadingRateKHR.Buffer pFragmentShadingRates) {
long __functionAddress = physicalDevice.getCapabilities().vkGetPhysicalDeviceFragmentShadingRatesKHR;
if (CHECKS) {
check(__functionAddress);
check(pFragmentShadingRateCount, 1);
checkSafe(pFragmentShadingRates, pFragmentShadingRateCount[0]);
}
return callPPPI(physicalDevice.address(), pFragmentShadingRateCount, memAddressSafe(pFragmentShadingRates), __functionAddress);
}
/** Array version of: {@link #vkCmdSetFragmentShadingRateKHR CmdSetFragmentShadingRateKHR} */
public static void vkCmdSetFragmentShadingRateKHR(VkCommandBuffer commandBuffer, @NativeType("VkExtent2D const *") VkExtent2D pFragmentSize, @NativeType("VkFragmentShadingRateCombinerOpKHR const *") int[] combinerOps) {
long __functionAddress = commandBuffer.getCapabilities().vkCmdSetFragmentShadingRateKHR;
if (CHECKS) {
check(__functionAddress);
check(combinerOps, 2);
}
callPPPV(commandBuffer.address(), pFragmentSize.address(), combinerOps, __functionAddress);
}
}