diff --git a/Content/Editor/MaterialTemplates/GPUParticles.shader b/Content/Editor/MaterialTemplates/GPUParticles.shader index 678eef099..5900743e3 100644 --- a/Content/Editor/MaterialTemplates/GPUParticles.shader +++ b/Content/Editor/MaterialTemplates/GPUParticles.shader @@ -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; diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index ef267b1cc..78dbad4d3 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -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(); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index 951310a2f..856b487d1 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -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; } diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index e662f7505..81dcf2dd8 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -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++) diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index b1d29d1b5..2071b99f3 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -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(); }; diff --git a/Source/Shaders/ShadowsSampling.hlsl b/Source/Shaders/ShadowsSampling.hlsl index 393234fc4..598a22748 100644 --- a/Source/Shaders/ShadowsSampling.hlsl +++ b/Source/Shaders/ShadowsSampling.hlsl @@ -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 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 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); }