aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_cmd_buffer.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2020-06-30 10:38:11 +0200
committerMarge Bot <[email protected]>2020-07-13 08:31:54 +0000
commitac575f4215d7477bbfba13bae161dc9600586f4e (patch)
treee9279f60855ab0589c7e88ba8bdb3eecc40f3ade /src/amd/vulkan/radv_cmd_buffer.c
parent7324977e420260cea0627e3381a9f3ae4e62af0f (diff)
radv: rework dynamic viewports/scissors support
The number of viewports/scissors is currently static because it can only be specified at pipeline creation, but it doesn't hurt to assume it's dynamic. Will help for supporting setting the number of viewports/scissors dynamically. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5718>
Diffstat (limited to 'src/amd/vulkan/radv_cmd_buffer.c')
-rw-r--r--src/amd/vulkan/radv_cmd_buffer.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index fd8400e9b7e..723a94c8192 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -106,15 +106,11 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer,
uint32_t copy_mask = src->mask;
uint32_t dest_mask = 0;
- /* Make sure to copy the number of viewports/scissors because they can
- * only be specified at pipeline creation time.
- */
- dest->viewport.count = src->viewport.count;
- dest->scissor.count = src->scissor.count;
dest->discard_rectangle.count = src->discard_rectangle.count;
dest->sample_location.count = src->sample_location.count;
if (copy_mask & RADV_DYNAMIC_VIEWPORT) {
+ dest->viewport.count = src->viewport.count;
if (memcmp(&dest->viewport.viewports, &src->viewport.viewports,
src->viewport.count * sizeof(VkViewport))) {
typed_memcpy(dest->viewport.viewports,
@@ -125,6 +121,7 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer,
}
if (copy_mask & RADV_DYNAMIC_SCISSOR) {
+ dest->scissor.count = src->scissor.count;
if (memcmp(&dest->scissor.scissors, &src->scissor.scissors,
src->scissor.count * sizeof(VkRect2D))) {
typed_memcpy(dest->scissor.scissors,
@@ -3956,11 +3953,15 @@ void radv_CmdSetViewport(
assert(firstViewport < MAX_VIEWPORTS);
assert(total_count >= 1 && total_count <= MAX_VIEWPORTS);
- if (!memcmp(state->dynamic.viewport.viewports + firstViewport,
+ if (total_count <= state->dynamic.viewport.count &&
+ !memcmp(state->dynamic.viewport.viewports + firstViewport,
pViewports, viewportCount * sizeof(*pViewports))) {
return;
}
+ if (state->dynamic.viewport.count < total_count)
+ state->dynamic.viewport.count = total_count;
+
memcpy(state->dynamic.viewport.viewports + firstViewport, pViewports,
viewportCount * sizeof(*pViewports));
@@ -3980,11 +3981,15 @@ void radv_CmdSetScissor(
assert(firstScissor < MAX_SCISSORS);
assert(total_count >= 1 && total_count <= MAX_SCISSORS);
- if (!memcmp(state->dynamic.scissor.scissors + firstScissor, pScissors,
+ if (total_count <= state->dynamic.scissor.count &&
+ !memcmp(state->dynamic.scissor.scissors + firstScissor, pScissors,
scissorCount * sizeof(*pScissors))) {
return;
}
+ if (state->dynamic.scissor.count < total_count)
+ state->dynamic.scissor.count = total_count;
+
memcpy(state->dynamic.scissor.scissors + firstScissor, pScissors,
scissorCount * sizeof(*pScissors));