v3dv: make TLB clearing paths return true/false

We are currently able to clear any supported format using the TLB, but
this is more consistent with other parts of the code and is what we want
should we add any formats in the future where we can't get away with
TLB clears.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2020-05-25 09:41:33 +02:00 committed by Marge Bot
parent a5cede6111
commit bbdfc5296b

View file

@ -1433,13 +1433,20 @@ get_hw_clear_color(const VkClearColorValue *color,
} }
} }
static void /* Returns true if the implementation is able to handle the case, false
* otherwise.
*/
static bool
clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer, clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
struct v3dv_image *image, struct v3dv_image *image,
VkFormat fb_format,
const VkClearValue *clear_value, const VkClearValue *clear_value,
const VkImageSubresourceRange *range) const VkImageSubresourceRange *range)
{ {
const VkOffset3D origin = { 0, 0, 0 };
VkFormat fb_format;
if (!can_use_tlb(image, &origin, &fb_format))
return false;
uint32_t internal_type, internal_bpp; uint32_t internal_type, internal_bpp;
get_internal_type_bpp_for_image_aspects(fb_format, range->aspectMask, get_internal_type_bpp_for_image_aspects(fb_format, range->aspectMask,
&internal_type, &internal_bpp); &internal_type, &internal_bpp);
@ -1486,7 +1493,7 @@ clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
struct v3dv_job *job = v3dv_cmd_buffer_start_job(cmd_buffer, -1); struct v3dv_job *job = v3dv_cmd_buffer_start_job(cmd_buffer, -1);
if (!job) if (!job)
return; return true;
/* We start a a new job for each layer so the frame "depth" is 1 */ /* We start a a new job for each layer so the frame "depth" is 1 */
v3dv_job_start_frame(job, width, height, 1, 1, internal_bpp); v3dv_job_start_frame(job, width, height, 1, 1, internal_bpp);
@ -1508,6 +1515,8 @@ clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
v3dv_cmd_buffer_finish_job(cmd_buffer); v3dv_cmd_buffer_finish_job(cmd_buffer);
} }
} }
return true;
} }
void void
@ -1525,15 +1534,10 @@ v3dv_CmdClearColorImage(VkCommandBuffer commandBuffer,
.color = *pColor, .color = *pColor,
}; };
VkFormat compat_format;
const VkOffset3D origin = { 0, 0, 0 };
for (uint32_t i = 0; i < rangeCount; i++) { for (uint32_t i = 0; i < rangeCount; i++) {
if (can_use_tlb(image, &origin, &compat_format)) { if (clear_image_tlb(cmd_buffer, image, &clear_value, &pRanges[i]))
clear_image_tlb(cmd_buffer, image, compat_format, continue;
&clear_value, &pRanges[i]); unreachable("Unsupported color clear.");
} else {
assert(!"Fallback path for vkCmdClearColorImage not implemented");
}
} }
} }
@ -1552,14 +1556,10 @@ v3dv_CmdClearDepthStencilImage(VkCommandBuffer commandBuffer,
.depthStencil = *pDepthStencil, .depthStencil = *pDepthStencil,
}; };
const VkOffset3D origin = { 0, 0, 0 };
for (uint32_t i = 0; i < rangeCount; i++) { for (uint32_t i = 0; i < rangeCount; i++) {
if (can_use_tlb(image, &origin, NULL)) { if (clear_image_tlb(cmd_buffer, image, &clear_value, &pRanges[i]))
clear_image_tlb(cmd_buffer, image, image->vk_format, continue;
&clear_value, &pRanges[i]); unreachable("Unsupported depth/stencil clear.");
} else {
assert(!"Fallback path for vkCmdClearDepthStencilImage not implemented");
}
} }
} }