Skip to content

Commit

Permalink
Replaced run-time checks with a static_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
corporateshark committed Aug 17, 2024
1 parent 8e946d2 commit bb7e843
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lvk/vulkan/VulkanClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3504,9 +3504,10 @@ lvk::Holder<lvk::TextureHandle> lvk::VulkanContext::createTexture(const TextureD
return {this, handle};
}

VkSampler lvk::VulkanContext::getOrCreateYcbcrSampler(lvk::Format format) {
LVK_ASSERT(format < LVK_ARRAY_NUM_ELEMENTS(pimpl_->ycbcrConversionData_));
static_assert(1 << (sizeof(lvk::Format) * 8) <= LVK_ARRAY_NUM_ELEMENTS(lvk::VulkanContextImpl::ycbcrConversionData_),
"There aren't enough elements in `ycbcrConversionData_` to be accessed by lvk::Format");

VkSampler lvk::VulkanContext::getOrCreateYcbcrSampler(lvk::Format format) {
const VkSamplerYcbcrConversionInfo* info = getOrCreateYcbcrConversionInfo(format);

if (!info) {
Expand All @@ -3517,8 +3518,6 @@ VkSampler lvk::VulkanContext::getOrCreateYcbcrSampler(lvk::Format format) {
}

const VkSamplerYcbcrConversionInfo* lvk::VulkanContext::getOrCreateYcbcrConversionInfo(lvk::Format format) {
LVK_ASSERT(format < LVK_ARRAY_NUM_ELEMENTS(pimpl_->ycbcrConversionData_));

if (pimpl_->ycbcrConversionData_[format].info.sType) {
return &pimpl_->ycbcrConversionData_[format].info;
}
Expand Down

0 comments on commit bb7e843

Please sign in to comment.