Crafter.Graphics/interfaces/Crafter.Graphics-SamplerVulkan.cppm

64 lines
2.3 KiB
Text
Raw Normal View History

2026-02-03 21:03:11 +01:00
/*
Crafter®.Graphics
Copyright (C) 2026 Catcrafts®
catcrafts.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 3.0 as published by the Free Software Foundation;
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
module;
#ifdef CRAFTER_GRAPHICS_VULKAN
2026-03-02 23:53:13 +01:00
#include "vulkan/vulkan.h"
2026-02-03 21:03:11 +01:00
#endif
export module Crafter.Graphics:SamplerVulkan;
import std;
import :VulkanBuffer;
import :ImageVulkan;
export namespace Crafter {
#ifdef CRAFTER_GRAPHICS_VULKAN
template <typename PixelType>
class SamplerVulkan {
public:
VkSampler textureSampler;
VkDescriptorImageInfo imageInfo;
2026-02-04 04:12:27 +01:00
SamplerVulkan() {
2026-02-03 21:03:11 +01:00
VkSamplerCreateInfo samplerInfo{};
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
samplerInfo.magFilter = VK_FILTER_LINEAR;
samplerInfo.minFilter = VK_FILTER_LINEAR;
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
2026-02-04 04:12:27 +01:00
samplerInfo.anisotropyEnable = VK_TRUE;
samplerInfo.maxAnisotropy = 16;
2026-02-03 21:03:11 +01:00
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
samplerInfo.unnormalizedCoordinates = VK_FALSE;
samplerInfo.compareEnable = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerInfo.mipLodBias = 0.0f;
samplerInfo.minLod = 0.0f;
2026-02-04 04:12:27 +01:00
samplerInfo.maxLod = VK_LOD_CLAMP_NONE;
2026-02-03 21:03:11 +01:00
VulkanDevice::CheckVkResult(vkCreateSampler(VulkanDevice::device, &samplerInfo, nullptr, &textureSampler));
imageInfo = {
.sampler = textureSampler
};
}
};
#endif
}