16 VkFilter filter = VK_FILTER_LINEAR,
19 : device(device), binding(binding)
21 VkSamplerCreateInfo samplerInfo{};
22 samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
23 samplerInfo.magFilter = filter;
24 samplerInfo.minFilter = filter;
25 samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
26 samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
27 samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
28 samplerInfo.anisotropyEnable = VK_TRUE;
29 samplerInfo.maxAnisotropy = device.
getLimits().maxSamplerAnisotropy;
30 samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
32 samplerInfo.unnormalizedCoordinates = VK_FALSE;
34 samplerInfo.compareEnable = VK_FALSE;
35 samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
36 samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
37 samplerInfo.mipLodBias = 0.0f;
38 samplerInfo.minLod = 0.0f;
39 samplerInfo.maxLod = 0.0f;
41 if (vkCreateSampler(device.
getVkDevice(), &samplerInfo,
nullptr, &sampler) != VK_SUCCESS) {
42 throw std::runtime_error(
"Failed to create texture sampler");
57 VkDescriptorSetLayoutBinding layout {};
58 layout.binding = binding;
59 layout.descriptorCount = 1;
60 layout.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
61 layout.pImmutableSamplers =
nullptr;
62 layout.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;