mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 08:10:09 +01:00
radv: use vk_sampler
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24416>
This commit is contained in:
parent
b6d542d7ba
commit
36a93b41d4
3 changed files with 13 additions and 31 deletions
|
|
@ -152,7 +152,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
|
||||
bool has_ycbcr_sampler = false;
|
||||
for (unsigned i = 0; i < pCreateInfo->pBindings[j].descriptorCount; ++i) {
|
||||
if (radv_sampler_from_handle(pCreateInfo->pBindings[j].pImmutableSamplers[i])->ycbcr_sampler)
|
||||
if (radv_sampler_from_handle(pCreateInfo->pBindings[j].pImmutableSamplers[i])->vk.ycbcr_conversion)
|
||||
has_ycbcr_sampler = true;
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
if (binding->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER && binding->pImmutableSamplers) {
|
||||
for (unsigned i = 0; i < binding->descriptorCount; ++i) {
|
||||
struct vk_ycbcr_conversion *conversion =
|
||||
radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler;
|
||||
radv_sampler_from_handle(binding->pImmutableSamplers[i])->vk.ycbcr_conversion;
|
||||
|
||||
if (conversion) {
|
||||
has_ycbcr_sampler = true;
|
||||
|
|
@ -351,8 +351,9 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
if (has_ycbcr_sampler) {
|
||||
ycbcr_sampler_offsets[b] = (const char *)ycbcr_samplers - (const char *)set_layout;
|
||||
for (uint32_t i = 0; i < binding->descriptorCount; i++) {
|
||||
if (radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler)
|
||||
ycbcr_samplers[i] = radv_sampler_from_handle(binding->pImmutableSamplers[i])->ycbcr_sampler->state;
|
||||
if (radv_sampler_from_handle(binding->pImmutableSamplers[i])->vk.ycbcr_conversion)
|
||||
ycbcr_samplers[i] =
|
||||
radv_sampler_from_handle(binding->pImmutableSamplers[i])->vk.ycbcr_conversion->state;
|
||||
else
|
||||
ycbcr_samplers[i].format = VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@
|
|||
#include "vk_log.h"
|
||||
#include "vk_physical_device.h"
|
||||
#include "vk_queue.h"
|
||||
#include "vk_sampler.h"
|
||||
#include "vk_shader_module.h"
|
||||
#include "vk_util.h"
|
||||
#include "vk_video.h"
|
||||
|
|
@ -2920,9 +2921,8 @@ radv_image_extent_compare(const struct radv_image *image, const VkExtent3D *exte
|
|||
}
|
||||
|
||||
struct radv_sampler {
|
||||
struct vk_object_base base;
|
||||
struct vk_sampler vk;
|
||||
uint32_t state[4];
|
||||
struct vk_ycbcr_conversion *ycbcr_sampler;
|
||||
uint32_t border_color_slot;
|
||||
};
|
||||
|
||||
|
|
@ -3662,7 +3662,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(radv_indirect_command_layout, base, VkIndirectCom
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline, base, VkPipeline, VK_OBJECT_TYPE_PIPELINE)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_layout, base, VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_query_pool, base, VkQueryPool, VK_OBJECT_TYPE_QUERY_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler, base, VkSampler, VK_OBJECT_TYPE_SAMPLER)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler, vk.base, VkSampler, VK_OBJECT_TYPE_SAMPLER)
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_video_session, vk.base, VkVideoSessionKHR, VK_OBJECT_TYPE_VIDEO_SESSION_KHR)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_video_session_params, vk.base, VkVideoSessionParametersKHR,
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ radv_init_sampler(struct radv_device *device, struct radv_sampler *sampler, cons
|
|||
uint32_t max_aniso_ratio = radv_tex_aniso_filter(max_aniso);
|
||||
bool compat_mode =
|
||||
device->physical_device->rad_info.gfx_level == GFX8 || device->physical_device->rad_info.gfx_level == GFX9;
|
||||
unsigned filter_mode = V_008F30_SQ_IMG_FILTER_MODE_BLEND;
|
||||
unsigned filter_mode = radv_tex_filter_mode(sampler->vk.reduction_mode);
|
||||
unsigned depth_compare_func = V_008F30_SQ_TEX_DEPTH_COMPARE_NEVER;
|
||||
bool trunc_coord = (pCreateInfo->minFilter == VK_FILTER_NEAREST && pCreateInfo->magFilter == VK_FILTER_NEAREST) ||
|
||||
device->physical_device->rad_info.conformant_trunc_coord;
|
||||
|
|
@ -209,23 +209,13 @@ radv_init_sampler(struct radv_device *device, struct radv_sampler *sampler, cons
|
|||
uint32_t border_color_ptr;
|
||||
bool disable_cube_wrap = pCreateInfo->flags & VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT;
|
||||
|
||||
const struct VkSamplerReductionModeCreateInfo *sampler_reduction =
|
||||
vk_find_struct_const(pCreateInfo->pNext, SAMPLER_REDUCTION_MODE_CREATE_INFO);
|
||||
if (sampler_reduction)
|
||||
filter_mode = radv_tex_filter_mode(sampler_reduction->reductionMode);
|
||||
|
||||
if (pCreateInfo->compareEnable)
|
||||
depth_compare_func = radv_tex_compare(pCreateInfo->compareOp);
|
||||
|
||||
sampler->border_color_slot = RADV_BORDER_COLOR_COUNT;
|
||||
|
||||
if (border_color == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT || border_color == VK_BORDER_COLOR_INT_CUSTOM_EXT) {
|
||||
const VkSamplerCustomBorderColorCreateInfoEXT *custom_border_color =
|
||||
vk_find_struct_const(pCreateInfo->pNext, SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
|
||||
|
||||
assert(custom_border_color);
|
||||
|
||||
sampler->border_color_slot = radv_register_border_color(device, custom_border_color->customBorderColor);
|
||||
if (vk_border_color_is_custom(border_color)) {
|
||||
sampler->border_color_slot = radv_register_border_color(device, sampler->vk.border_color_value);
|
||||
|
||||
/* Did we fail to find a slot? */
|
||||
if (sampler->border_color_slot == RADV_BORDER_COLOR_COUNT) {
|
||||
|
|
@ -278,20 +268,12 @@ radv_CreateSampler(VkDevice _device, const VkSamplerCreateInfo *pCreateInfo, con
|
|||
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||
struct radv_sampler *sampler;
|
||||
|
||||
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_alloc2(&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);
|
||||
|
||||
radv_init_sampler(device, sampler, pCreateInfo);
|
||||
|
||||
sampler->ycbcr_sampler = ycbcr_conversion ? vk_ycbcr_conversion_from_handle(ycbcr_conversion->conversion) : NULL;
|
||||
*pSampler = radv_sampler_to_handle(sampler);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -309,6 +291,5 @@ radv_DestroySampler(VkDevice _device, VkSampler _sampler, const VkAllocationCall
|
|||
if (sampler->border_color_slot != RADV_BORDER_COLOR_COUNT)
|
||||
radv_unregister_border_color(device, sampler->border_color_slot);
|
||||
|
||||
vk_object_base_finish(&sampler->base);
|
||||
vk_free2(&device->vk.alloc, pAllocator, sampler);
|
||||
vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue