From 596efeda33543ec777bde5911e80d9efae9f8076 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 24 Oct 2024 11:16:40 -0400 Subject: [PATCH] lavapipe: split out sampler init from create no functional changes Konstantin Seurer Part-of: --- src/gallium/frontends/lavapipe/lvp_device.c | 38 +++++++++++--------- src/gallium/frontends/lavapipe/lvp_private.h | 3 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 371f10202ba..74865b02b27 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -2489,20 +2489,9 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_ResetEvent( return VK_SUCCESS; } -VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSampler( - VkDevice _device, - const VkSamplerCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSampler* pSampler) +void +lvp_sampler_init(struct lvp_device *device, struct lp_descriptor *desc, const VkSamplerCreateInfo *pCreateInfo, const struct vk_sampler *sampler) { - LVP_FROM_HANDLE(lvp_device, device, _device); - struct lvp_sampler *sampler; - - sampler = vk_sampler_create(&device->vk, pCreateInfo, - pAllocator, sizeof(*sampler)); - if (!sampler) - return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - struct pipe_sampler_state state = {0}; VkClearColorValue border_color = vk_sampler_border_color_value(pCreateInfo, NULL); @@ -2528,16 +2517,33 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSampler( STATIC_ASSERT((unsigned)VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE == (unsigned)PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE); STATIC_ASSERT((unsigned)VK_SAMPLER_REDUCTION_MODE_MIN == (unsigned)PIPE_TEX_REDUCTION_MIN); STATIC_ASSERT((unsigned)VK_SAMPLER_REDUCTION_MODE_MAX == (unsigned)PIPE_TEX_REDUCTION_MAX); - state.reduction_mode = (enum pipe_tex_reduction_mode)sampler->vk.reduction_mode; + state.reduction_mode = (enum pipe_tex_reduction_mode)sampler->reduction_mode; memcpy(&state.border_color, &border_color, sizeof(border_color)); simple_mtx_lock(&device->queue.lock); struct lp_texture_handle *texture_handle = (void *)(uintptr_t)device->queue.ctx->create_texture_handle(device->queue.ctx, NULL, &state); - sampler->desc.texture.sampler_index = texture_handle->sampler_index; + desc->texture.sampler_index = texture_handle->sampler_index; device->queue.ctx->delete_texture_handle(device->queue.ctx, (uint64_t)(uintptr_t)texture_handle); simple_mtx_unlock(&device->queue.lock); - lp_jit_sampler_from_pipe(&sampler->desc.sampler, &state); + lp_jit_sampler_from_pipe(&desc->sampler, &state); +} + +VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSampler( + VkDevice _device, + const VkSamplerCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSampler* pSampler) +{ + LVP_FROM_HANDLE(lvp_device, device, _device); + struct lvp_sampler *sampler; + + sampler = vk_sampler_create(&device->vk, pCreateInfo, + pAllocator, sizeof(*sampler)); + if (!sampler) + return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); + + lvp_sampler_init(device, &sampler->desc, pCreateInfo, &sampler->vk); *pSampler = lvp_sampler_to_handle(sampler); diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h index 7ee1624c24b..4d5f32f6947 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -769,6 +769,9 @@ lvp_vk_format_to_pipe_format(VkFormat format) } } +void +lvp_sampler_init(struct lvp_device *device, struct lp_descriptor *desc, const VkSamplerCreateInfo *pCreateInfo, const struct vk_sampler *sampler); + static inline uint8_t lvp_image_aspects_to_plane(ASSERTED const struct lvp_image *image, VkImageAspectFlags aspectMask)