mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
v3dV: move meta init/finish to meta implementation files
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
db0bb36ace
commit
4823313587
4 changed files with 130 additions and 109 deletions
|
|
@ -1197,119 +1197,20 @@ init_device_dispatch(struct v3dv_device *device)
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
u64_hash(const void *key)
|
||||
{
|
||||
return _mesa_hash_data(key, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
static bool
|
||||
u64_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return memcmp(key1, key2, sizeof(uint64_t)) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
init_meta_clear_resources(struct v3dv_device *device)
|
||||
{
|
||||
device->meta.color_clear.cache =
|
||||
_mesa_hash_table_create(NULL, u64_hash, u64_compare);
|
||||
device->meta.depth_clear.cache =
|
||||
_mesa_hash_table_create(NULL, u64_hash, u64_compare);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
meta_blit_key_hash(const void *key)
|
||||
{
|
||||
return _mesa_hash_data(key, V3DV_META_BLIT_CACHE_KEY_SIZE);
|
||||
}
|
||||
|
||||
static bool
|
||||
meta_blit_key_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return memcmp(key1, key2, V3DV_META_BLIT_CACHE_KEY_SIZE) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
init_meta_blit_resources(struct v3dv_device *device)
|
||||
{
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
device->meta.blit.cache[i] =
|
||||
_mesa_hash_table_create(NULL,
|
||||
meta_blit_key_hash,
|
||||
meta_blit_key_compare);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_device_meta(struct v3dv_device *device)
|
||||
{
|
||||
mtx_init(&device->meta.mtx, mtx_plain);
|
||||
init_meta_clear_resources(device);
|
||||
init_meta_blit_resources(device);
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_meta_color_clear_pipeline_destroy(VkDevice _device,
|
||||
struct v3dv_meta_color_clear_pipeline *p,
|
||||
VkAllocationCallbacks *alloc)
|
||||
{
|
||||
v3dv_DestroyPipeline(_device, p->pipeline, alloc);
|
||||
if (p->cached)
|
||||
v3dv_DestroyRenderPass(_device, p->pass, alloc);
|
||||
vk_free(alloc, p);
|
||||
v3dv_meta_clear_init(device);
|
||||
v3dv_meta_blit_init(device);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_device_meta(struct v3dv_device *device)
|
||||
{
|
||||
VkDevice _device = v3dv_device_to_handle(device);
|
||||
|
||||
mtx_destroy(&device->meta.mtx);
|
||||
|
||||
hash_table_foreach(device->meta.color_clear.cache, entry) {
|
||||
struct v3dv_meta_color_clear_pipeline *item = entry->data;
|
||||
v3dv_meta_color_clear_pipeline_destroy(v3dv_device_to_handle(device),
|
||||
item, &device->alloc);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.color_clear.cache, NULL);
|
||||
|
||||
if (device->meta.color_clear.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.color_clear.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
|
||||
hash_table_foreach(device->meta.depth_clear.cache, entry) {
|
||||
struct v3dv_meta_depth_clear_pipeline *item = entry->data;
|
||||
v3dv_DestroyPipeline(_device, item->pipeline, &device->alloc);
|
||||
vk_free(&device->alloc, item);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.depth_clear.cache, NULL);
|
||||
|
||||
if (device->meta.depth_clear.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.depth_clear.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
hash_table_foreach(device->meta.blit.cache[i], entry) {
|
||||
struct v3dv_meta_blit_pipeline *item = entry->data;
|
||||
v3dv_DestroyPipeline(_device, item->pipeline, &device->alloc);
|
||||
v3dv_DestroyRenderPass(_device, item->pass, &device->alloc);
|
||||
vk_free(&device->alloc, item);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.blit.cache[i], NULL);
|
||||
}
|
||||
|
||||
if (device->meta.blit.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.blit.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
|
||||
if (device->meta.blit.dslayout) {
|
||||
v3dv_DestroyDescriptorSetLayout(_device, device->meta.blit.dslayout,
|
||||
&device->alloc);
|
||||
}
|
||||
v3dv_meta_clear_finish(device);
|
||||
v3dv_meta_blit_finish(device);
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
|
|||
|
|
@ -28,6 +28,64 @@
|
|||
#include "vk_format_info.h"
|
||||
#include "util/u_pack_color.h"
|
||||
|
||||
static void
|
||||
destroy_color_clear_pipeline(VkDevice _device,
|
||||
struct v3dv_meta_color_clear_pipeline *p,
|
||||
VkAllocationCallbacks *alloc)
|
||||
{
|
||||
v3dv_DestroyPipeline(_device, p->pipeline, alloc);
|
||||
if (p->cached)
|
||||
v3dv_DestroyRenderPass(_device, p->pass, alloc);
|
||||
vk_free(alloc, p);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_depth_clear_pipeline(VkDevice _device,
|
||||
struct v3dv_meta_depth_clear_pipeline *p,
|
||||
VkAllocationCallbacks *alloc)
|
||||
{
|
||||
v3dv_DestroyPipeline(_device, p->pipeline, alloc);
|
||||
vk_free(alloc, p);
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_meta_clear_init(struct v3dv_device *device)
|
||||
{
|
||||
device->meta.color_clear.cache =
|
||||
_mesa_hash_table_create(NULL, u64_hash, u64_compare);
|
||||
|
||||
device->meta.depth_clear.cache =
|
||||
_mesa_hash_table_create(NULL, u64_hash, u64_compare);
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_meta_clear_finish(struct v3dv_device *device)
|
||||
{
|
||||
VkDevice _device = v3dv_device_to_handle(device);
|
||||
|
||||
hash_table_foreach(device->meta.color_clear.cache, entry) {
|
||||
struct v3dv_meta_color_clear_pipeline *item = entry->data;
|
||||
destroy_color_clear_pipeline(_device, item, &device->alloc);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.color_clear.cache, NULL);
|
||||
|
||||
if (device->meta.color_clear.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.color_clear.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
|
||||
hash_table_foreach(device->meta.depth_clear.cache, entry) {
|
||||
struct v3dv_meta_depth_clear_pipeline *item = entry->data;
|
||||
destroy_depth_clear_pipeline(_device, item, &device->alloc);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.depth_clear.cache, NULL);
|
||||
|
||||
if (device->meta.depth_clear.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.depth_clear.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
gen_rect_vertices(nir_builder *b)
|
||||
{
|
||||
|
|
@ -1037,7 +1095,7 @@ emit_subpass_color_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
|
|||
assert(!pipeline->cached);
|
||||
v3dv_cmd_buffer_add_private_obj(
|
||||
cmd_buffer, (uintptr_t)pipeline,
|
||||
(v3dv_cmd_buffer_private_obj_destroy_cb) v3dv_meta_color_clear_pipeline_destroy);
|
||||
(v3dv_cmd_buffer_private_obj_destroy_cb) destroy_color_clear_pipeline);
|
||||
|
||||
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dynamic_states, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,55 @@
|
|||
#include "vk_format_info.h"
|
||||
#include "util/u_pack_color.h"
|
||||
|
||||
static uint32_t
|
||||
meta_blit_key_hash(const void *key)
|
||||
{
|
||||
return _mesa_hash_data(key, V3DV_META_BLIT_CACHE_KEY_SIZE);
|
||||
}
|
||||
|
||||
static bool
|
||||
meta_blit_key_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return memcmp(key1, key2, V3DV_META_BLIT_CACHE_KEY_SIZE) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_meta_blit_init(struct v3dv_device *device)
|
||||
{
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
device->meta.blit.cache[i] =
|
||||
_mesa_hash_table_create(NULL,
|
||||
meta_blit_key_hash,
|
||||
meta_blit_key_compare);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_meta_blit_finish(struct v3dv_device *device)
|
||||
{
|
||||
VkDevice _device = v3dv_device_to_handle(device);
|
||||
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
hash_table_foreach(device->meta.blit.cache[i], entry) {
|
||||
struct v3dv_meta_blit_pipeline *item = entry->data;
|
||||
v3dv_DestroyPipeline(_device, item->pipeline, &device->alloc);
|
||||
v3dv_DestroyRenderPass(_device, item->pass, &device->alloc);
|
||||
vk_free(&device->alloc, item);
|
||||
}
|
||||
_mesa_hash_table_destroy(device->meta.blit.cache[i], NULL);
|
||||
}
|
||||
|
||||
if (device->meta.blit.playout) {
|
||||
v3dv_DestroyPipelineLayout(_device, device->meta.blit.playout,
|
||||
&device->alloc);
|
||||
}
|
||||
|
||||
if (device->meta.blit.dslayout) {
|
||||
v3dv_DestroyDescriptorSetLayout(_device, device->meta.blit.dslayout,
|
||||
&device->alloc);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
can_use_tlb(struct v3dv_image *image,
|
||||
const VkOffset3D *offset,
|
||||
|
|
|
|||
|
|
@ -159,6 +159,12 @@ struct v3dv_physical_device {
|
|||
VkResult v3dv_wsi_init(struct v3dv_physical_device *physical_device);
|
||||
void v3dv_wsi_finish(struct v3dv_physical_device *physical_device);
|
||||
|
||||
void v3dv_meta_clear_init(struct v3dv_device *device);
|
||||
void v3dv_meta_clear_finish(struct v3dv_device *device);
|
||||
|
||||
void v3dv_meta_blit_init(struct v3dv_device *device);
|
||||
void v3dv_meta_blit_finish(struct v3dv_device *device);
|
||||
|
||||
struct v3dv_app_info {
|
||||
const char *app_name;
|
||||
uint32_t app_version;
|
||||
|
|
@ -1859,11 +1865,6 @@ v3dv_pipeline_cache_upload_variant(struct v3dv_pipeline *pipeline,
|
|||
void v3dv_shader_module_internal_init(struct v3dv_shader_module *module,
|
||||
nir_shader *nir);
|
||||
|
||||
void
|
||||
v3dv_meta_color_clear_pipeline_destroy(VkDevice _device,
|
||||
struct v3dv_meta_color_clear_pipeline *p,
|
||||
VkAllocationCallbacks *alloc);
|
||||
|
||||
#define V3DV_DEFINE_HANDLE_CASTS(__v3dv_type, __VkType) \
|
||||
\
|
||||
static inline struct __v3dv_type * \
|
||||
|
|
@ -1967,4 +1968,16 @@ v3dv_flag_oom(struct v3dv_cmd_buffer *cmd_buffer, struct v3dv_job *job)
|
|||
return; \
|
||||
} while(0) \
|
||||
|
||||
static inline uint32_t
|
||||
u64_hash(const void *key)
|
||||
{
|
||||
return _mesa_hash_data(key, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
u64_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return memcmp(key1, key2, sizeof(uint64_t)) == 0;
|
||||
}
|
||||
|
||||
#endif /* V3DV_PRIVATE_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue