1// Copyright (c) 2018-2020 NVIDIA Corporation 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[vertexpostproc-viewportwscaling]] 6== Controlling Viewport W Scaling 7 8If viewport *W* scaling is enabled, the *W* component of the clip coordinate 9is modified by the provided coefficients from the corresponding viewport as 10follows. 11 12 {empty}:: [eq]#w~c~' = x~coeff~ x~c~ {plus} y~coeff~ y~c~ {plus} w~c~# 13 14[open,refpage='VkPipelineViewportWScalingStateCreateInfoNV',desc='Structure specifying parameters of a newly created pipeline viewport W scaling state',type='structs'] 15-- 16The sname:VkPipelineViewportWScalingStateCreateInfoNV structure is defined 17as: 18 19include::{generated}/api/structs/VkPipelineViewportWScalingStateCreateInfoNV.adoc[] 20 21 * pname:sType is a elink:VkStructureType value identifying this structure. 22 * pname:pNext is `NULL` or a pointer to a structure extending this 23 structure. 24 * pname:viewportWScalingEnable controls whether viewport *W* scaling is 25 enabled. 26 * pname:viewportCount is the number of viewports used by *W* scaling, and 27 must: match the number of viewports in the pipeline if viewport *W* 28 scaling is enabled. 29 * pname:pViewportWScalings is a pointer to an array of 30 slink:VkViewportWScalingNV structures defining the *W* scaling 31 parameters for the corresponding viewports. 32 If the viewport *W* scaling state is dynamic, this member is ignored. 33 34include::{generated}/validity/structs/VkPipelineViewportWScalingStateCreateInfoNV.adoc[] 35-- 36 37The sname:VkPipelineViewportWScalingStateCreateInfoNV state is set by adding 38this structure to the pname:pNext chain of a 39sname:VkPipelineViewportStateCreateInfo structure and setting the graphics 40pipeline state with flink:vkCreateGraphicsPipelines. 41 42ifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 43 44[open,refpage='vkCmdSetViewportWScalingEnableNV',desc='Specify the viewport W scaling enable state dynamically for a command buffer',type='protos'] 45-- 46To <<pipelines-dynamic-state, dynamically set>> the 47pname:viewportWScalingEnable state, call: 48 49include::{generated}/api/protos/vkCmdSetViewportWScalingEnableNV.adoc[] 50 51 * pname:commandBuffer is the command buffer into which the command will be 52 recorded. 53 * pname:viewportWScalingEnable specifies the pname:viewportWScalingEnable 54 state. 55 56This command sets the pname:viewportWScalingEnable state for subsequent 57drawing commands 58ifdef::VK_EXT_shader_object[] 59ifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or] 60ifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.] 61endif::VK_EXT_shader_object[] 62ifdef::VK_EXT_extended_dynamic_state3[] 63when the graphics pipeline is created with 64ename:VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_ENABLE_NV set in 65slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 66endif::VK_EXT_extended_dynamic_state3[] 67Otherwise, this state is specified by the 68slink:VkPipelineViewportWScalingStateCreateInfoNV::pname:viewportWScalingEnable 69value used to create the currently active pipeline. 70 71:refpage: vkCmdSetViewportWScalingEnableNV 72:requiredfeature: extendedDynamicState3ViewportWScalingEnable 73 74.Valid Usage 75**** 76include::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[] 77**** 78 79include::{generated}/validity/protos/vkCmdSetViewportWScalingEnableNV.adoc[] 80-- 81 82endif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] 83 84[open,refpage='vkCmdSetViewportWScalingNV',desc='Set the viewport W scaling dynamically for a command buffer',type='protos'] 85-- 86To <<pipelines-dynamic-state, dynamically set>> the viewport *W* scaling 87parameters, call: 88 89include::{generated}/api/protos/vkCmdSetViewportWScalingNV.adoc[] 90 91 * pname:commandBuffer is the command buffer into which the command will be 92 recorded. 93 * pname:firstViewport is the index of the first viewport whose parameters 94 are updated by the command. 95 * pname:viewportCount is the number of viewports whose parameters are 96 updated by the command. 97 * pname:pViewportWScalings is a pointer to an array of 98 slink:VkViewportWScalingNV structures specifying viewport parameters. 99 100The viewport parameters taken from element [eq]#i# of 101pname:pViewportWScalings replace the current state for the viewport index 102[eq]#pname:firstViewport {plus} i#, for [eq]#i# in [eq]#[0, 103pname:viewportCount)#. 104 105This command sets the viewport *W* scaling for subsequent drawing commands 106ifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or] 107when the graphics pipeline is created with 108ename:VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV set in 109slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 110Otherwise, this state is specified by the 111slink:VkPipelineViewportWScalingStateCreateInfoNV::pname:pViewportWScalings 112values used to create the currently active pipeline. 113 114.Valid Usage 115**** 116 * [[VUID-vkCmdSetViewportWScalingNV-firstViewport-01324]] 117 The sum of pname:firstViewport and pname:viewportCount must: be between 118 `1` and slink:VkPhysicalDeviceLimits::pname:maxViewports, inclusive 119**** 120 121include::{generated}/validity/protos/vkCmdSetViewportWScalingNV.adoc[] 122-- 123 124Both slink:VkPipelineViewportWScalingStateCreateInfoNV and 125flink:vkCmdSetViewportWScalingNV use sname:VkViewportWScalingNV to set the 126viewport transformation parameters. 127 128[open,refpage='VkViewportWScalingNV',desc='Structure specifying a viewport',type='structs'] 129-- 130The sname:VkViewportWScalingNV structure is defined as: 131 132include::{generated}/api/structs/VkViewportWScalingNV.adoc[] 133 134 * pname:xcoeff and pname:ycoeff are the viewport's W scaling factor for x 135 and y respectively. 136 137include::{generated}/validity/structs/VkViewportWScalingNV.adoc[] 138-- 139