Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-mesa: 提交

external/mesa


Commit MetaInfo

修订版7662965ce96e2987a2356608f7c73ca8cf492dcd (tree)
时间2019-02-15 20:40:11
作者Juan A. Suarez Romero <jasuarez@igal...>
CommiterEmil Velikov

Log Message

anv/cmd_buffer: check for NULL framebuffer

This can happen when we record a VkCmdDraw in a secondary buffer that
was created inheriting from the primary buffer, but with the framebuffer
set to NULL in the VkCommandBufferInheritanceInfo.

Vulkan 1.1.81 spec says that "the application must ensure (using scissor
if neccesary) that all rendering is contained in the render area [...]
[which] must be contained within the framebuffer dimesions".

While this should be done by the application, commit 465e5a86 added the
clamp to the framebuffer size, in case of application does not do it.
But this requires to know the framebuffer dimensions.

If we do not have a framebuffer at that moment, the best compromise we
can do is to just apply the scissor as it is, and let the application to
ensure the rendering is contained in the render area.

v2: do not clamp to framebuffer if there isn't a framebuffer

v3 (Jason):
- clamp earlier in the conditional
- clamp to render area if command buffer is primary

v4: clamp also x and y to render area (Jason)

v5: rename used variables (Jason)

Fixes: 465e5a86 ("anv: Clamp scissors to the framebuffer boundary")
CC: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
(cherry picked from commit 1ad26f941792f07f226c054811be78b0c0ac9fce)

更改概述

差异

--- a/src/intel/vulkan/gen7_cmd_buffer.c
+++ b/src/intel/vulkan/gen7_cmd_buffer.c
@@ -70,12 +70,36 @@ gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
7070 };
7171
7272 const int max = 0xffff;
73+
74+ uint32_t y_min = s->offset.y;
75+ uint32_t x_min = s->offset.x;
76+ uint32_t y_max = s->offset.y + s->extent.height - 1;
77+ uint32_t x_max = s->offset.x + s->extent.width - 1;
78+
79+ /* Do this math using int64_t so overflow gets clamped correctly. */
80+ if (cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
81+ y_min = clamp_int64((uint64_t) y_min,
82+ cmd_buffer->state.render_area.offset.y, max);
83+ x_min = clamp_int64((uint64_t) x_min,
84+ cmd_buffer->state.render_area.offset.x, max);
85+ y_max = clamp_int64((uint64_t) y_max, 0,
86+ cmd_buffer->state.render_area.offset.y +
87+ cmd_buffer->state.render_area.extent.height - 1);
88+ x_max = clamp_int64((uint64_t) x_max, 0,
89+ cmd_buffer->state.render_area.offset.x +
90+ cmd_buffer->state.render_area.extent.width - 1);
91+ } else if (fb) {
92+ y_min = clamp_int64((uint64_t) y_min, 0, max);
93+ x_min = clamp_int64((uint64_t) x_min, 0, max);
94+ y_max = clamp_int64((uint64_t) y_max, 0, fb->height - 1);
95+ x_max = clamp_int64((uint64_t) x_max, 0, fb->width - 1);
96+ }
97+
7398 struct GEN7_SCISSOR_RECT scissor = {
74- /* Do this math using int64_t so overflow gets clamped correctly. */
75- .ScissorRectangleYMin = clamp_int64(s->offset.y, 0, max),
76- .ScissorRectangleXMin = clamp_int64(s->offset.x, 0, max),
77- .ScissorRectangleYMax = clamp_int64((uint64_t) s->offset.y + s->extent.height - 1, 0, fb->height - 1),
78- .ScissorRectangleXMax = clamp_int64((uint64_t) s->offset.x + s->extent.width - 1, 0, fb->width - 1)
99+ .ScissorRectangleYMin = y_min,
100+ .ScissorRectangleXMin = x_min,
101+ .ScissorRectangleYMax = y_max,
102+ .ScissorRectangleXMax = x_max
79103 };
80104
81105 if (s->extent.width <= 0 || s->extent.height <= 0) {
Show on old repository browser