v3dv: don't use cl_packet_length for prepacked data
cl_packet_length depends on the specific hw generation packets, so it is can't be included directly by main header. The straight forward solution would be to allocate them dynamically, based on the current generation. That ended to be complex and messy. Also, even if that change between hw versions, it will not change significantly. So we just add some definition with the size of the packets we prepack. We just need to be careful that this needs to be the maximum value considering all the versions supported. Note that on Opengl v3d does something similar, using hardcoded values, but without a define, neither a runtime check. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11310>
This commit is contained in:
parent
1bea0d76b8
commit
2e40f13f9a
|
@ -803,7 +803,7 @@ descriptor_set_create(struct v3dv_device *device,
|
|||
|
||||
memcpy(desc_map,
|
||||
samplers[i].sampler_state,
|
||||
cl_packet_length(SAMPLER_STATE));
|
||||
sizeof(samplers[i].sampler_state));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1676,6 +1676,9 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
v3dv_X(device, device_check_prepacked_sizes)();
|
||||
#endif
|
||||
init_device_meta(device);
|
||||
v3dv_bo_cache_init(device);
|
||||
v3dv_pipeline_cache_init(&device->default_pipeline_cache, device,
|
||||
|
|
|
@ -69,5 +69,4 @@
|
|||
#define PAGE_CACHE_UB_ROWS (V3D_PAGE_CACHE_SIZE / V3D_UIFBLOCK_ROW_SIZE)
|
||||
#define PAGE_CACHE_MINUS_1_5_UB_ROWS (PAGE_CACHE_UB_ROWS - PAGE_UB_ROWS_TIMES_1_5)
|
||||
|
||||
|
||||
#endif /* V3DV_LIMITS_H */
|
||||
|
|
|
@ -500,6 +500,19 @@ struct v3dv_image {
|
|||
|
||||
VkImageViewType v3dv_image_type_to_view_type(VkImageType type);
|
||||
|
||||
/* Pre-generating packets needs to consider changes in packet sizes across hw
|
||||
* versions. Keep things simple and allocate enough space for any supported
|
||||
* version. We ensure the size is large enough through static asserts.
|
||||
*/
|
||||
#define V3DV_TEXTURE_SHADER_STATE_LENGTH 32
|
||||
#define V3DV_SAMPLER_STATE_LENGTH 24
|
||||
#define V3DV_BLEND_CFG_LENGTH 5
|
||||
#define V3DV_CFG_BITS_LENGTH 4
|
||||
#define V3DV_GL_SHADER_STATE_RECORD_LENGTH 36
|
||||
#define V3DV_VCM_CACHE_SIZE_LENGTH 2
|
||||
#define V3DV_GL_SHADER_STATE_ATTRIBUTE_RECORD_LENGTH 16
|
||||
#define V3DV_STENCIL_CFG_LENGTH 6
|
||||
|
||||
struct v3dv_image_view {
|
||||
struct vk_object_base base;
|
||||
|
||||
|
@ -536,7 +549,7 @@ struct v3dv_image_view {
|
|||
* we generate two states and select the one to use based on the descriptor
|
||||
* type.
|
||||
*/
|
||||
uint8_t texture_shader_state[2][cl_packet_length(TEXTURE_SHADER_STATE)];
|
||||
uint8_t texture_shader_state[2][V3DV_TEXTURE_SHADER_STATE_LENGTH];
|
||||
};
|
||||
|
||||
uint32_t v3dv_layer_offset(const struct v3dv_image *image, uint32_t level, uint32_t layer);
|
||||
|
@ -567,7 +580,7 @@ struct v3dv_buffer_view {
|
|||
uint32_t num_elements;
|
||||
|
||||
/* Prepacked TEXTURE_SHADER_STATE. */
|
||||
uint8_t texture_shader_state[cl_packet_length(TEXTURE_SHADER_STATE)];
|
||||
uint8_t texture_shader_state[V3DV_TEXTURE_SHADER_STATE_LENGTH];
|
||||
};
|
||||
|
||||
struct v3dv_subpass_attachment {
|
||||
|
@ -1577,7 +1590,7 @@ struct v3dv_sampler {
|
|||
* configuration. If needed it will be copied to the descriptor info during
|
||||
* UpdateDescriptorSets
|
||||
*/
|
||||
uint8_t sampler_state[cl_packet_length(SAMPLER_STATE)];
|
||||
uint8_t sampler_state[V3DV_SAMPLER_STATE_LENGTH];
|
||||
};
|
||||
|
||||
struct v3dv_descriptor_template_entry {
|
||||
|
@ -1765,7 +1778,7 @@ struct v3dv_pipeline {
|
|||
/* Per-RT bit mask with blend enables */
|
||||
uint8_t enables;
|
||||
/* Per-RT prepacked blend config packets */
|
||||
uint8_t cfg[V3D_MAX_DRAW_BUFFERS][cl_packet_length(BLEND_CFG)];
|
||||
uint8_t cfg[V3D_MAX_DRAW_BUFFERS][V3DV_BLEND_CFG_LENGTH];
|
||||
/* Flag indicating whether the blend factors in use require
|
||||
* color constants.
|
||||
*/
|
||||
|
@ -1782,12 +1795,12 @@ struct v3dv_pipeline {
|
|||
|
||||
/* Packets prepacked during pipeline creation
|
||||
*/
|
||||
uint8_t cfg_bits[cl_packet_length(CFG_BITS)];
|
||||
uint8_t shader_state_record[cl_packet_length(GL_SHADER_STATE_RECORD)];
|
||||
uint8_t vcm_cache_size[cl_packet_length(VCM_CACHE_SIZE)];
|
||||
uint8_t vertex_attrs[cl_packet_length(GL_SHADER_STATE_ATTRIBUTE_RECORD) *
|
||||
uint8_t cfg_bits[V3DV_CFG_BITS_LENGTH];
|
||||
uint8_t shader_state_record[V3DV_GL_SHADER_STATE_RECORD_LENGTH];
|
||||
uint8_t vcm_cache_size[V3DV_VCM_CACHE_SIZE_LENGTH];
|
||||
uint8_t vertex_attrs[V3DV_GL_SHADER_STATE_ATTRIBUTE_RECORD_LENGTH *
|
||||
MAX_VERTEX_ATTRIBS];
|
||||
uint8_t stencil_cfg[2][cl_packet_length(STENCIL_CFG)];
|
||||
uint8_t stencil_cfg[2][V3DV_STENCIL_CFG_LENGTH];
|
||||
};
|
||||
|
||||
static inline VkPipelineBindPoint
|
||||
|
|
|
@ -235,3 +235,28 @@ v3dX(get_hw_clear_color)(const VkClearColorValue *color,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
v3dX(device_check_prepacked_sizes)(void)
|
||||
{
|
||||
STATIC_ASSERT(V3DV_SAMPLER_STATE_LENGTH >=
|
||||
cl_packet_length(SAMPLER_STATE));
|
||||
STATIC_ASSERT(V3DV_TEXTURE_SHADER_STATE_LENGTH >=
|
||||
cl_packet_length(TEXTURE_SHADER_STATE));
|
||||
STATIC_ASSERT(V3DV_SAMPLER_STATE_LENGTH >=
|
||||
cl_packet_length(SAMPLER_STATE));
|
||||
STATIC_ASSERT(V3DV_BLEND_CFG_LENGTH>=
|
||||
cl_packet_length(BLEND_CFG));
|
||||
STATIC_ASSERT(V3DV_CFG_BITS_LENGTH>=
|
||||
cl_packet_length(CFG_BITS));
|
||||
STATIC_ASSERT(V3DV_GL_SHADER_STATE_RECORD_LENGTH >=
|
||||
cl_packet_length(GL_SHADER_STATE_RECORD));
|
||||
STATIC_ASSERT(V3DV_VCM_CACHE_SIZE_LENGTH>=
|
||||
cl_packet_length(VCM_CACHE_SIZE));
|
||||
STATIC_ASSERT(V3DV_GL_SHADER_STATE_ATTRIBUTE_RECORD_LENGTH >=
|
||||
cl_packet_length(GL_SHADER_STATE_ATTRIBUTE_RECORD));
|
||||
STATIC_ASSERT(V3DV_STENCIL_CFG_LENGTH >=
|
||||
cl_packet_length(STENCIL_CFG));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -137,6 +137,11 @@ v3dX(framebuffer_compute_internal_bpp_msaa)(const struct v3dv_framebuffer *frame
|
|||
const struct v3dv_subpass *subpass,
|
||||
uint8_t *max_bpp, bool *msaa);
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
v3dX(device_check_prepacked_sizes)(void);
|
||||
#endif
|
||||
|
||||
/* Used at v3dv_format */
|
||||
const struct v3dv_format *
|
||||
v3dX(get_format)(VkFormat);
|
||||
|
|
Loading…
Reference in New Issue