Skip to content

Commit

Permalink
Added TextureSubresourceViews device feature (API254003)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Jan 12, 2024
1 parent f57b131 commit bf3d2c5
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Graphics/GraphicsEngine/interface/APIInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/// \file
/// Diligent API information

#define DILIGENT_API_VERSION 254002
#define DILIGENT_API_VERSION 254003

#include "../../../Primitives/interface/BasicTypes.h"

Expand Down
14 changes: 12 additions & 2 deletions Graphics/GraphicsEngine/interface/GraphicsTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Graphics/GraphicsEngine/src/RenderDeviceBase.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -219,6 +219,7 @@ class EngineFactoryD3DBase : public EngineFactoryBase<BaseInterface>
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
Expand Down
6 changes: 4 additions & 2 deletions Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit bf3d2c5

Please sign in to comment.