v3d,v3dv: move tile size calculation to a common helper
We had this code replicated in 3 places across both drivers. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13790>
This commit is contained in:

committed by
Marge Bot

parent
a9c4e0c371
commit
f384c763fc
@@ -86,3 +86,35 @@ v3d_csd_choose_workgroups_per_supergroup(struct v3d_device_info *devinfo,
|
|||||||
|
|
||||||
return best_wgs_per_sg;
|
return best_wgs_per_sg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3d_choose_tile_size(uint32_t color_attachment_count,
|
||||||
|
uint32_t max_color_bpp, bool msaa,
|
||||||
|
uint32_t *width, uint32_t *height)
|
||||||
|
{
|
||||||
|
static const uint8_t tile_sizes[] = {
|
||||||
|
64, 64,
|
||||||
|
64, 32,
|
||||||
|
32, 32,
|
||||||
|
32, 16,
|
||||||
|
16, 16,
|
||||||
|
16, 8,
|
||||||
|
8, 8
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t idx = 0;
|
||||||
|
if (color_attachment_count > 2)
|
||||||
|
idx += 2;
|
||||||
|
else if (color_attachment_count > 1)
|
||||||
|
idx += 1;
|
||||||
|
|
||||||
|
if (msaa)
|
||||||
|
idx += 2;
|
||||||
|
|
||||||
|
idx += max_color_bpp;
|
||||||
|
|
||||||
|
assert(idx < ARRAY_SIZE(tile_sizes) / 2);
|
||||||
|
|
||||||
|
*width = tile_sizes[idx * 2];
|
||||||
|
*height = tile_sizes[idx * 2 + 1];
|
||||||
|
}
|
||||||
|
@@ -34,4 +34,9 @@ v3d_csd_choose_workgroups_per_supergroup(struct v3d_device_info *devinfo,
|
|||||||
uint32_t num_wgs,
|
uint32_t num_wgs,
|
||||||
uint32_t wg_size);
|
uint32_t wg_size);
|
||||||
|
|
||||||
|
void
|
||||||
|
v3d_choose_tile_size(uint32_t color_attachment_count,
|
||||||
|
uint32_t max_color_bpp, bool msaa,
|
||||||
|
uint32_t *width, uint32_t *height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -432,16 +432,6 @@ job_compute_frame_tiling(struct v3dv_job *job,
|
|||||||
uint8_t max_internal_bpp,
|
uint8_t max_internal_bpp,
|
||||||
bool msaa)
|
bool msaa)
|
||||||
{
|
{
|
||||||
static const uint8_t tile_sizes[] = {
|
|
||||||
64, 64,
|
|
||||||
64, 32,
|
|
||||||
32, 32,
|
|
||||||
32, 16,
|
|
||||||
16, 16,
|
|
||||||
16, 8,
|
|
||||||
8, 8
|
|
||||||
};
|
|
||||||
|
|
||||||
assert(job);
|
assert(job);
|
||||||
struct v3dv_frame_tiling *tiling = &job->frame_tiling;
|
struct v3dv_frame_tiling *tiling = &job->frame_tiling;
|
||||||
|
|
||||||
@@ -450,23 +440,10 @@ job_compute_frame_tiling(struct v3dv_job *job,
|
|||||||
tiling->layers = layers;
|
tiling->layers = layers;
|
||||||
tiling->render_target_count = render_target_count;
|
tiling->render_target_count = render_target_count;
|
||||||
tiling->msaa = msaa;
|
tiling->msaa = msaa;
|
||||||
|
|
||||||
uint32_t tile_size_index = 0;
|
|
||||||
|
|
||||||
if (render_target_count > 2)
|
|
||||||
tile_size_index += 2;
|
|
||||||
else if (render_target_count > 1)
|
|
||||||
tile_size_index += 1;
|
|
||||||
|
|
||||||
if (msaa)
|
|
||||||
tile_size_index += 2;
|
|
||||||
|
|
||||||
tiling->internal_bpp = max_internal_bpp;
|
tiling->internal_bpp = max_internal_bpp;
|
||||||
tile_size_index += tiling->internal_bpp;
|
|
||||||
assert(tile_size_index < ARRAY_SIZE(tile_sizes) / 2);
|
|
||||||
|
|
||||||
tiling->tile_width = tile_sizes[tile_size_index * 2];
|
v3d_choose_tile_size(render_target_count, max_internal_bpp, msaa,
|
||||||
tiling->tile_height = tile_sizes[tile_size_index * 2 + 1];
|
&tiling->tile_width, &tiling->tile_height);
|
||||||
|
|
||||||
tiling->draw_tiles_x = DIV_ROUND_UP(width, tiling->tile_width);
|
tiling->draw_tiles_x = DIV_ROUND_UP(width, tiling->tile_width);
|
||||||
tiling->draw_tiles_y = DIV_ROUND_UP(height, tiling->tile_height);
|
tiling->draw_tiles_y = DIV_ROUND_UP(height, tiling->tile_height);
|
||||||
|
@@ -285,25 +285,13 @@ subpass_get_granularity(struct v3dv_device *device,
|
|||||||
uint32_t subpass_idx,
|
uint32_t subpass_idx,
|
||||||
VkExtent2D *granularity)
|
VkExtent2D *granularity)
|
||||||
{
|
{
|
||||||
static const uint8_t tile_sizes[] = {
|
/* Granularity is defined by the tile size */
|
||||||
64, 64,
|
|
||||||
64, 32,
|
|
||||||
32, 32,
|
|
||||||
32, 16,
|
|
||||||
16, 16,
|
|
||||||
16, 8,
|
|
||||||
8, 8
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Our tile size depends on the number of color attachments and the maximum
|
|
||||||
* bpp across them.
|
|
||||||
*/
|
|
||||||
assert(subpass_idx < pass->subpass_count);
|
assert(subpass_idx < pass->subpass_count);
|
||||||
struct v3dv_subpass *subpass = &pass->subpasses[subpass_idx];
|
struct v3dv_subpass *subpass = &pass->subpasses[subpass_idx];
|
||||||
const uint32_t color_attachment_count = subpass->color_count;
|
const uint32_t color_attachment_count = subpass->color_count;
|
||||||
|
|
||||||
bool msaa = false;
|
bool msaa = false;
|
||||||
uint32_t max_internal_bpp = 0;
|
uint32_t max_bpp = 0;
|
||||||
for (uint32_t i = 0; i < color_attachment_count; i++) {
|
for (uint32_t i = 0; i < color_attachment_count; i++) {
|
||||||
uint32_t attachment_idx = subpass->color_attachments[i].attachment;
|
uint32_t attachment_idx = subpass->color_attachments[i].attachment;
|
||||||
if (attachment_idx == VK_ATTACHMENT_UNUSED)
|
if (attachment_idx == VK_ATTACHMENT_UNUSED)
|
||||||
@@ -315,27 +303,17 @@ subpass_get_granularity(struct v3dv_device *device,
|
|||||||
v3dv_X(device, get_internal_type_bpp_for_output_format)
|
v3dv_X(device, get_internal_type_bpp_for_output_format)
|
||||||
(format->rt_type, &internal_type, &internal_bpp);
|
(format->rt_type, &internal_type, &internal_bpp);
|
||||||
|
|
||||||
max_internal_bpp = MAX2(max_internal_bpp, internal_bpp);
|
max_bpp = MAX2(max_bpp, internal_bpp);
|
||||||
|
|
||||||
if (desc->samples > VK_SAMPLE_COUNT_1_BIT)
|
if (desc->samples > VK_SAMPLE_COUNT_1_BIT)
|
||||||
msaa = true;
|
msaa = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t idx = 0;
|
uint32_t width, height;
|
||||||
if (color_attachment_count > 2)
|
v3d_choose_tile_size(color_attachment_count, max_bpp, msaa, &width, &height);
|
||||||
idx += 2;
|
|
||||||
else if (color_attachment_count > 1)
|
|
||||||
idx += 1;
|
|
||||||
|
|
||||||
if (msaa)
|
|
||||||
idx += 2;
|
|
||||||
|
|
||||||
idx += max_internal_bpp;
|
|
||||||
|
|
||||||
assert(idx < ARRAY_SIZE(tile_sizes));
|
|
||||||
*granularity = (VkExtent2D) {
|
*granularity = (VkExtent2D) {
|
||||||
.width = tile_sizes[idx * 2],
|
.width = width,
|
||||||
.height = tile_sizes[idx * 2 + 1]
|
.height = height
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include "v3d_context.h"
|
#include "v3d_context.h"
|
||||||
#include "v3d_resource.h"
|
#include "v3d_resource.h"
|
||||||
#include "broadcom/compiler/v3d_compiler.h"
|
#include "broadcom/compiler/v3d_compiler.h"
|
||||||
|
#include "broadcom/common/v3d_util.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
v3d_flush(struct pipe_context *pctx)
|
v3d_flush(struct pipe_context *pctx)
|
||||||
@@ -248,27 +249,13 @@ v3d_get_tile_buffer_size(bool is_msaa,
|
|||||||
uint32_t *tile_height,
|
uint32_t *tile_height,
|
||||||
uint32_t *max_bpp)
|
uint32_t *max_bpp)
|
||||||
{
|
{
|
||||||
static const uint8_t tile_sizes[] = {
|
uint32_t max_cbuf_idx = 0;
|
||||||
64, 64,
|
|
||||||
64, 32,
|
|
||||||
32, 32,
|
|
||||||
32, 16,
|
|
||||||
16, 16,
|
|
||||||
};
|
|
||||||
int tile_size_index = 0;
|
|
||||||
if (is_msaa)
|
|
||||||
tile_size_index += 2;
|
|
||||||
|
|
||||||
if (cbufs[3] || cbufs[2])
|
|
||||||
tile_size_index += 2;
|
|
||||||
else if (cbufs[1])
|
|
||||||
tile_size_index++;
|
|
||||||
|
|
||||||
*max_bpp = 0;
|
*max_bpp = 0;
|
||||||
for (int i = 0; i < nr_cbufs; i++) {
|
for (int i = 0; i < nr_cbufs; i++) {
|
||||||
if (cbufs[i]) {
|
if (cbufs[i]) {
|
||||||
struct v3d_surface *surf = v3d_surface(cbufs[i]);
|
struct v3d_surface *surf = v3d_surface(cbufs[i]);
|
||||||
*max_bpp = MAX2(*max_bpp, surf->internal_bpp);
|
*max_bpp = MAX2(*max_bpp, surf->internal_bpp);
|
||||||
|
max_cbuf_idx = MAX2(i, max_cbuf_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,11 +265,8 @@ v3d_get_tile_buffer_size(bool is_msaa,
|
|||||||
*max_bpp = MAX2(*max_bpp, bsurf->internal_bpp);
|
*max_bpp = MAX2(*max_bpp, bsurf->internal_bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_size_index += *max_bpp;
|
v3d_choose_tile_size(max_cbuf_idx + 1, *max_bpp, is_msaa,
|
||||||
|
tile_width, tile_height);
|
||||||
assert(tile_size_index < ARRAY_SIZE(tile_sizes));
|
|
||||||
*tile_width = tile_sizes[tile_size_index * 2 + 0];
|
|
||||||
*tile_height = tile_sizes[tile_size_index * 2 + 1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user