bug-14365: add dynamic state to PSO
This commit covers phase 2 of the removal of dynamic
state objects. Now, an application can include an array
of VK_DYNAMIC_STATE_* values that tell the driver
which PSO dynamic state elements to use.
I.e. if VK_DYNAMIC_STATE_LINE_WIDTH was specified in the
pDynamicState array then the ICD should use the lineWidth
defined at PSO create time and ignore any set using
vkCmdSetLineWidth.
To accomplish that the driver will make a copy of the
dynamic state specified in the PSO as well as a bitmask
of the affected state. When vkCmdSet* is called, the
driver will check if a PSO override is current and ignore
the call if so.
At PSO bind time the command buffer's dynamic state
will be updated and the PSO override bitmask set so that
any future vkCmdSet*'s will be appropriately ignored.
TODO: Validation layer should probably indicate a warning
if app tries to do vkCmdSet on state defined by the PSO.
diff --git a/icd/intel/cmd.h b/icd/intel/cmd.h
index 0ae97c8..3bcadea 100644
--- a/icd/intel/cmd.h
+++ b/icd/intel/cmd.h
@@ -124,6 +124,18 @@
INTEL_CMD_WRITER_COUNT,
};
+enum intel_use_pipeline_dynamic_state {
+ INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT = (1 << 0),
+ INTEL_USE_PIPELINE_DYNAMIC_SCISSOR = (1 << 1),
+ INTEL_USE_PIPELINE_DYNAMIC_LINE_WIDTH = (1 << 2),
+ INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BIAS = (1 << 3),
+ INTEL_USE_PIPELINE_DYNAMIC_BLEND_CONSTANTS = (1 << 4),
+ INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BOUNDS = (1 << 5),
+ INTEL_USE_PIPELINE_DYNAMIC_STENCIL_COMPARE_MASK = (1 << 6),
+ INTEL_USE_PIPELINE_DYNAMIC_STENCIL_WRITE_MASK = (1 << 7),
+ INTEL_USE_PIPELINE_DYNAMIC_STENCIL_REFERENCE = (1 << 8)
+};
+
struct intel_cmd_shader_cache {
struct {
const void *shader;
@@ -164,6 +176,7 @@
} pipeline;
struct {
+ VkFlags use_pipeline_dynamic_state;
struct intel_dynamic_viewport viewport;
struct intel_dynamic_line_width line_width;
struct intel_dynamic_depth_bias depth_bias;
diff --git a/icd/intel/cmd_pipeline.c b/icd/intel/cmd_pipeline.c
index 403f884..05ddd42 100644
--- a/icd/intel/cmd_pipeline.c
+++ b/icd/intel/cmd_pipeline.c
@@ -3328,11 +3328,62 @@
return true;
}
+static void cmd_bind_dynamic_state(struct intel_cmd *cmd,
+ const struct intel_pipeline *pipeline)
+
+{
+ VkFlags use_flags = pipeline->state.use_pipeline_dynamic_state;
+ if (!use_flags) {
+ return;
+ }
+ cmd->bind.state.use_pipeline_dynamic_state = use_flags;
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT) {
+ const struct intel_dynamic_viewport *viewport = &pipeline->state.viewport;
+ intel_set_viewport(cmd, viewport->viewport_count, viewport->viewports);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT) {
+ const struct intel_dynamic_viewport *viewport = &pipeline->state.viewport;
+ intel_set_scissor(cmd, viewport->viewport_count, viewport->scissors);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_LINE_WIDTH) {
+ intel_set_line_width(cmd, pipeline->state.line_width.line_width);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BIAS) {
+ const struct intel_dynamic_depth_bias *s = &pipeline->state.depth_bias;
+ intel_set_depth_bias(cmd, s->depth_bias, s->depth_bias_clamp, s->slope_scaled_depth_bias);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_BLEND_CONSTANTS) {
+ const struct intel_dynamic_blend *s = &pipeline->state.blend;
+ intel_set_blend_constants(cmd, s->blend_const);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BOUNDS) {
+ const struct intel_dynamic_depth_bounds *s = &pipeline->state.depth_bounds;
+ intel_set_depth_bounds(cmd, s->min_depth_bounds, s->max_depth_bounds);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_COMPARE_MASK) {
+ const struct intel_dynamic_stencil *s = &pipeline->state.stencil;
+ intel_set_stencil_compare_mask(cmd, VK_STENCIL_FACE_FRONT_BIT, s->front.stencil_compare_mask);
+ intel_set_stencil_compare_mask(cmd, VK_STENCIL_FACE_BACK_BIT, s->back.stencil_compare_mask);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_WRITE_MASK) {
+ const struct intel_dynamic_stencil *s = &pipeline->state.stencil;
+ intel_set_stencil_write_mask(cmd, VK_STENCIL_FACE_FRONT_BIT, s->front.stencil_write_mask);
+ intel_set_stencil_write_mask(cmd, VK_STENCIL_FACE_BACK_BIT, s->back.stencil_write_mask);
+ }
+ if (use_flags & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_REFERENCE) {
+ const struct intel_dynamic_stencil *s = &pipeline->state.stencil;
+ intel_set_stencil_reference(cmd, VK_STENCIL_FACE_FRONT_BIT, s->front.stencil_reference);
+ intel_set_stencil_reference(cmd, VK_STENCIL_FACE_BACK_BIT, s->back.stencil_reference);
+ }
+}
+
static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
const struct intel_pipeline *pipeline)
{
cmd->bind.pipeline.graphics = pipeline;
+ cmd_bind_dynamic_state(cmd, pipeline);
+
cmd_alloc_dset_data(cmd, &cmd->bind.dset.graphics_data,
pipeline->pipeline_layout);
}
diff --git a/icd/intel/pipeline.c b/icd/intel/pipeline.c
index 391feff..a265048 100644
--- a/icd/intel/pipeline.c
+++ b/icd/intel/pipeline.c
@@ -111,6 +111,7 @@
}
struct intel_pipeline_create_info {
+ VkFlags use_pipeline_dynamic_state;
VkGraphicsPipelineCreateInfo graphics;
VkPipelineVertexInputStateCreateInfo vi;
VkPipelineInputAssemblyStateCreateInfo ia;
@@ -1072,12 +1073,57 @@
}
+static void pipeline_build_state(struct intel_pipeline *pipeline,
+ const struct intel_pipeline_create_info *info)
+{
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT) {
+ pipeline->state.viewport.viewport_count = info->vp.viewportCount;
+ memcpy(pipeline->state.viewport.viewports, info->vp.pViewports, sizeof(info->vp.viewportCount) * sizeof(VkViewport));
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_SCISSOR) {
+ memcpy(pipeline->state.viewport.scissors, info->vp.pScissors, sizeof(info->vp.viewportCount) * sizeof(VkRect2D));
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_LINE_WIDTH) {
+ pipeline->state.line_width.line_width = info->rs.lineWidth;
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BIAS) {
+ pipeline->state.depth_bias.depth_bias = info->rs.depthBias;
+ pipeline->state.depth_bias.depth_bias_clamp = info->rs.depthBiasClamp;
+ pipeline->state.depth_bias.slope_scaled_depth_bias = info->rs.slopeScaledDepthBias;
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_BLEND_CONSTANTS) {
+ pipeline->state.blend.blend_const[0] = info->cb.blendConst[0];
+ pipeline->state.blend.blend_const[1] = info->cb.blendConst[1];
+ pipeline->state.blend.blend_const[2] = info->cb.blendConst[2];
+ pipeline->state.blend.blend_const[3] = info->cb.blendConst[3];
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BOUNDS) {
+ pipeline->state.depth_bounds.min_depth_bounds = info->db.minDepthBounds;
+ pipeline->state.depth_bounds.max_depth_bounds = info->db.maxDepthBounds;
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_COMPARE_MASK) {
+ pipeline->state.stencil.front.stencil_compare_mask = info->db.front.stencilCompareMask;
+ pipeline->state.stencil.back.stencil_compare_mask = info->db.back.stencilCompareMask;
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_WRITE_MASK) {
+
+ pipeline->state.stencil.front.stencil_write_mask = info->db.front.stencilWriteMask;
+ pipeline->state.stencil.back.stencil_write_mask = info->db.back.stencilWriteMask;
+ }
+ if (info->use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_REFERENCE) {
+ pipeline->state.stencil.front.stencil_reference = info->db.front.stencilReference;
+ pipeline->state.stencil.back.stencil_reference = info->db.back.stencilReference;
+ }
+}
+
static VkResult pipeline_build_all(struct intel_pipeline *pipeline,
- const struct intel_pipeline_create_info *info)
+ const struct intel_pipeline_create_info *info)
{
VkResult ret;
+ pipeline_build_state(pipeline, info);
+
ret = pipeline_build_shaders(pipeline, info);
if (ret != VK_SUCCESS)
return ret;
@@ -1202,8 +1248,42 @@
if (vkinfo->pViewportState != NULL) {
memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
}
- if (vkinfo->pViewportState != NULL) {
- memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
+
+ if (vkinfo->pDynamicState != NULL) {
+ for (uint32_t i = 0; i < vkinfo->pDynamicState->dynamicStateCount; i++) {
+ switch (vkinfo->pDynamicState->pDynamicStates[i]) {
+ case VK_DYNAMIC_STATE_VIEWPORT:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT;
+ break;
+ case VK_DYNAMIC_STATE_SCISSOR:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_SCISSOR;
+ break;
+ case VK_DYNAMIC_STATE_LINE_WIDTH:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_LINE_WIDTH;
+ break;
+ case VK_DYNAMIC_STATE_DEPTH_BIAS:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BIAS;
+ break;
+ case VK_DYNAMIC_STATE_BLEND_CONSTANTS:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_BLEND_CONSTANTS;
+ break;
+ case VK_DYNAMIC_STATE_DEPTH_BOUNDS:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BOUNDS;
+ break;
+ case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_STENCIL_COMPARE_MASK;
+ break;
+ case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_STENCIL_WRITE_MASK;
+ break;
+ case VK_DYNAMIC_STATE_STENCIL_REFERENCE:
+ info->use_pipeline_dynamic_state |= INTEL_USE_PIPELINE_DYNAMIC_STENCIL_REFERENCE;
+ break;
+ default:
+ assert(!"Invalid dynamic state");
+ break;
+ }
+ }
}
return VK_SUCCESS;
diff --git a/icd/intel/pipeline.h b/icd/intel/pipeline.h
index 3241434..22ec7eb 100644
--- a/icd/intel/pipeline.h
+++ b/icd/intel/pipeline.h
@@ -33,6 +33,7 @@
#include "obj.h"
#include "desc.h"
#include "dev.h"
+#include "state.h"
enum intel_pipeline_shader_use {
INTEL_SHADER_USE_VID = (1 << 0),
@@ -230,6 +231,18 @@
*/
// VkPipelineDsStateCreateInfo ds_state
bool stencilTestEnable;
+
+ /* Dynamic state specified at PSO create time */
+ struct {
+ VkFlags use_pipeline_dynamic_state;
+ struct intel_dynamic_viewport viewport;
+ struct intel_dynamic_line_width line_width;
+ struct intel_dynamic_depth_bias depth_bias;
+ struct intel_dynamic_blend blend;
+ struct intel_dynamic_depth_bounds depth_bounds;
+ struct intel_dynamic_stencil stencil;
+ } state;
+
uint32_t cmd_depth_stencil;
uint32_t cmd_depth_test;
diff --git a/icd/intel/state.c b/icd/intel/state.c
index a70f3f6..6e5f719 100644
--- a/icd/intel/state.c
+++ b/icd/intel/state.c
@@ -30,71 +30,49 @@
#include "state.h"
#include "cmd.h"
-
-
-ICD_EXPORT void VKAPI vkCmdSetViewport(
- VkCmdBuffer cmdBuffer,
- uint32_t viewportCount,
- const VkViewport* pViewports)
+void intel_set_viewport(struct intel_cmd *cmd, uint32_t count, const VkViewport *viewports)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
- cmd->bind.state.viewport.viewport_count = viewportCount;
- memcpy(cmd->bind.state.viewport.viewports, pViewports, viewportCount * sizeof(VkViewport));
+ cmd->bind.state.viewport.viewport_count = count;
+ memcpy(cmd->bind.state.viewport.viewports, viewports, count * sizeof(VkViewport));
}
-ICD_EXPORT void VKAPI vkCmdSetScissor(
- VkCmdBuffer cmdBuffer,
- uint32_t scissorCount,
- const VkRect2D* pScissors)
+void intel_set_scissor(struct intel_cmd *cmd, uint32_t count, const VkRect2D *scissors)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
- cmd->bind.state.viewport.viewport_count = scissorCount;
- memcpy(cmd->bind.state.viewport.scissors, pScissors, scissorCount * sizeof(VkRect2D));
+ cmd->bind.state.viewport.viewport_count = count;
+ memcpy(cmd->bind.state.viewport.scissors, scissors, count * sizeof(VkRect2D));
}
-ICD_EXPORT void VKAPI vkCmdSetLineWidth(
- VkCmdBuffer cmdBuffer,
- float line_width)
+void intel_set_line_width(struct intel_cmd *cmd, float line_width)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
cmd->bind.state.line_width.line_width = line_width;
}
-ICD_EXPORT void VKAPI vkCmdSetDepthBias(
- VkCmdBuffer cmdBuffer,
+void intel_set_depth_bias(
+ struct intel_cmd *cmd,
float depthBias,
float depthBiasClamp,
float slopeScaledDepthBias)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
cmd->bind.state.depth_bias.depth_bias = depthBias;
cmd->bind.state.depth_bias.depth_bias_clamp = depthBiasClamp;
cmd->bind.state.depth_bias.slope_scaled_depth_bias = slopeScaledDepthBias;
}
-ICD_EXPORT void VKAPI vkCmdSetBlendConstants(
- VkCmdBuffer cmdBuffer,
+void intel_set_blend_constants(
+ struct intel_cmd *cmd,
const float blendConst[4])
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
cmd->bind.state.blend.blend_const[0] = blendConst[0];
cmd->bind.state.blend.blend_const[1] = blendConst[1];
cmd->bind.state.blend.blend_const[2] = blendConst[2];
cmd->bind.state.blend.blend_const[3] = blendConst[3];
}
-ICD_EXPORT void VKAPI vkCmdSetDepthBounds(
- VkCmdBuffer cmdBuffer,
+void intel_set_depth_bounds(
+ struct intel_cmd *cmd,
float minDepthBounds,
float maxDepthBounds)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 359:
*
@@ -113,13 +91,11 @@
cmd->bind.state.depth_bounds.max_depth_bounds = maxDepthBounds;
}
-ICD_EXPORT void VKAPI vkCmdSetStencilCompareMask(
- VkCmdBuffer cmdBuffer,
+void intel_set_stencil_compare_mask(
+ struct intel_cmd *cmd,
VkStencilFaceFlags faceMask,
uint32_t stencilCompareMask)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
/* TODO: enable back facing stencil state */
/* Some plumbing needs to be done if we want to support info_back.
* In the meantime, catch that back facing info has been submitted. */
@@ -146,13 +122,11 @@
}
}
-ICD_EXPORT void VKAPI vkCmdSetStencilWriteMask(
- VkCmdBuffer cmdBuffer,
+void intel_set_stencil_write_mask(
+ struct intel_cmd *cmd,
VkStencilFaceFlags faceMask,
uint32_t stencilWriteMask)
{
- struct intel_cmd *cmd = intel_cmd(cmdBuffer);
-
if (faceMask & VK_STENCIL_FACE_FRONT_BIT) {
cmd->bind.state.stencil.front.stencil_write_mask = stencilWriteMask;
}
@@ -160,6 +134,131 @@
cmd->bind.state.stencil.back.stencil_write_mask = stencilWriteMask;
}
}
+
+void intel_set_stencil_reference(
+ struct intel_cmd *cmd,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilReference)
+{
+ if (faceMask & VK_STENCIL_FACE_FRONT_BIT) {
+ cmd->bind.state.stencil.front.stencil_reference = stencilReference;
+ }
+ if (faceMask & VK_STENCIL_FACE_BACK_BIT) {
+ cmd->bind.state.stencil.back.stencil_reference = stencilReference;
+ }
+}
+
+ICD_EXPORT void VKAPI vkCmdSetViewport(
+ VkCmdBuffer cmdBuffer,
+ uint32_t viewportCount,
+ const VkViewport* pViewports)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_VIEWPORT) {
+ return;
+ }
+
+ intel_set_viewport(cmd, viewportCount, pViewports);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetScissor(
+ VkCmdBuffer cmdBuffer,
+ uint32_t scissorCount,
+ const VkRect2D* pScissors)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_SCISSOR) {
+ return;
+ }
+
+ intel_set_scissor(cmd, scissorCount, pScissors);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetLineWidth(
+ VkCmdBuffer cmdBuffer,
+ float line_width)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_LINE_WIDTH) {
+ return;
+ }
+
+ cmd->bind.state.line_width.line_width = line_width;
+}
+
+ICD_EXPORT void VKAPI vkCmdSetDepthBias(
+ VkCmdBuffer cmdBuffer,
+ float depthBias,
+ float depthBiasClamp,
+ float slopeScaledDepthBias)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BIAS) {
+ return;
+ }
+
+ intel_set_depth_bias(cmd, depthBias, depthBiasClamp, slopeScaledDepthBias);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetBlendConstants(
+ VkCmdBuffer cmdBuffer,
+ const float blendConst[4])
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_BLEND_CONSTANTS) {
+ return;
+ }
+
+ intel_set_blend_constants(cmd, blendConst);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetDepthBounds(
+ VkCmdBuffer cmdBuffer,
+ float minDepthBounds,
+ float maxDepthBounds)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_DEPTH_BOUNDS) {
+ return;
+ }
+
+ intel_set_depth_bounds(cmd, minDepthBounds, maxDepthBounds);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetStencilCompareMask(
+ VkCmdBuffer cmdBuffer,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilCompareMask)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_COMPARE_MASK) {
+ return;
+ }
+
+ intel_set_stencil_compare_mask(cmd, faceMask, stencilCompareMask);
+}
+
+ICD_EXPORT void VKAPI vkCmdSetStencilWriteMask(
+ VkCmdBuffer cmdBuffer,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilWriteMask)
+{
+ struct intel_cmd *cmd = intel_cmd(cmdBuffer);
+
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_WRITE_MASK) {
+ return;
+ }
+
+ intel_set_stencil_write_mask(cmd, faceMask, stencilWriteMask);
+}
+
ICD_EXPORT void VKAPI vkCmdSetStencilReference(
VkCmdBuffer cmdBuffer,
VkStencilFaceFlags faceMask,
@@ -167,10 +266,9 @@
{
struct intel_cmd *cmd = intel_cmd(cmdBuffer);
- if (faceMask & VK_STENCIL_FACE_FRONT_BIT) {
- cmd->bind.state.stencil.front.stencil_reference = stencilReference;
+ if (cmd->bind.state.use_pipeline_dynamic_state & INTEL_USE_PIPELINE_DYNAMIC_STENCIL_REFERENCE) {
+ return;
}
- if (faceMask & VK_STENCIL_FACE_BACK_BIT) {
- cmd->bind.state.stencil.back.stencil_reference = stencilReference;
- }
+
+ intel_set_stencil_reference(cmd, faceMask, stencilReference);
}
diff --git a/icd/intel/state.h b/icd/intel/state.h
index bc4957a..85fd8b3 100644
--- a/icd/intel/state.h
+++ b/icd/intel/state.h
@@ -73,4 +73,34 @@
/* TODO: enable back facing stencil state */
struct intel_dynamic_stencil_face back;
};
+
+struct intel_cmd;
+void intel_set_viewport(struct intel_cmd *cmd, uint32_t count, const VkViewport *viewports);
+void intel_set_scissor(struct intel_cmd *cmd, uint32_t count, const VkRect2D *scissors);
+void intel_set_line_width(struct intel_cmd *cmd, float line_width);
+void intel_set_depth_bias(
+ struct intel_cmd *cmd,
+ float depthBias,
+ float depthBiasClamp,
+ float slopeScaledDepthBias);
+void intel_set_blend_constants(
+ struct intel_cmd *cmd,
+ const float blendConst[4]);
+void intel_set_depth_bounds(
+ struct intel_cmd *cmd,
+ float minDepthBounds,
+ float maxDepthBounds);
+void intel_set_stencil_compare_mask(
+ struct intel_cmd *cmd,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilCompareMask);
+void intel_set_stencil_write_mask(
+ struct intel_cmd *cmd,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilWriteMask);
+void intel_set_stencil_reference(
+ struct intel_cmd *cmd,
+ VkStencilFaceFlags faceMask,
+ uint32_t stencilReference);
+
#endif /* STATE_H */
diff --git a/include/vulkan.h b/include/vulkan.h
index 2a1e06d..8be2b4f 100644
--- a/include/vulkan.h
+++ b/include/vulkan.h
@@ -41,7 +41,7 @@
((major << 22) | (minor << 12) | patch)
// Vulkan API version supported by this file
-#define VK_API_VERSION VK_MAKE_VERSION(0, 170, 1)
+#define VK_API_VERSION VK_MAKE_VERSION(0, 170, 2)
#if defined(__cplusplus) && (_MSC_VER >= 1800 || __cplusplus >= 201103L)
@@ -206,9 +206,10 @@
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43,
VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO = 44,
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 45,
+ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 46,
VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO,
- VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
- VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1),
+ VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
+ VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1),
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType;
@@ -670,6 +671,22 @@
} VkBlendOp;
typedef enum {
+ VK_DYNAMIC_STATE_VIEWPORT = 0,
+ VK_DYNAMIC_STATE_SCISSOR = 1,
+ VK_DYNAMIC_STATE_LINE_WIDTH = 2,
+ VK_DYNAMIC_STATE_DEPTH_BIAS = 3,
+ VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
+ VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
+ VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
+ VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
+ VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
+ VK_DYNAMIC_STATE_BEGIN_RANGE = VK_DYNAMIC_STATE_VIEWPORT,
+ VK_DYNAMIC_STATE_END_RANGE = VK_DYNAMIC_STATE_STENCIL_REFERENCE,
+ VK_DYNAMIC_STATE_NUM = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1),
+ VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF
+} VkDynamicState;
+
+typedef enum {
VK_TEX_FILTER_NEAREST = 0,
VK_TEX_FILTER_LINEAR = 1,
VK_TEX_FILTER_BEGIN_RANGE = VK_TEX_FILTER_NEAREST,
@@ -1640,6 +1657,9 @@
VkStructureType sType;
const void* pNext;
uint32_t viewportCount;
+ const VkViewport* pViewports;
+ uint32_t scissorCount;
+ const VkRect2D* pScissors;
} VkPipelineViewportStateCreateInfo;
typedef struct {
@@ -1651,6 +1671,10 @@
VkCullMode cullMode;
VkFrontFace frontFace;
VkBool32 depthBiasEnable;
+ float depthBias;
+ float depthBiasClamp;
+ float slopeScaledDepthBias;
+ float lineWidth;
} VkPipelineRasterStateCreateInfo;
typedef struct {
@@ -1667,6 +1691,9 @@
VkStencilOp stencilPassOp;
VkStencilOp stencilDepthFailOp;
VkCompareOp stencilCompareOp;
+ uint32_t stencilCompareMask;
+ uint32_t stencilWriteMask;
+ uint32_t stencilReference;
} VkStencilOpState;
typedef struct {
@@ -1679,6 +1706,8 @@
VkBool32 stencilTestEnable;
VkStencilOpState front;
VkStencilOpState back;
+ float minDepthBounds;
+ float maxDepthBounds;
} VkPipelineDepthStencilStateCreateInfo;
typedef struct {
@@ -1701,11 +1730,19 @@
VkLogicOp logicOp;
uint32_t attachmentCount;
const VkPipelineColorBlendAttachmentState* pAttachments;
+ float blendConst[4];
} VkPipelineColorBlendStateCreateInfo;
typedef struct {
VkStructureType sType;
const void* pNext;
+ uint32_t dynamicStateCount;
+ const VkDynamicState* pDynamicStates;
+} VkPipelineDynamicStateCreateInfo;
+
+typedef struct {
+ VkStructureType sType;
+ const void* pNext;
uint32_t stageCount;
const VkPipelineShaderStageCreateInfo* pStages;
const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
@@ -1716,6 +1753,7 @@
const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
+ const VkPipelineDynamicStateCreateInfo* pDynamicState;
VkPipelineCreateFlags flags;
VkPipelineLayout layout;
VkRenderPass renderPass;
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index f6b6a6d..a0780fd 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -2332,7 +2332,12 @@
if (pCB->state == CB_UPDATE_ACTIVE) {
pCB->drawCount[DRAW]++;
skipCall |= validate_draw_state(pCB, VK_FALSE);
- /* TODO: Check that scissor and viewport counts are the same */
+ /* TODOVV: Check that scissor and viewport counts are the same */
+ /* TODOVV: Do we need to check that viewportCount given in pipeline's
+ * VkPipelineViewportStateCreateInfo matches scissor & viewport counts
+ * given as dynamic state? Or is the count given in VkPipelineViewportStateCreateInfo
+ * simply indicate the number of viewport / scissor to use at this time?
+ */
// TODO : Need to pass cmdBuffer as srcObj here
skipCall |= log_msg(mdd(cmdBuffer), VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS",
"vkCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++);