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:
Wojtek Figat
2025-03-09 09:23:42 +01:00
6 changed files with 39 additions and 14 deletions

View File

@@ -140,7 +140,7 @@ void SetParticleVec4(uint particleIndex, int offset, float4 value)
bool AddParticle(out uint dstIndex)
{
// Acquire the particle index in the destination buffer
DstParticlesData.InterlockedAdd(ParticleCounterOffset, 1, dstIndex);
DstParticlesData.InterlockedAdd(ParticleCounterOffset, 1u, dstIndex);
// Prevent overflow
return dstIndex >= PARTICLE_CAPACITY;

View File

@@ -1292,7 +1292,8 @@ Asset* Content::LoadAsync(const Guid& id, const ScriptingTypeHandle& type)
LOAD_FAILED();
}
#endif
result->RegisterObject();
if (!result->IsInternalType())
result->RegisterObject();
// Register asset
AssetsLocker.Lock();

View File

@@ -560,14 +560,9 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
VkBuffer buffer = VK_NULL_HANDLE;
VkDeviceSize offset = 0, range = 0;
uint32 dynamicOffset = 0;
if (handle)
handle->DescriptorAsDynamicUniformBuffer(this, buffer, offset, range, dynamicOffset);
else
{
const auto dummy = _device->HelperResources.GetDummyBuffer(PixelFormat::R32_SInt);
buffer = dummy->GetHandle();
range = dummy->GetSize();
}
if (!handle)
handle = (GPUConstantBufferVulkan*)_device->HelperResources.GetDummyConstantBuffer();
handle->DescriptorAsDynamicUniformBuffer(this, buffer, offset, range, dynamicOffset);
needsWrite |= dsWriter.WriteDynamicUniformBuffer(descriptorIndex, buffer, offset, range, dynamicOffset, index);
break;
}

View File

@@ -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);
else
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;
}
@@ -765,7 +778,6 @@ bool BufferedQueryPoolVulkan::HasRoom() const
HelperResourcesVulkan::HelperResourcesVulkan(GPUDeviceVulkan* device)
: _device(device)
, _dummyVB(nullptr)
{
Platform::MemoryClear(_dummyTextures, sizeof(_dummyTextures));
Platform::MemoryClear(_staticSamplers, sizeof(_staticSamplers));
@@ -918,10 +930,20 @@ GPUBufferVulkan* HelperResourcesVulkan::GetDummyVertexBuffer()
return _dummyVB;
}
GPUConstantBuffer* HelperResourcesVulkan::GetDummyConstantBuffer()
{
if (!_dummyCB)
{
_dummyCB = _device->CreateConstantBuffer(256, TEXT("DummyConstantBuffer"));
}
return _dummyCB;
}
void HelperResourcesVulkan::Dispose()
{
SAFE_DELETE_GPU_RESOURCES(_dummyTextures);
SAFE_DELETE_GPU_RESOURCE(_dummyVB);
SAFE_DELETE_GPU_RESOURCE(_dummyCB);
if (_dummyBuffers)
{
for (int32 i = 0; i < (int32)PixelFormat::MAX; i++)

View File

@@ -310,7 +310,8 @@ private:
GPUDeviceVulkan* _device;
GPUTextureVulkan* _dummyTextures[6];
GPUBufferVulkan** _dummyBuffers = nullptr;
GPUBufferVulkan* _dummyVB;
GPUBufferVulkan* _dummyVB = nullptr;
GPUConstantBuffer* _dummyCB = nullptr;
VkSampler _staticSamplers[GPU_STATIC_SAMPLERS_COUNT];
public:
@@ -321,6 +322,7 @@ public:
GPUTextureVulkan* GetDummyTexture(SpirvShaderResourceType type);
GPUBufferVulkan* GetDummyBuffer(PixelFormat format);
GPUBufferVulkan* GetDummyVertexBuffer();
GPUConstantBuffer* GetDummyConstantBuffer();
void Dispose();
};

View File

@@ -17,6 +17,11 @@
#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)
#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)
{
@@ -276,7 +281,7 @@ ShadowSample SampleDirectionalLightShadow(LightData light, Buffer<float4> shadow
{
float opacity = gBuffer.CustomData.a;
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 = PostProcessShadow(shadow, result.TransmissionShadow);
}
@@ -337,7 +342,7 @@ ShadowSample SampleLocalLightShadow(LightData light, Buffer<float4> shadowsBuffe
{
float opacity = gBuffer.CustomData.a;
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 = PostProcessShadow(shadow, result.TransmissionShadow);
}