Vk Immediate: Get Sampler

This commit is contained in:
DrChat 2017-08-06 18:24:48 -05:00
parent 2ba0ebb4cb
commit c656d95345
2 changed files with 22 additions and 13 deletions

View File

@ -651,19 +651,7 @@ std::unique_ptr<ImmediateTexture> VulkanImmediateDrawer::CreateTexture(
const uint8_t* data) {
auto device = context_->device();
VkSampler sampler = nullptr;
switch (filter) {
case ImmediateTextureFilter::kNearest:
sampler = repeat ? samplers_.nearest_repeat : samplers_.nearest_clamp;
break;
case ImmediateTextureFilter::kLinear:
sampler = repeat ? samplers_.linear_repeat : samplers_.linear_clamp;
break;
default:
assert_unhandled_case(filter);
sampler = samplers_.nearest_clamp;
break;
}
VkSampler sampler = GetSampler(filter, repeat);
auto texture = std::make_unique<VulkanImmediateTexture>(
device, descriptor_pool_, texture_set_layout_, sampler, width, height);
@ -810,6 +798,25 @@ void VulkanImmediateDrawer::EndDrawBatch() {}
void VulkanImmediateDrawer::End() { current_cmd_buffer_ = nullptr; }
VkSampler VulkanImmediateDrawer::GetSampler(ImmediateTextureFilter filter,
bool repeat) {
VkSampler sampler = nullptr;
switch (filter) {
case ImmediateTextureFilter::kNearest:
sampler = repeat ? samplers_.nearest_repeat : samplers_.nearest_clamp;
break;
case ImmediateTextureFilter::kLinear:
sampler = repeat ? samplers_.linear_repeat : samplers_.linear_clamp;
break;
default:
assert_unhandled_case(filter);
sampler = samplers_.nearest_clamp;
break;
}
return sampler;
}
} // namespace vulkan
} // namespace ui
} // namespace xe

View File

@ -44,6 +44,8 @@ class VulkanImmediateDrawer : public ImmediateDrawer {
void EndDrawBatch() override;
void End() override;
VkSampler GetSampler(ImmediateTextureFilter filter, bool repeat);
private:
VulkanContext* context_ = nullptr;