@@ -35,10 +35,6 @@ GpuTexture::GpuTexture(GpuTexture &&other) noexcept
35
35
m_sampler = std::exchange (other.m_sampler , nullptr );
36
36
}
37
37
38
- GpuTexture::~GpuTexture () {
39
- vkDestroySampler (m_device.device (), m_sampler, nullptr );
40
- }
41
-
42
38
void GpuTexture::create_texture (void *texture_data, const std::size_t texture_size) {
43
39
const VkExtent2D extent{
44
40
// Because stb_image stored the texture's width and height as a normal int, we need a cast here
@@ -70,35 +66,25 @@ void GpuTexture::create_texture(void *texture_data, const std::size_t texture_si
70
66
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
71
67
});
72
68
73
- create_texture_sampler ();
74
- }
75
-
76
- void GpuTexture::create_texture_sampler () {
77
- VkPhysicalDeviceFeatures device_features;
78
- vkGetPhysicalDeviceFeatures (m_device.physical_device (), &device_features);
79
-
80
- VkPhysicalDeviceProperties graphics_card_properties;
81
- vkGetPhysicalDeviceProperties (m_device.physical_device (), &graphics_card_properties);
82
-
83
- const auto sampler_ci = make_info<VkSamplerCreateInfo>({
84
- .magFilter = VK_FILTER_LINEAR,
85
- .minFilter = VK_FILTER_LINEAR,
86
- .mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
87
- .addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT,
88
- .addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT,
89
- .addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
90
- .mipLodBias = 0 .0f ,
91
- .anisotropyEnable = VK_FALSE,
92
- .maxAnisotropy = 1 .0f ,
93
- .compareEnable = VK_FALSE,
94
- .compareOp = VK_COMPARE_OP_ALWAYS,
95
- .minLod = 0 .0f ,
96
- .maxLod = 0 .0f ,
97
- .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
98
- .unnormalizedCoordinates = VK_FALSE,
99
- });
100
-
101
- m_device.create_sampler (sampler_ci, &m_sampler, m_name);
69
+ m_sampler = std::make_unique<Sampler>(m_device,
70
+ make_info<VkSamplerCreateInfo>({
71
+ .magFilter = VK_FILTER_LINEAR,
72
+ .minFilter = VK_FILTER_LINEAR,
73
+ .mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
74
+ .addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT,
75
+ .addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT,
76
+ .addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
77
+ .mipLodBias = 0 .0f ,
78
+ .anisotropyEnable = VK_FALSE,
79
+ .maxAnisotropy = 1 .0f ,
80
+ .compareEnable = VK_FALSE,
81
+ .compareOp = VK_COMPARE_OP_ALWAYS,
82
+ .minLod = 0 .0f ,
83
+ .maxLod = 0 .0f ,
84
+ .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
85
+ .unnormalizedCoordinates = VK_FALSE,
86
+ }),
87
+ " default sampler" );
102
88
}
103
89
104
90
} // namespace inexor::vulkan_renderer::wrapper
0 commit comments