{
LVP_FROM_HANDLE(lvp_device, device, _device);
struct lvp_sampler *sampler;
- const VkSamplerReductionModeCreateInfo *reduction_mode_create_info =
- vk_find_struct_const(pCreateInfo->pNext,
- SAMPLER_REDUCTION_MODE_CREATE_INFO);
- const struct VkSamplerYcbcrConversionInfo *ycbcr_conversion =
- vk_find_struct_const(pCreateInfo->pNext, SAMPLER_YCBCR_CONVERSION_INFO);
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
-
- sampler = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*sampler), 8,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ sampler = vk_sampler_create(&device->vk, pCreateInfo,
+ pAllocator, sizeof(*sampler));
if (!sampler)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
- vk_object_base_init(&device->vk, &sampler->base,
- VK_OBJECT_TYPE_SAMPLER);
-
struct pipe_sampler_state state = {0};
VkClearColorValue border_color =
vk_sampler_border_color_value(pCreateInfo, NULL);
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);
- if (reduction_mode_create_info)
- state.reduction_mode = (enum pipe_tex_reduction_mode)reduction_mode_create_info->reductionMode;
- else
- state.reduction_mode = PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
+ state.reduction_mode = (enum pipe_tex_reduction_mode)sampler->vk.reduction_mode;
memcpy(&state.border_color, &border_color, sizeof(border_color));
simple_mtx_lock(&device->queue.lock);
lp_jit_sampler_from_pipe(&sampler->desc.sampler, &state);
sampler->desc.sampler_index = sampler->texture_handle->sampler_index;
- sampler->ycbcr_conversion = ycbcr_conversion ? vk_ycbcr_conversion_from_handle(ycbcr_conversion->conversion) : NULL;
-
*pSampler = lvp_sampler_to_handle(sampler);
return VK_SUCCESS;
device->queue.ctx->delete_texture_handle(device->queue.ctx, (uint64_t)(uintptr_t)sampler->texture_handle);
simple_mtx_unlock(&device->queue.lock);
- vk_object_base_finish(&sampler->base);
- vk_free2(&device->vk.alloc, pAllocator, sampler);
+ vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk);
}
/* vk_icd.h does not declare this function, so we declare it here to
#include "vk_graphics_state.h"
#include "vk_pipeline_layout.h"
#include "vk_queue.h"
+#include "vk_sampler.h"
#include "vk_sync.h"
#include "vk_sync_timeline.h"
#include "vk_ycbcr_conversion.h"
};
struct lvp_sampler {
- struct vk_object_base base;
+ struct vk_sampler vk;
struct lp_descriptor desc;
struct lp_texture_handle *texture_handle;
-
- struct vk_ycbcr_conversion *ycbcr_conversion;
};
struct lvp_descriptor_set_binding_layout {
VK_OBJECT_TYPE_PIPELINE_LAYOUT)
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_query_pool, base, VkQueryPool,
VK_OBJECT_TYPE_QUERY_POOL)
-VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, base, VkSampler,
+VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, vk.base, VkSampler,
VK_OBJECT_TYPE_SAMPLER)
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_indirect_command_layout, base, VkIndirectCommandsLayoutNV,
VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV)