From bf3d2c51841716a3cbb6767b45ee18bb6023e689 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 11 Jan 2024 21:45:20 -0800 Subject: [PATCH] Added TextureSubresourceViews device feature (API254003) --- Graphics/GraphicsEngine/interface/APIInfo.h | 2 +- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 14 ++++++++++++-- Graphics/GraphicsEngine/src/RenderDeviceBase.cpp | 5 +++-- .../GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp | 4 ++-- .../GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp | 4 ++-- .../include/EngineFactoryD3DBase.hpp | 3 ++- .../src/RenderDeviceGLImpl.cpp | 6 ++++-- .../GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 4 ++-- .../src/VulkanTypeConversions.cpp | 5 +++-- ReleaseHistory.md | 1 + 10 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 8a741e867..23ab56984 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -30,7 +30,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 254002 +#define DILIGENT_API_VERSION 254003 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 4f0879edb..e1813ebf0 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1788,6 +1788,15 @@ struct DeviceFeatures /// Indicates if device supports texture component swizzle. DEVICE_FEATURE_STATE TextureComponentSwizzle DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED); + /// Indicates if device supports texture subresource views. + /// + /// \remarks This feature is always enabled in all backends except for GLES, WebGL and older + /// OpenGL versions. + /// + /// When this feature is disabled, only texture views that reference the entire + /// texture can be created. + DEVICE_FEATURE_STATE TextureSubresourceViews DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED); + #if DILIGENT_CPP_INTERFACE constexpr DeviceFeatures() noexcept {} @@ -1832,11 +1841,12 @@ struct DeviceFeatures Handler(VariableRateShading) \ Handler(SparseResources) \ Handler(SubpassFramebufferFetch) \ - Handler(TextureComponentSwizzle) + Handler(TextureComponentSwizzle) \ + Handler(TextureSubresourceViews) explicit constexpr DeviceFeatures(DEVICE_FEATURE_STATE State) noexcept { - static_assert(sizeof(*this) == 41, "Did you add a new feature to DeviceFeatures? Please add it to ENUMERATE_DEVICE_FEATURES."); + static_assert(sizeof(*this) == 42, "Did you add a new feature to DeviceFeatures? Please add it to ENUMERATE_DEVICE_FEATURES."); #define INIT_FEATURE(Feature) Feature = State; ENUMERATE_DEVICE_FEATURES(INIT_FEATURE) #undef INIT_FEATURE diff --git a/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp b/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp index 8293fbdc6..46d8db2ff 100644 --- a/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp +++ b/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,10 +113,11 @@ DeviceFeatures EnableDeviceFeatures(const DeviceFeatures& SupportedFeatures, ENABLE_FEATURE(SparseResources, "Sparse resources are"); ENABLE_FEATURE(SubpassFramebufferFetch, "Subpass framebuffer fetch is"); ENABLE_FEATURE(TextureComponentSwizzle, "Texture component swizzle is"); + ENABLE_FEATURE(TextureSubresourceViews, "Texture subresource views are"); // clang-format on #undef ENABLE_FEATURE - ASSERT_SIZEOF(Diligent::DeviceFeatures, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); + ASSERT_SIZEOF(Diligent::DeviceFeatures, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); return EnabledFeatures; } diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index 3892c7342..2d06f5456 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -455,7 +455,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void* } Features.ShaderFloat16 = ShaderFloat16Supported ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED; } - ASSERT_SIZEOF(Features, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(Features, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here."); // Texture properties { diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 685cbe9cf..17b12a8aa 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1067,7 +1067,7 @@ GraphicsAdapterInfo EngineFactoryD3D12Impl::GetGraphicsAdapterInfo(void* ASSERT_SIZEOF(DrawCommandProps, 12, "Did you add a new member to DrawCommandProperties? Please initialize it here."); } - ASSERT_SIZEOF(DeviceFeatures, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(DeviceFeatures, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here."); return AdapterInfo; } diff --git a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp index 6f2a55f55..123f14438 100644 --- a/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/EngineFactoryD3DBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -219,6 +219,7 @@ class EngineFactoryD3DBase : public EngineFactoryBase Features.TileShaders = DEVICE_FEATURE_STATE_DISABLED; Features.SubpassFramebufferFetch = DEVICE_FEATURE_STATE_DISABLED; Features.TextureComponentSwizzle = DEVICE_FEATURE_STATE_DISABLED; + Features.TextureSubresourceViews = DEVICE_FEATURE_STATE_ENABLED; } // Set memory properties diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 6ab47f212..0f4abaec9 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -838,6 +838,7 @@ void RenderDeviceGLImpl::InitAdapterInfo() ENABLE_FEATURE(ResourceBuffer8BitAccess, CheckExtension("GL_EXT_shader_8bit_storage")); ENABLE_FEATURE(UniformBuffer8BitAccess, CheckExtension("GL_EXT_shader_8bit_storage")); ENABLE_FEATURE(TextureComponentSwizzle, IsGL46OrAbove || CheckExtension("GL_ARB_texture_swizzle")); + ENABLE_FEATURE(TextureSubresourceViews, IsGL43OrAbove || CheckExtension("GL_ARB_texture_view")); // clang-format on TexProps.MaxTexture1DDimension = MaxTextureSize; @@ -908,6 +909,7 @@ void RenderDeviceGLImpl::InitAdapterInfo() ENABLE_FEATURE(ResourceBuffer8BitAccess, strstr(Extensions, "shader_8bit_storage")); ENABLE_FEATURE(UniformBuffer8BitAccess, strstr(Extensions, "shader_8bit_storage")); ENABLE_FEATURE(TextureComponentSwizzle, true); + ENABLE_FEATURE(TextureSubresourceViews, strstr(Extensions, "texture_view")); // clang-format on TexProps.MaxTexture1DDimension = 0; // Not supported in GLES 3.2 @@ -1070,7 +1072,7 @@ void RenderDeviceGLImpl::InitAdapterInfo() m_AdapterInfo.Queues[0].TextureCopyGranularity[2] = 1; } - ASSERT_SIZEOF(DeviceFeatures, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(DeviceFeatures, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here."); } void RenderDeviceGLImpl::FlagSupportedTexFormats() diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index 74801a567..d601b1781 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1153,7 +1153,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En LOG_ERROR_MESSAGE("Can not enable extended device features when VK_KHR_get_physical_device_properties2 extension is not supported by device"); } - ASSERT_SIZEOF(Diligent::DeviceFeatures, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(Diligent::DeviceFeatures, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here."); for (Uint32 i = 0; i < EngineCI.DeviceExtensionCount; ++i) { diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index 8f512fec8..d525368a4 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1941,6 +1941,7 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t Features.BinaryOcclusionQueries = DEVICE_FEATURE_STATE_ENABLED; Features.SubpassFramebufferFetch = DEVICE_FEATURE_STATE_ENABLED; Features.TextureComponentSwizzle = DEVICE_FEATURE_STATE_ENABLED; + Features.TextureSubresourceViews = DEVICE_FEATURE_STATE_ENABLED; // Timestamps are not a feature and can't be disabled. They are either supported by the device, or not. Features.TimestampQueries = vkDeviceProps.limits.timestampComputeAndGraphics ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED; @@ -2037,7 +2038,7 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t Features.DurationQueries = DEVICE_FEATURE_STATE_DISABLED; #endif - ASSERT_SIZEOF(DeviceFeatures, 41, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); + ASSERT_SIZEOF(DeviceFeatures, 42, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); return Features; } diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 8b1584c66..e1be8a4dd 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,5 +1,6 @@ ## Current progress +* Added `TextureSubresourceViews` device feature (API254003) * Added device context rendering statistics (API254002) * Added `DeviceContextStats` struct * Added `IDeviceContext::ClearStats` and `IDeviceContext::GetStats` methods