mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
lavapipe: replace lvp_sampler internals with pipe_sampler_state
less indirection, less code Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Acked-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17740>
This commit is contained in:
parent
78495ffaf9
commit
832af7776b
3 changed files with 28 additions and 34 deletions
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "lvp_private.h"
|
||||
#include "lvp_conv.h"
|
||||
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
#include "git_sha1.h"
|
||||
|
|
@ -2171,16 +2172,36 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateSampler(
|
|||
|
||||
vk_object_base_init(&device->vk, &sampler->base,
|
||||
VK_OBJECT_TYPE_SAMPLER);
|
||||
sampler->create_info = *pCreateInfo;
|
||||
|
||||
VkClearColorValue border_color =
|
||||
vk_sampler_border_color_value(pCreateInfo, NULL);
|
||||
STATIC_ASSERT(sizeof(sampler->border_color) == sizeof(border_color));
|
||||
memcpy(&sampler->border_color, &border_color, sizeof(border_color));
|
||||
STATIC_ASSERT(sizeof(sampler->state.border_color) == sizeof(border_color));
|
||||
|
||||
sampler->reduction_mode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
|
||||
sampler->state.wrap_s = vk_conv_wrap_mode(pCreateInfo->addressModeU);
|
||||
sampler->state.wrap_t = vk_conv_wrap_mode(pCreateInfo->addressModeV);
|
||||
sampler->state.wrap_r = vk_conv_wrap_mode(pCreateInfo->addressModeW);
|
||||
sampler->state.min_img_filter = pCreateInfo->minFilter == VK_FILTER_LINEAR ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST;
|
||||
sampler->state.min_mip_filter = pCreateInfo->mipmapMode == VK_SAMPLER_MIPMAP_MODE_LINEAR ? PIPE_TEX_MIPFILTER_LINEAR : PIPE_TEX_MIPFILTER_NEAREST;
|
||||
sampler->state.mag_img_filter = pCreateInfo->magFilter == VK_FILTER_LINEAR ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST;
|
||||
sampler->state.min_lod = pCreateInfo->minLod;
|
||||
sampler->state.max_lod = pCreateInfo->maxLod;
|
||||
sampler->state.lod_bias = pCreateInfo->mipLodBias;
|
||||
if (pCreateInfo->anisotropyEnable)
|
||||
sampler->state.max_anisotropy = pCreateInfo->maxAnisotropy;
|
||||
else
|
||||
sampler->state.max_anisotropy = 1;
|
||||
sampler->state.normalized_coords = !pCreateInfo->unnormalizedCoordinates;
|
||||
sampler->state.compare_mode = pCreateInfo->compareEnable ? PIPE_TEX_COMPARE_R_TO_TEXTURE : PIPE_TEX_COMPARE_NONE;
|
||||
sampler->state.compare_func = pCreateInfo->compareOp;
|
||||
sampler->state.seamless_cube_map = !(pCreateInfo->flags & VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT);
|
||||
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)
|
||||
sampler->reduction_mode = reduction_mode_create_info->reductionMode;
|
||||
sampler->state.reduction_mode = (enum pipe_tex_reduction_mode)reduction_mode_create_info->reductionMode;
|
||||
else
|
||||
sampler->state.reduction_mode = PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
|
||||
memcpy(&sampler->state.border_color, &border_color, sizeof(border_color));
|
||||
|
||||
*pSampler = lvp_sampler_to_handle(sampler);
|
||||
|
||||
|
|
|
|||
|
|
@ -1041,31 +1041,6 @@ struct dyn_info {
|
|||
uint32_t dynamic_offset_count;
|
||||
};
|
||||
|
||||
static void fill_sampler(struct pipe_sampler_state *ss,
|
||||
struct lvp_sampler *samp)
|
||||
{
|
||||
ss->wrap_s = vk_conv_wrap_mode(samp->create_info.addressModeU);
|
||||
ss->wrap_t = vk_conv_wrap_mode(samp->create_info.addressModeV);
|
||||
ss->wrap_r = vk_conv_wrap_mode(samp->create_info.addressModeW);
|
||||
ss->min_img_filter = samp->create_info.minFilter == VK_FILTER_LINEAR ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST;
|
||||
ss->min_mip_filter = samp->create_info.mipmapMode == VK_SAMPLER_MIPMAP_MODE_LINEAR ? PIPE_TEX_MIPFILTER_LINEAR : PIPE_TEX_MIPFILTER_NEAREST;
|
||||
ss->mag_img_filter = samp->create_info.magFilter == VK_FILTER_LINEAR ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST;
|
||||
ss->min_lod = samp->create_info.minLod;
|
||||
ss->max_lod = samp->create_info.maxLod;
|
||||
ss->lod_bias = samp->create_info.mipLodBias;
|
||||
if (samp->create_info.anisotropyEnable)
|
||||
ss->max_anisotropy = samp->create_info.maxAnisotropy;
|
||||
else
|
||||
ss->max_anisotropy = 1;
|
||||
ss->normalized_coords = !samp->create_info.unnormalizedCoordinates;
|
||||
ss->compare_mode = samp->create_info.compareEnable ? PIPE_TEX_COMPARE_R_TO_TEXTURE : PIPE_TEX_COMPARE_NONE;
|
||||
ss->compare_func = samp->create_info.compareOp;
|
||||
ss->seamless_cube_map = !(samp->create_info.flags & VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT);
|
||||
ss->reduction_mode = samp->reduction_mode;
|
||||
memcpy(&ss->border_color, &samp->border_color,
|
||||
sizeof(union pipe_color_union));
|
||||
}
|
||||
|
||||
static void fill_sampler_stage(struct rendering_state *state,
|
||||
struct dyn_info *dyn_info,
|
||||
gl_shader_stage stage,
|
||||
|
|
@ -1079,7 +1054,7 @@ static void fill_sampler_stage(struct rendering_state *state,
|
|||
return;
|
||||
ss_idx += array_idx;
|
||||
ss_idx += dyn_info->stage[stage].sampler_count;
|
||||
fill_sampler(&state->ss[p_stage][ss_idx], binding->immutable_samplers ? binding->immutable_samplers[array_idx] : descriptor->sampler);
|
||||
state->ss[p_stage][ss_idx] = binding->immutable_samplers ? binding->immutable_samplers[array_idx]->state : descriptor->sampler->state;
|
||||
if (state->num_sampler_states[p_stage] <= ss_idx)
|
||||
state->num_sampler_states[p_stage] = ss_idx + 1;
|
||||
state->ss_dirty[p_stage] = true;
|
||||
|
|
|
|||
|
|
@ -261,9 +261,7 @@ struct lvp_image_view {
|
|||
|
||||
struct lvp_sampler {
|
||||
struct vk_object_base base;
|
||||
VkSamplerCreateInfo create_info;
|
||||
union pipe_color_union border_color;
|
||||
VkSamplerReductionMode reduction_mode;
|
||||
struct pipe_sampler_state state;
|
||||
};
|
||||
|
||||
struct lvp_descriptor_set_binding_layout {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue