mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[dxvk] Optimize format lookup for simple formats
This commit is contained in:
parent
cdf22a4086
commit
fc525d5b70
@ -7,7 +7,7 @@ namespace dxvk {
|
||||
constexpr VkColorComponentFlags RG = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT;
|
||||
constexpr VkColorComponentFlags R = VK_COLOR_COMPONENT_R_BIT;
|
||||
|
||||
const std::array<DxvkFormatInfo, 152> g_formatInfos = {{
|
||||
const std::array<DxvkFormatInfo, DxvkFormatCount> g_formatInfos = {{
|
||||
// VK_FORMAT_UNDEFINED
|
||||
{ },
|
||||
|
||||
@ -572,7 +572,7 @@ namespace dxvk {
|
||||
}};
|
||||
|
||||
|
||||
const DxvkFormatInfo* lookupFormatInfo(VkFormat format) {
|
||||
const DxvkFormatInfo* lookupFormatInfoSlow(VkFormat format) {
|
||||
uint32_t indexOffset = 0;
|
||||
|
||||
for (const auto& group : g_formatGroups) {
|
||||
|
@ -52,9 +52,33 @@ namespace dxvk {
|
||||
/// Plane info for multi-planar formats
|
||||
std::array<DxvkPlaneFormatInfo, 3> planes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const DxvkFormatInfo* lookupFormatInfo(VkFormat format);
|
||||
|
||||
|
||||
/// Number of formats defined in lookup table
|
||||
constexpr size_t DxvkFormatCount = 152;
|
||||
|
||||
/// Format lookup table
|
||||
extern const std::array<DxvkFormatInfo, DxvkFormatCount> g_formatInfos;
|
||||
|
||||
/**
|
||||
* \brief Looks up format info
|
||||
*
|
||||
* \param [in] format Format to look up
|
||||
* \returns Info for the given format
|
||||
*/
|
||||
const DxvkFormatInfo* lookupFormatInfoSlow(VkFormat format);
|
||||
|
||||
/**
|
||||
* \brief Queries image format info
|
||||
*
|
||||
* Provides a fast path for the most common base formats.
|
||||
* \param [in] format Format to look up
|
||||
* \returns Info for the given format
|
||||
*/
|
||||
inline const DxvkFormatInfo* lookupFormatInfo(VkFormat format) {
|
||||
if (likely(format <= VK_FORMAT_BC7_SRGB_BLOCK))
|
||||
return &g_formatInfos[uint32_t(format)];
|
||||
else
|
||||
return lookupFormatInfo(format);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user