Add HasTypedUAVLoad to GPULimits (use for GPU lightmaps support baking detection)
#526
This commit is contained in:
@@ -10,8 +10,6 @@ namespace FlaxEditor.Progress.Handlers
|
||||
/// <seealso cref="FlaxEditor.Progress.ProgressHandler" />
|
||||
public sealed class BakeLightmapsProgress : ProgressHandler
|
||||
{
|
||||
private static int _canBake;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether GPU lightmaps baking is supported on this device.
|
||||
/// </summary>
|
||||
@@ -19,15 +17,11 @@ namespace FlaxEditor.Progress.Handlers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_canBake == 0)
|
||||
{
|
||||
var instance = GPUDevice.Instance;
|
||||
if (instance == null)
|
||||
return false;
|
||||
var limits = instance.Limits;
|
||||
_canBake = limits.HasCompute && limits.MaximumTexture2DSize >= 8 * 1024 && instance.TotalGraphicsMemory >= 2 * 1024 ? 1 : 2;
|
||||
}
|
||||
return _canBake == 1;
|
||||
var instance = GPUDevice.Instance;
|
||||
if (instance == null)
|
||||
return false;
|
||||
var limits = instance.Limits;
|
||||
return limits.HasCompute && limits.HasTypedUAVLoad && limits.MaximumTexture2DSize >= 8 * 1024 && instance.TotalGraphicsMemory >= 2 * 1024;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,6 +275,11 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(GPULimits);
|
||||
/// </summary>
|
||||
API_FIELD() bool HasMultisampleDepthAsSRV;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
API_FIELD() bool HasTypedUAVLoad;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum amount of texture mip levels.
|
||||
/// </summary>
|
||||
|
||||
@@ -296,26 +296,16 @@ bool GPUDeviceDX11::Init()
|
||||
ASSERT(createdFeatureLevel == targetFeatureLevel);
|
||||
_state = DeviceState::Created;
|
||||
|
||||
// Verify compute shader is supported on DirectX 11
|
||||
if (createdFeatureLevel >= D3D_FEATURE_LEVEL_11_0)
|
||||
{
|
||||
D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options = { 0 };
|
||||
_device->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &options, sizeof(options));
|
||||
if (!options.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x)
|
||||
{
|
||||
_device->Release();
|
||||
_device = nullptr;
|
||||
LOG(Fatal, "DirectCompute is not supported by this device (DirectX 11 level).");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Init device limits
|
||||
{
|
||||
auto& limits = Limits;
|
||||
if (createdFeatureLevel >= D3D_FEATURE_LEVEL_11_0)
|
||||
{
|
||||
limits.HasCompute = true;
|
||||
D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS d3D10XHardwareOptions = {};
|
||||
_device->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &d3D10XHardwareOptions, sizeof(d3D10XHardwareOptions));
|
||||
D3D11_FEATURE_DATA_D3D11_OPTIONS2 featureDataD3D11Options2 = {};
|
||||
_device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS2, &featureDataD3D11Options2, sizeof(featureDataD3D11Options2));
|
||||
limits.HasCompute = d3D10XHardwareOptions.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x != 0;
|
||||
limits.HasTessellation = true;
|
||||
limits.HasGeometryShaders = true;
|
||||
limits.HasInstancing = true;
|
||||
@@ -326,6 +316,7 @@ bool GPUDeviceDX11::Init()
|
||||
limits.HasDepthAsSRV = true;
|
||||
limits.HasReadOnlyDepth = true;
|
||||
limits.HasMultisampleDepthAsSRV = true;
|
||||
limits.HasTypedUAVLoad = featureDataD3D11Options2.TypedUAVLoadAdditionalFormats != 0;
|
||||
limits.MaximumMipLevelsCount = D3D11_REQ_MIP_LEVELS;
|
||||
limits.MaximumTexture1DSize = D3D11_REQ_TEXTURE1D_U_DIMENSION;
|
||||
limits.MaximumTexture1DArraySize = D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
|
||||
@@ -347,6 +338,7 @@ bool GPUDeviceDX11::Init()
|
||||
limits.HasDepthAsSRV = false;
|
||||
limits.HasReadOnlyDepth = createdFeatureLevel == D3D_FEATURE_LEVEL_10_1;
|
||||
limits.HasMultisampleDepthAsSRV = false;
|
||||
limits.HasTypedUAVLoad = false;
|
||||
limits.MaximumMipLevelsCount = D3D10_REQ_MIP_LEVELS;
|
||||
limits.MaximumTexture1DSize = D3D10_REQ_TEXTURE1D_U_DIMENSION;
|
||||
limits.MaximumTexture1DArraySize = D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
|
||||
|
||||
@@ -339,6 +339,7 @@ bool GPUDeviceDX12::Init()
|
||||
limits.HasDepthAsSRV = true;
|
||||
limits.HasReadOnlyDepth = true;
|
||||
limits.HasMultisampleDepthAsSRV = true;
|
||||
limits.HasTypedUAVLoad = options.TypedUAVLoadAdditionalFormats != 0;
|
||||
limits.MaximumMipLevelsCount = D3D12_REQ_MIP_LEVELS;
|
||||
limits.MaximumTexture1DSize = D3D12_REQ_TEXTURE1D_U_DIMENSION;
|
||||
limits.MaximumTexture1DArraySize = D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
|
||||
|
||||
@@ -58,6 +58,7 @@ bool GPUDeviceNull::Init()
|
||||
limits.HasDepthAsSRV = false;
|
||||
limits.HasReadOnlyDepth = false;
|
||||
limits.HasMultisampleDepthAsSRV = false;
|
||||
limits.HasTypedUAVLoad = false;
|
||||
limits.MaximumMipLevelsCount = 14;
|
||||
limits.MaximumTexture1DSize = 8192;
|
||||
limits.MaximumTexture1DArraySize = 512;
|
||||
|
||||
@@ -1684,6 +1684,7 @@ bool GPUDeviceVulkan::Init()
|
||||
limits.HasDepthAsSRV = true;
|
||||
limits.HasReadOnlyDepth = true;
|
||||
limits.HasMultisampleDepthAsSRV = !!PhysicalDeviceFeatures.sampleRateShading;
|
||||
limits.HasTypedUAVLoad = true;
|
||||
limits.MaximumMipLevelsCount = Math::Min(static_cast<int32>(log2(PhysicalDeviceLimits.maxImageDimension2D)), GPU_MAX_TEXTURE_MIP_LEVELS);
|
||||
limits.MaximumTexture1DSize = PhysicalDeviceLimits.maxImageDimension1D;
|
||||
limits.MaximumTexture1DArraySize = PhysicalDeviceLimits.maxImageArrayLayers;
|
||||
|
||||
@@ -38,8 +38,6 @@ bool DepthOfFieldPass::Init()
|
||||
_platformSupportsDoF = limits.HasCompute;
|
||||
_platformSupportsBokeh = _platformSupportsDoF && limits.HasGeometryShaders && limits.HasDrawIndirect && limits.HasAppendConsumeBuffers;
|
||||
|
||||
_platformSupportsBokeh &= GPUDevice::Instance->GetRendererType() != RendererType::Vulkan; // TODO: add bokeh on Vulkan (draw indirect with UA output from PS)
|
||||
|
||||
// Create pipeline states
|
||||
if (_platformSupportsDoF)
|
||||
{
|
||||
|
||||
@@ -314,11 +314,13 @@ void ShadowsPass::RenderShadow(RenderContext& renderContext, RendererPointLightD
|
||||
context->ResetSR();
|
||||
context->ResetRenderTarget();
|
||||
const Viewport viewport = renderContext.Task->GetViewport();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferHandle = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(viewport);
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
context->BindSR(2, renderContext.Buffers->GBuffer2);
|
||||
context->BindSR(3, renderContext.Buffers->DepthBuffer);
|
||||
context->BindSR(3, depthBufferHandle);
|
||||
context->BindSR(4, renderContext.Buffers->GBuffer3);
|
||||
|
||||
// Setup shader data
|
||||
@@ -414,11 +416,13 @@ void ShadowsPass::RenderShadow(RenderContext& renderContext, RendererSpotLightDa
|
||||
context->ResetSR();
|
||||
context->ResetRenderTarget();
|
||||
const Viewport viewport = renderContext.Task->GetViewport();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferHandle = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(viewport);
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
context->BindSR(2, renderContext.Buffers->GBuffer2);
|
||||
context->BindSR(3, renderContext.Buffers->DepthBuffer);
|
||||
context->BindSR(3, depthBufferHandle);
|
||||
context->BindSR(4, renderContext.Buffers->GBuffer3);
|
||||
|
||||
// Setup shader data
|
||||
@@ -688,11 +692,13 @@ void ShadowsPass::RenderShadow(RenderContext& renderContext, RendererDirectional
|
||||
context->ResetSR();
|
||||
context->ResetRenderTarget();
|
||||
const Viewport viewport = renderContext.Task->GetViewport();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferHandle = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(viewport);
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
context->BindSR(2, renderContext.Buffers->GBuffer2);
|
||||
context->BindSR(3, renderContext.Buffers->DepthBuffer);
|
||||
context->BindSR(3, depthBufferHandle);
|
||||
context->BindSR(4, renderContext.Buffers->GBuffer3);
|
||||
|
||||
// Setup shader data
|
||||
|
||||
Reference in New Issue
Block a user