From: Jason Ekstrand Date: Mon, 30 Nov 2015 22:19:41 +0000 (-0800) Subject: vk/0.210.0: Rework dynamic states X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4ab9391fbb35e627f2033494f0440536bb3341a8;p=mesa.git vk/0.210.0: Rework dynamic states --- diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index c7a4ad1c387..d378598b0d3 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -1640,9 +1640,9 @@ typedef struct { VkCullModeFlags cullMode; VkFrontFace frontFace; VkBool32 depthBiasEnable; - float depthBias; + float depthBiasConstantFactor; float depthBiasClamp; - float slopeScaledDepthBias; + float depthBiasSlopeFactor; float lineWidth; } VkPipelineRasterStateCreateInfo; @@ -1655,14 +1655,14 @@ typedef struct { const VkSampleMask* pSampleMask; } VkPipelineMultisampleStateCreateInfo; -typedef struct { - VkStencilOp stencilFailOp; - VkStencilOp stencilPassOp; - VkStencilOp stencilDepthFailOp; - VkCompareOp stencilCompareOp; - uint32_t stencilCompareMask; - uint32_t stencilWriteMask; - uint32_t stencilReference; +typedef struct VkStencilOpState { + VkStencilOp failOp; + VkStencilOp passOp; + VkStencilOp depthFailOp; + VkCompareOp compareOp; + uint32_t compareMask; + uint32_t writeMask; + uint32_t reference; } VkStencilOpState; typedef struct { @@ -1699,7 +1699,7 @@ typedef struct { VkLogicOp logicOp; uint32_t attachmentCount; const VkPipelineColorBlendAttachmentState* pAttachments; - float blendConst[4]; + float blendConstants[4]; } VkPipelineColorBlendStateCreateInfo; typedef struct { @@ -2168,12 +2168,12 @@ typedef void (VKAPI_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, V typedef void (VKAPI_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t viewportCount, const VkViewport* pViewports); typedef void (VKAPI_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t scissorCount, const VkRect2D* pScissors); typedef void (VKAPI_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); -typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias); -typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConst[4]); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); +typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants[4]); typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); @@ -2722,13 +2722,13 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth( VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias( VkCommandBuffer commandBuffer, - float depthBias, + float depthBiasConstantFactor, float depthBiasClamp, - float slopeScaledDepthBias); + float depthBiasSlopeFactor); VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants( VkCommandBuffer commandBuffer, - const float blendConst[4]); + const float blendConstants[4]); VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds( VkCommandBuffer commandBuffer, @@ -2738,17 +2738,17 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds( VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilCompareMask); + uint32_t compareMask); VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilWriteMask); + uint32_t writeMask); VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilReference); + uint32_t reference); VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets( VkCommandBuffer commandBuffer, diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index f42f6fd5183..401fd5681f6 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -50,7 +50,7 @@ const struct anv_dynamic_state default_dynamic_state = { .depth_bias = { .bias = 0.0f, .clamp = 0.0f, - .slope_scaled = 0.0f, + .slope = 0.0f, }, .blend_constants = { 0.0f, 0.0f, 0.0f, 0.0f }, .depth_bounds = { @@ -380,27 +380,27 @@ void anv_CmdSetLineWidth( void anv_CmdSetDepthBias( VkCommandBuffer commandBuffer, - float depthBias, + float depthBiasConstantFactor, float depthBiasClamp, - float slopeScaledDepthBias) + float depthBiasSlopeFactor) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); - cmd_buffer->state.dynamic.depth_bias.bias = depthBias; + cmd_buffer->state.dynamic.depth_bias.bias = depthBiasConstantFactor; cmd_buffer->state.dynamic.depth_bias.clamp = depthBiasClamp; - cmd_buffer->state.dynamic.depth_bias.slope_scaled = slopeScaledDepthBias; + cmd_buffer->state.dynamic.depth_bias.slope = depthBiasSlopeFactor; cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS; } void anv_CmdSetBlendConstants( VkCommandBuffer commandBuffer, - const float blendConst[4]) + const float blendConstants[4]) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); memcpy(cmd_buffer->state.dynamic.blend_constants, - blendConst, sizeof(float) * 4); + blendConstants, sizeof(float) * 4); cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS; } @@ -421,14 +421,14 @@ void anv_CmdSetDepthBounds( void anv_CmdSetStencilCompareMask( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilCompareMask) + uint32_t compareMask) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); if (faceMask & VK_STENCIL_FACE_FRONT_BIT) - cmd_buffer->state.dynamic.stencil_compare_mask.front = stencilCompareMask; + cmd_buffer->state.dynamic.stencil_compare_mask.front = compareMask; if (faceMask & VK_STENCIL_FACE_BACK_BIT) - cmd_buffer->state.dynamic.stencil_compare_mask.back = stencilCompareMask; + cmd_buffer->state.dynamic.stencil_compare_mask.back = compareMask; cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK; } @@ -436,14 +436,14 @@ void anv_CmdSetStencilCompareMask( void anv_CmdSetStencilWriteMask( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilWriteMask) + uint32_t writeMask) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); if (faceMask & VK_STENCIL_FACE_FRONT_BIT) - cmd_buffer->state.dynamic.stencil_write_mask.front = stencilWriteMask; + cmd_buffer->state.dynamic.stencil_write_mask.front = writeMask; if (faceMask & VK_STENCIL_FACE_BACK_BIT) - cmd_buffer->state.dynamic.stencil_write_mask.back = stencilWriteMask; + cmd_buffer->state.dynamic.stencil_write_mask.back = writeMask; cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK; } @@ -451,14 +451,14 @@ void anv_CmdSetStencilWriteMask( void anv_CmdSetStencilReference( VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, - uint32_t stencilReference) + uint32_t reference) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); if (faceMask & VK_STENCIL_FACE_FRONT_BIT) - cmd_buffer->state.dynamic.stencil_reference.front = stencilReference; + cmd_buffer->state.dynamic.stencil_reference.front = reference; if (faceMask & VK_STENCIL_FACE_BACK_BIT) - cmd_buffer->state.dynamic.stencil_reference.back = stencilReference; + cmd_buffer->state.dynamic.stencil_reference.back = reference; cmd_buffer->state.dirty |= ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE; } diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c index bcdc9e4d5b4..a9bcbc3be9e 100644 --- a/src/vulkan/anv_meta_clear.c +++ b/src/vulkan/anv_meta_clear.c @@ -459,10 +459,10 @@ create_depthstencil_pipeline(struct anv_device *device, .depthBoundsTestEnable = false, .stencilTestEnable = (aspects & VK_IMAGE_ASPECT_STENCIL_BIT), .front = { - .stencilPassOp = VK_STENCIL_OP_REPLACE, - .stencilCompareOp = VK_COMPARE_OP_ALWAYS, - .stencilWriteMask = UINT32_MAX, - .stencilReference = 0, /* dynamic */ + .passOp = VK_STENCIL_OP_REPLACE, + .compareOp = VK_COMPARE_OP_ALWAYS, + .writeMask = UINT32_MAX, + .reference = 0, /* dynamic */ }, .back = { 0 /* dont care */ }, }; diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index 16d054665f5..e4209bd13c9 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -849,16 +849,17 @@ anv_pipeline_init_dynamic_state(struct anv_pipeline *pipeline, if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS)) { assert(pCreateInfo->pRasterState); - dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias; + dynamic->depth_bias.bias = + pCreateInfo->pRasterState->depthBiasConstantFactor; dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp; - dynamic->depth_bias.slope_scaled = - pCreateInfo->pRasterState->slopeScaledDepthBias; + dynamic->depth_bias.slope = + pCreateInfo->pRasterState->depthBiasSlopeFactor; } if (states & (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS)) { assert(pCreateInfo->pColorBlendState); typed_memcpy(dynamic->blend_constants, - pCreateInfo->pColorBlendState->blendConst, 4); + pCreateInfo->pColorBlendState->blendConstants, 4); } /* If there is no depthstencil attachment, then don't read @@ -884,25 +885,25 @@ anv_pipeline_init_dynamic_state(struct anv_pipeline *pipeline, if (states & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) { assert(pCreateInfo->pDepthStencilState); dynamic->stencil_compare_mask.front = - pCreateInfo->pDepthStencilState->front.stencilCompareMask; + pCreateInfo->pDepthStencilState->front.compareMask; dynamic->stencil_compare_mask.back = - pCreateInfo->pDepthStencilState->back.stencilCompareMask; + pCreateInfo->pDepthStencilState->back.compareMask; } if (states & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) { assert(pCreateInfo->pDepthStencilState); dynamic->stencil_write_mask.front = - pCreateInfo->pDepthStencilState->front.stencilWriteMask; + pCreateInfo->pDepthStencilState->front.writeMask; dynamic->stencil_write_mask.back = - pCreateInfo->pDepthStencilState->back.stencilWriteMask; + pCreateInfo->pDepthStencilState->back.writeMask; } if (states & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) { assert(pCreateInfo->pDepthStencilState); dynamic->stencil_reference.front = - pCreateInfo->pDepthStencilState->front.stencilReference; + pCreateInfo->pDepthStencilState->front.reference; dynamic->stencil_reference.back = - pCreateInfo->pDepthStencilState->back.stencilReference; + pCreateInfo->pDepthStencilState->back.reference; } } diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 0e148b36b1c..c86003f5823 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -917,7 +917,7 @@ struct anv_dynamic_state { struct { float bias; float clamp; - float slope_scaled; + float slope; } depth_bias; float blend_constants[4]; diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c index b69982d6e52..9a3d4799d62 100644 --- a/src/vulkan/gen7_cmd_buffer.c +++ b/src/vulkan/gen7_cmd_buffer.c @@ -409,7 +409,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS)) { bool enable_bias = cmd_buffer->state.dynamic.depth_bias.bias != 0.0f || - cmd_buffer->state.dynamic.depth_bias.slope_scaled != 0.0f; + cmd_buffer->state.dynamic.depth_bias.slope != 0.0f; uint32_t sf_dw[GEN7_3DSTATE_SF_length]; struct GEN7_3DSTATE_SF sf = { @@ -419,7 +419,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) .GlobalDepthOffsetEnableWireframe = enable_bias, .GlobalDepthOffsetEnablePoint = enable_bias, .GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, - .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope_scaled, + .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope, .GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp }; GEN7_3DSTATE_SF_pack(NULL, sf_dw, &sf); diff --git a/src/vulkan/gen7_pipeline.c b/src/vulkan/gen7_pipeline.c index 1ae4d26bcdd..2f51b4bfc73 100644 --- a/src/vulkan/gen7_pipeline.c +++ b/src/vulkan/gen7_pipeline.c @@ -231,15 +231,15 @@ gen7_emit_ds_state(struct anv_pipeline *pipeline, .DoubleSidedStencilEnable = true, .StencilTestEnable = info->stencilTestEnable, - .StencilFailOp = vk_to_gen_stencil_op[info->front.stencilFailOp], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[info->front.stencilPassOp], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[info->front.stencilDepthFailOp], - .StencilTestFunction = vk_to_gen_compare_op[info->front.stencilCompareOp], - - .BackfaceStencilFailOp = vk_to_gen_stencil_op[info->back.stencilFailOp], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[info->back.stencilPassOp], - .BackfaceStencilPassDepthFailOp = vk_to_gen_stencil_op[info->back.stencilDepthFailOp], - .BackFaceStencilTestFunction = vk_to_gen_compare_op[info->back.stencilCompareOp], + .StencilFailOp = vk_to_gen_stencil_op[info->front.failOp], + .StencilPassDepthPassOp = vk_to_gen_stencil_op[info->front.passOp], + .StencilPassDepthFailOp = vk_to_gen_stencil_op[info->front.depthFailOp], + .StencilTestFunction = vk_to_gen_compare_op[info->front.compareOp], + + .BackfaceStencilFailOp = vk_to_gen_stencil_op[info->back.failOp], + .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[info->back.passOp], + .BackfaceStencilPassDepthFailOp = vk_to_gen_stencil_op[info->back.depthFailOp], + .BackFaceStencilTestFunction = vk_to_gen_compare_op[info->back.compareOp], }; GEN7_DEPTH_STENCIL_STATE_pack(NULL, &pipeline->gen7.depth_stencil_state, &state); diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c index 88062a6f61b..b6523b5ecf5 100644 --- a/src/vulkan/gen8_cmd_buffer.c +++ b/src/vulkan/gen8_cmd_buffer.c @@ -231,7 +231,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) if (cmd_buffer->state.dirty & (ANV_CMD_DIRTY_PIPELINE | ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS)){ bool enable_bias = cmd_buffer->state.dynamic.depth_bias.bias != 0.0f || - cmd_buffer->state.dynamic.depth_bias.slope_scaled != 0.0f; + cmd_buffer->state.dynamic.depth_bias.slope != 0.0f; uint32_t raster_dw[GENX(3DSTATE_RASTER_length)]; struct GENX(3DSTATE_RASTER) raster = { @@ -240,7 +240,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) .GlobalDepthOffsetEnableWireframe = enable_bias, .GlobalDepthOffsetEnablePoint = enable_bias, .GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, - .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope_scaled, + .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope, .GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp }; GENX(3DSTATE_RASTER_pack)(NULL, raster_dw, &raster); diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index fb0373c1f7e..16143300cf1 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -313,14 +313,14 @@ emit_ds_state(struct anv_pipeline *pipeline, .DoubleSidedStencilEnable = true, .StencilTestEnable = info->stencilTestEnable, - .StencilFailOp = vk_to_gen_stencil_op[info->front.stencilFailOp], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[info->front.stencilPassOp], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[info->front.stencilDepthFailOp], - .StencilTestFunction = vk_to_gen_compare_op[info->front.stencilCompareOp], - .BackfaceStencilFailOp = vk_to_gen_stencil_op[info->back.stencilFailOp], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[info->back.stencilPassOp], - .BackfaceStencilPassDepthFailOp =vk_to_gen_stencil_op[info->back.stencilDepthFailOp], - .BackfaceStencilTestFunction = vk_to_gen_compare_op[info->back.stencilCompareOp], + .StencilFailOp = vk_to_gen_stencil_op[info->front.failOp], + .StencilPassDepthPassOp = vk_to_gen_stencil_op[info->front.passOp], + .StencilPassDepthFailOp = vk_to_gen_stencil_op[info->front.depthFailOp], + .StencilTestFunction = vk_to_gen_compare_op[info->front.compareOp], + .BackfaceStencilFailOp = vk_to_gen_stencil_op[info->back.failOp], + .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[info->back.passOp], + .BackfaceStencilPassDepthFailOp =vk_to_gen_stencil_op[info->back.depthFailOp], + .BackfaceStencilTestFunction = vk_to_gen_compare_op[info->back.compareOp], }; GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, dw, &wm_depth_stencil);