diff --git a/Source/Engine/Graphics/GPUContext.cpp b/Source/Engine/Graphics/GPUContext.cpp
index 905919794..3ef903be2 100644
--- a/Source/Engine/Graphics/GPUContext.cpp
+++ b/Source/Engine/Graphics/GPUContext.cpp
@@ -101,6 +101,19 @@ void GPUContext::Draw(GPUTexture* dst, GPUTexture* src)
DrawFullscreenTriangle();
}
+void GPUContext::Draw(GPUTexture* dst, GPUTextureView* src)
+{
+ ASSERT_LOW_LAYER(dst && src);
+ ResetRenderTarget();
+ const float width = (float)dst->Width();
+ const float height = (float)dst->Height();
+ SetViewport(width, height);
+ SetRenderTarget(dst->View());
+ BindSR(0, src);
+ SetState(_device->GetCopyLinearPS());
+ DrawFullscreenTriangle();
+}
+
void GPUContext::Draw(GPUTexture* rt)
{
ASSERT_LOW_LAYER(rt);
diff --git a/Source/Engine/Graphics/GPUContext.h b/Source/Engine/Graphics/GPUContext.h
index 042e0501a..68cdfa77b 100644
--- a/Source/Engine/Graphics/GPUContext.h
+++ b/Source/Engine/Graphics/GPUContext.h
@@ -489,6 +489,13 @@ public:
/// The source texture.
API_FUNCTION() void Draw(GPUTexture* dst, GPUTexture* src);
+ ///
+ /// Draws the specified source texture view to destination render target (using fullscreen triangle). Copies contents with resizing and format conversion support. Uses linear texture sampling.
+ ///
+ /// The destination texture.
+ /// The source texture view.
+ API_FUNCTION() void Draw(GPUTexture* dst, GPUTextureView* src);
+
///
/// Draws the specified texture to render target (using fullscreen triangle). Copies contents with resizing and format conversion support. Uses linear texture sampling.
///
diff --git a/Source/Engine/Graphics/GPULimits.h b/Source/Engine/Graphics/GPULimits.h
index 4efe52f43..3de489cdb 100644
--- a/Source/Engine/Graphics/GPULimits.h
+++ b/Source/Engine/Graphics/GPULimits.h
@@ -176,7 +176,7 @@ DECLARE_ENUM_OPERATORS(FormatSupport);
///
/// The features exposed for a particular format.
///
-API_STRUCT() struct FormatFeatures
+API_STRUCT(NoDefault) struct FormatFeatures
{
DECLARE_SCRIPTING_TYPE_MINIMAL(FormatFeatures);
@@ -196,11 +196,23 @@ API_STRUCT() struct FormatFeatures
///
/// Initializes a new instance of the struct.
+ /// [Deprecated in v1.12]
///
/// The format.
/// The MSAA level maximum.
/// The format support.
- FormatFeatures(const PixelFormat format, MSAALevel msaaLevelMax, FormatSupport formatSupport)
+ DEPRECATED("Skip format argument as it's unsued.") FormatFeatures(const PixelFormat format, MSAALevel msaaLevelMax, FormatSupport formatSupport)
+ : MSAALevelMax(msaaLevelMax)
+ , Support(formatSupport)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The MSAA level maximum.
+ /// The format support.
+ FormatFeatures(MSAALevel msaaLevelMax, FormatSupport formatSupport)
: MSAALevelMax(msaaLevelMax)
, Support(formatSupport)
{
@@ -210,59 +222,59 @@ API_STRUCT() struct FormatFeatures
///
/// Graphics Device limits and constraints descriptor.
///
-API_STRUCT() struct GPULimits
+API_STRUCT(NoDefault) struct GPULimits
{
DECLARE_SCRIPTING_TYPE_MINIMAL(GPULimits);
///
/// True if device supports Compute shaders.
///
- API_FIELD() bool HasCompute;
+ API_FIELD() bool HasCompute = false;
///
/// True if device supports Tessellation shaders (domain and hull shaders).
///
- API_FIELD() bool HasTessellation;
+ API_FIELD() bool HasTessellation = false;
///
/// True if device supports Geometry shaders.
///
- API_FIELD() bool HasGeometryShaders;
+ API_FIELD() bool HasGeometryShaders = false;
///
/// True if device supports hardware geometry instancing.
///
- API_FIELD() bool HasInstancing;
+ API_FIELD() bool HasInstancing = false;
///
/// True if device supports rendering to volume textures using Geometry shaders.
///
- API_FIELD() bool HasVolumeTextureRendering;
+ API_FIELD() bool HasVolumeTextureRendering = false;
///
/// True if device supports indirect drawing (including pixel shader write to UAV).
///
- API_FIELD() bool HasDrawIndirect;
+ API_FIELD() bool HasDrawIndirect = false;
///
/// True if device supports append/consume buffers with counters.
///
- API_FIELD() bool HasAppendConsumeBuffers;
+ API_FIELD() bool HasAppendConsumeBuffers = false;
///
/// True if device supports separate render target blending states.
///
- API_FIELD() bool HasSeparateRenderTargetBlendState;
+ API_FIELD() bool HasSeparateRenderTargetBlendState = false;
///
/// True if device supports depth buffer texture as a shader resource view.
///
- API_FIELD() bool HasDepthAsSRV;
+ API_FIELD() bool HasDepthAsSRV = false;
///
/// True if device supports depth buffer clipping (see GPUPipelineState::Description::DepthClipEnable).
///
- API_FIELD() bool HasDepthClip;
+ API_FIELD() bool HasDepthClip = false;
///
/// True if device supports depth buffer bounds testing (see GPUPipelineState::Description::DepthBoundsEnable and GPUContext::SetDepthBounds).
@@ -272,55 +284,55 @@ API_STRUCT() struct GPULimits
///
/// True if device supports depth buffer texture as a readonly depth buffer (can be sampled in the shader while performing depth-test).
///
- API_FIELD() bool HasReadOnlyDepth;
+ API_FIELD() bool HasReadOnlyDepth = false;
///
/// True if device supports multisampled depth buffer texture as a shader resource view.
///
- API_FIELD() bool HasMultisampleDepthAsSRV;
+ API_FIELD() bool HasMultisampleDepthAsSRV = false;
///
/// True if device supports reading from typed UAV in shader (common types such as R32G32B32A32, R16G16B16A16, R16, R8). This doesn't apply to single-component 32-bit formats.
///
- API_FIELD() bool HasTypedUAVLoad;
+ API_FIELD() bool HasTypedUAVLoad = false;
///
/// The maximum amount of texture mip levels.
///
- API_FIELD() int32 MaximumMipLevelsCount;
+ API_FIELD() int32 MaximumMipLevelsCount = 1;
///
/// The maximum size of the 1D texture.
///
- API_FIELD() int32 MaximumTexture1DSize;
+ API_FIELD() int32 MaximumTexture1DSize = 0;
///
/// The maximum length of 1D textures array.
///
- API_FIELD() int32 MaximumTexture1DArraySize;
+ API_FIELD() int32 MaximumTexture1DArraySize = 0;
///
/// The maximum size of the 2D texture.
///
- API_FIELD() int32 MaximumTexture2DSize;
+ API_FIELD() int32 MaximumTexture2DSize = 0;
///
/// The maximum length of 2D textures array.
///
- API_FIELD() int32 MaximumTexture2DArraySize;
+ API_FIELD() int32 MaximumTexture2DArraySize = 0;
///
/// The maximum size of the 3D texture.
///
- API_FIELD() int32 MaximumTexture3DSize;
+ API_FIELD() int32 MaximumTexture3DSize = 0;
///
/// The maximum size of the cube texture (both width and height).
///
- API_FIELD() int32 MaximumTextureCubeSize;
+ API_FIELD() int32 MaximumTextureCubeSize = 0;
///
/// The maximum degree of anisotropic filtering used for texture sampling.
///
- API_FIELD() float MaximumSamplerAnisotropy;
+ API_FIELD() float MaximumSamplerAnisotropy = 0.0f;
};
diff --git a/Source/Engine/Graphics/GPUSwapChain.cpp b/Source/Engine/Graphics/GPUSwapChain.cpp
index 529c4ee83..631382844 100644
--- a/Source/Engine/Graphics/GPUSwapChain.cpp
+++ b/Source/Engine/Graphics/GPUSwapChain.cpp
@@ -1,6 +1,7 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#include "GPUSwapChain.h"
+#include "GPUContext.h"
#include "GPUDevice.h"
#include "Textures/GPUTexture.h"
#include "Engine/Core/Log.h"
@@ -42,6 +43,11 @@ GPUSwapChain::GPUSwapChain()
#endif
}
+void GPUSwapChain::CopyBackbuffer(GPUContext* context, GPUTexture* dst)
+{
+ context->Draw(dst, GetBackBufferView());
+}
+
Task* GPUSwapChain::DownloadDataAsync(TextureData& result)
{
if (_downloadTask)
diff --git a/Source/Engine/Graphics/GPUSwapChain.h b/Source/Engine/Graphics/GPUSwapChain.h
index 2b7c124d9..a8cb9570b 100644
--- a/Source/Engine/Graphics/GPUSwapChain.h
+++ b/Source/Engine/Graphics/GPUSwapChain.h
@@ -106,7 +106,7 @@ public:
///
/// The GPU commands context.
/// The destination texture. It must match the output dimensions and format. No staging texture support.
- virtual void CopyBackbuffer(GPUContext* context, GPUTexture* dst) = 0;
+ virtual void CopyBackbuffer(GPUContext* context, GPUTexture* dst);
///
/// Checks if task is ready to render.
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp
index e4b9e5526..a2b2c99f2 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp
@@ -658,7 +658,7 @@ bool GPUDeviceDX11::Init()
}
UINT formatSupport = 0;
_device->CheckFormatSupport(dxgiFormat, &formatSupport);
- FeaturesPerFormat[i] = FormatFeatures(format, static_cast(maxCount), (FormatSupport)formatSupport);
+ FeaturesPerFormat[i] = FormatFeatures((MSAALevel)maxCount, (FormatSupport)formatSupport);
}
// Driver extensions support
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp
index 0faaa2c16..126673535 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp
@@ -786,7 +786,7 @@ bool GPUDeviceDX12::Init()
if (FAILED(_device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatInfo, sizeof(formatInfo))))
formatInfo.Support1 = D3D12_FORMAT_SUPPORT1_NONE;
const MSAALevel maximumMultisampleCount = GetMaximumMultisampleCount(_device, dxgiFormat);
- FeaturesPerFormat[i] = FormatFeatures(format, maximumMultisampleCount, (FormatSupport)formatInfo.Support1);
+ FeaturesPerFormat[i] = FormatFeatures(maximumMultisampleCount, (FormatSupport)formatInfo.Support1);
}
D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2 = {};
diff --git a/Source/Engine/GraphicsDevice/Null/GPUDeviceNull.cpp b/Source/Engine/GraphicsDevice/Null/GPUDeviceNull.cpp
index 3f9733d52..0e81c8cc8 100644
--- a/Source/Engine/GraphicsDevice/Null/GPUDeviceNull.cpp
+++ b/Source/Engine/GraphicsDevice/Null/GPUDeviceNull.cpp
@@ -62,7 +62,7 @@ bool GPUDeviceNull::Init()
limits.MaximumTextureCubeSize = 16384;
limits.MaximumSamplerAnisotropy = 1;
for (int32 i = 0; i < static_cast(PixelFormat::MAX); i++)
- FeaturesPerFormat[i] = FormatFeatures(static_cast(i), MSAALevel::None, FormatSupport::None);
+ FeaturesPerFormat[i] = FormatFeatures(MSAALevel::None, FormatSupport::None);
}
// Create main context
diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp
index eed7ace29..7299d26d1 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp
+++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp
@@ -1807,7 +1807,7 @@ bool GPUDeviceVulkan::Init()
msaa = maxMsaa;
}
- FeaturesPerFormat[i] = FormatFeatures(format, msaa, support);
+ FeaturesPerFormat[i] = FormatFeatures(msaa, support);
}
}