Merge remote-tracking branch 'origin/master' into 1.10
# Conflicts: # Source/Engine/Core/Math/Vector3.cpp # Source/Engine/Core/Math/Vector3.h # Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp # Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp # Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h
This commit is contained in:
@@ -140,7 +140,7 @@ void SetParticleVec4(uint particleIndex, int offset, float4 value)
|
|||||||
bool AddParticle(out uint dstIndex)
|
bool AddParticle(out uint dstIndex)
|
||||||
{
|
{
|
||||||
// Acquire the particle index in the destination buffer
|
// Acquire the particle index in the destination buffer
|
||||||
DstParticlesData.InterlockedAdd(ParticleCounterOffset, 1, dstIndex);
|
DstParticlesData.InterlockedAdd(ParticleCounterOffset, 1u, dstIndex);
|
||||||
|
|
||||||
// Prevent overflow
|
// Prevent overflow
|
||||||
return dstIndex >= PARTICLE_CAPACITY;
|
return dstIndex >= PARTICLE_CAPACITY;
|
||||||
|
|||||||
@@ -1292,7 +1292,8 @@ Asset* Content::LoadAsync(const Guid& id, const ScriptingTypeHandle& type)
|
|||||||
LOAD_FAILED();
|
LOAD_FAILED();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
result->RegisterObject();
|
if (!result->IsInternalType())
|
||||||
|
result->RegisterObject();
|
||||||
|
|
||||||
// Register asset
|
// Register asset
|
||||||
AssetsLocker.Lock();
|
AssetsLocker.Lock();
|
||||||
|
|||||||
@@ -560,14 +560,9 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
VkBuffer buffer = VK_NULL_HANDLE;
|
VkBuffer buffer = VK_NULL_HANDLE;
|
||||||
VkDeviceSize offset = 0, range = 0;
|
VkDeviceSize offset = 0, range = 0;
|
||||||
uint32 dynamicOffset = 0;
|
uint32 dynamicOffset = 0;
|
||||||
if (handle)
|
if (!handle)
|
||||||
handle->DescriptorAsDynamicUniformBuffer(this, buffer, offset, range, dynamicOffset);
|
handle = (GPUConstantBufferVulkan*)_device->HelperResources.GetDummyConstantBuffer();
|
||||||
else
|
handle->DescriptorAsDynamicUniformBuffer(this, buffer, offset, range, dynamicOffset);
|
||||||
{
|
|
||||||
const auto dummy = _device->HelperResources.GetDummyBuffer(PixelFormat::R32_SInt);
|
|
||||||
buffer = dummy->GetHandle();
|
|
||||||
range = dummy->GetSize();
|
|
||||||
}
|
|
||||||
needsWrite |= dsWriter.WriteDynamicUniformBuffer(descriptorIndex, buffer, offset, range, dynamicOffset, index);
|
needsWrite |= dsWriter.WriteDynamicUniformBuffer(descriptorIndex, buffer, offset, range, dynamicOffset, index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,6 +232,19 @@ static VKAPI_ATTR VkBool32 VKAPI_PTR DebugUtilsCallback(VkDebugUtilsMessageSever
|
|||||||
LOG(Info, "[Vulkan] {0} {1}:{2}({3}) {4}", type, severity, callbackData->messageIdNumber, String(callbackData->pMessageIdName), message);
|
LOG(Info, "[Vulkan] {0} {1}:{2}({3}) {4}", type, severity, callbackData->messageIdNumber, String(callbackData->pMessageIdName), message);
|
||||||
else
|
else
|
||||||
LOG(Info, "[Vulkan] {0} {1}:{2} {3}", type, severity, callbackData->messageIdNumber, message);
|
LOG(Info, "[Vulkan] {0} {1}:{2} {3}", type, severity, callbackData->messageIdNumber, message);
|
||||||
|
|
||||||
|
#if BUILD_DEBUG
|
||||||
|
if (auto* context = (GPUContextVulkan*)GPUDevice::Instance->GetMainContext())
|
||||||
|
{
|
||||||
|
if (auto* state = (GPUPipelineStateVulkan*)context->GetState())
|
||||||
|
{
|
||||||
|
const StringAnsi vsName = state->DebugDesc.VS ? state->DebugDesc.VS->GetName() : StringAnsi::Empty;
|
||||||
|
const StringAnsi psName = state->DebugDesc.PS ? state->DebugDesc.PS->GetName() : StringAnsi::Empty;
|
||||||
|
LOG(Warning, "[Vulkan] Error during rendering with VS={}, PS={}", String(vsName), String(psName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,7 +778,6 @@ bool BufferedQueryPoolVulkan::HasRoom() const
|
|||||||
|
|
||||||
HelperResourcesVulkan::HelperResourcesVulkan(GPUDeviceVulkan* device)
|
HelperResourcesVulkan::HelperResourcesVulkan(GPUDeviceVulkan* device)
|
||||||
: _device(device)
|
: _device(device)
|
||||||
, _dummyVB(nullptr)
|
|
||||||
{
|
{
|
||||||
Platform::MemoryClear(_dummyTextures, sizeof(_dummyTextures));
|
Platform::MemoryClear(_dummyTextures, sizeof(_dummyTextures));
|
||||||
Platform::MemoryClear(_staticSamplers, sizeof(_staticSamplers));
|
Platform::MemoryClear(_staticSamplers, sizeof(_staticSamplers));
|
||||||
@@ -918,10 +930,20 @@ GPUBufferVulkan* HelperResourcesVulkan::GetDummyVertexBuffer()
|
|||||||
return _dummyVB;
|
return _dummyVB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUConstantBuffer* HelperResourcesVulkan::GetDummyConstantBuffer()
|
||||||
|
{
|
||||||
|
if (!_dummyCB)
|
||||||
|
{
|
||||||
|
_dummyCB = _device->CreateConstantBuffer(256, TEXT("DummyConstantBuffer"));
|
||||||
|
}
|
||||||
|
return _dummyCB;
|
||||||
|
}
|
||||||
|
|
||||||
void HelperResourcesVulkan::Dispose()
|
void HelperResourcesVulkan::Dispose()
|
||||||
{
|
{
|
||||||
SAFE_DELETE_GPU_RESOURCES(_dummyTextures);
|
SAFE_DELETE_GPU_RESOURCES(_dummyTextures);
|
||||||
SAFE_DELETE_GPU_RESOURCE(_dummyVB);
|
SAFE_DELETE_GPU_RESOURCE(_dummyVB);
|
||||||
|
SAFE_DELETE_GPU_RESOURCE(_dummyCB);
|
||||||
if (_dummyBuffers)
|
if (_dummyBuffers)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < (int32)PixelFormat::MAX; i++)
|
for (int32 i = 0; i < (int32)PixelFormat::MAX; i++)
|
||||||
|
|||||||
@@ -310,7 +310,8 @@ private:
|
|||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
GPUTextureVulkan* _dummyTextures[6];
|
GPUTextureVulkan* _dummyTextures[6];
|
||||||
GPUBufferVulkan** _dummyBuffers = nullptr;
|
GPUBufferVulkan** _dummyBuffers = nullptr;
|
||||||
GPUBufferVulkan* _dummyVB;
|
GPUBufferVulkan* _dummyVB = nullptr;
|
||||||
|
GPUConstantBuffer* _dummyCB = nullptr;
|
||||||
VkSampler _staticSamplers[GPU_STATIC_SAMPLERS_COUNT];
|
VkSampler _staticSamplers[GPU_STATIC_SAMPLERS_COUNT];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -321,6 +322,7 @@ public:
|
|||||||
GPUTextureVulkan* GetDummyTexture(SpirvShaderResourceType type);
|
GPUTextureVulkan* GetDummyTexture(SpirvShaderResourceType type);
|
||||||
GPUBufferVulkan* GetDummyBuffer(PixelFormat format);
|
GPUBufferVulkan* GetDummyBuffer(PixelFormat format);
|
||||||
GPUBufferVulkan* GetDummyVertexBuffer();
|
GPUBufferVulkan* GetDummyVertexBuffer();
|
||||||
|
GPUConstantBuffer* GetDummyConstantBuffer();
|
||||||
void Dispose();
|
void Dispose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,11 @@
|
|||||||
#define SAMPLE_SHADOW_MAP(shadowMap, shadowUV, sceneDepth) (sceneDepth < shadowMap.SampleLevel(SamplerLinearClamp, shadowUV, 0).r)
|
#define SAMPLE_SHADOW_MAP(shadowMap, shadowUV, sceneDepth) (sceneDepth < shadowMap.SampleLevel(SamplerLinearClamp, shadowUV, 0).r)
|
||||||
#define SAMPLE_SHADOW_MAP_OFFSET(shadowMap, shadowUV, texelOffset, sceneDepth) (sceneDepth < shadowMap.SampleLevel(SamplerLinearClamp, shadowUV, 0, texelOffset).r)
|
#define SAMPLE_SHADOW_MAP_OFFSET(shadowMap, shadowUV, texelOffset, sceneDepth) (sceneDepth < shadowMap.SampleLevel(SamplerLinearClamp, shadowUV, 0, texelOffset).r)
|
||||||
#endif
|
#endif
|
||||||
|
#if VULKAN || FEATURE_LEVEL < FEATURE_LEVEL_SM5
|
||||||
|
#define SAMPLE_SHADOW_MAP_SAMPLER SamplerPointClamp
|
||||||
|
#else
|
||||||
|
#define SAMPLE_SHADOW_MAP_SAMPLER SamplerLinearClamp
|
||||||
|
#endif
|
||||||
|
|
||||||
float4 GetShadowMask(ShadowSample shadow)
|
float4 GetShadowMask(ShadowSample shadow)
|
||||||
{
|
{
|
||||||
@@ -276,7 +281,7 @@ ShadowSample SampleDirectionalLightShadow(LightData light, Buffer<float4> shadow
|
|||||||
{
|
{
|
||||||
float opacity = gBuffer.CustomData.a;
|
float opacity = gBuffer.CustomData.a;
|
||||||
shadowMapUV = GetLightShadowAtlasUV(shadow, shadowTile, gBuffer.WorldPos, shadowPosition);
|
shadowMapUV = GetLightShadowAtlasUV(shadow, shadowTile, gBuffer.WorldPos, shadowPosition);
|
||||||
float shadowMapDepth = shadowMap.SampleLevel(SamplerLinearClamp, shadowMapUV, 0).r;
|
float shadowMapDepth = shadowMap.SampleLevel(SAMPLE_SHADOW_MAP_SAMPLER, shadowMapUV, 0).r;
|
||||||
result.TransmissionShadow = CalculateSubsurfaceOcclusion(opacity, shadowPosition.z, shadowMapDepth);
|
result.TransmissionShadow = CalculateSubsurfaceOcclusion(opacity, shadowPosition.z, shadowMapDepth);
|
||||||
result.TransmissionShadow = PostProcessShadow(shadow, result.TransmissionShadow);
|
result.TransmissionShadow = PostProcessShadow(shadow, result.TransmissionShadow);
|
||||||
}
|
}
|
||||||
@@ -337,7 +342,7 @@ ShadowSample SampleLocalLightShadow(LightData light, Buffer<float4> shadowsBuffe
|
|||||||
{
|
{
|
||||||
float opacity = gBuffer.CustomData.a;
|
float opacity = gBuffer.CustomData.a;
|
||||||
shadowMapUV = GetLightShadowAtlasUV(shadow, shadowTile, gBuffer.WorldPos, shadowPosition);
|
shadowMapUV = GetLightShadowAtlasUV(shadow, shadowTile, gBuffer.WorldPos, shadowPosition);
|
||||||
float shadowMapDepth = shadowMap.SampleLevel(SamplerLinearClamp, shadowMapUV, 0).r;
|
float shadowMapDepth = shadowMap.SampleLevel(SAMPLE_SHADOW_MAP_SAMPLER, shadowMapUV, 0).r;
|
||||||
result.TransmissionShadow = CalculateSubsurfaceOcclusion(opacity, shadowPosition.z, shadowMapDepth);
|
result.TransmissionShadow = CalculateSubsurfaceOcclusion(opacity, shadowPosition.z, shadowMapDepth);
|
||||||
result.TransmissionShadow = PostProcessShadow(shadow, result.TransmissionShadow);
|
result.TransmissionShadow = PostProcessShadow(shadow, result.TransmissionShadow);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user