From 13d0450aa8565476d2cec41fbcd10ad4e4f60b10 Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 11 Jul 2026 17:38:35 +0800 Subject: [PATCH 1/2] feat: update editor layout config path --- Editor/Include/Editor/EditorApplication.h | 1 + Editor/Src/EditorApplication.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Editor/Include/Editor/EditorApplication.h b/Editor/Include/Editor/EditorApplication.h index 2fa71e7e..f8d91b0f 100644 --- a/Editor/Include/Editor/EditorApplication.h +++ b/Editor/Include/Editor/EditorApplication.h @@ -49,6 +49,7 @@ namespace Editor { float NextDeltaSeconds(); EditorApplicationDesc desc; + std::string imguiIniFilename; Common::UniquePtr window; Common::UniquePtr context; Common::UniquePtr sceneRenderCanvas; diff --git a/Editor/Src/EditorApplication.cpp b/Editor/Src/EditorApplication.cpp index a83fa224..40246c32 100644 --- a/Editor/Src/EditorApplication.cpp +++ b/Editor/Src/EditorApplication.cpp @@ -188,7 +188,14 @@ namespace Editor { io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; io.BackendPlatformName = "ExplosionGLFW"; io.BackendRendererName = "ExplosionRHI"; - io.IniFilename = "ExplosionEditor.ini"; + if (desc.mode == EditorApplicationMode::editor) { + const Common::Path iniFilePath = Core::Paths::GameCacheDir() / "Editor" / "Layout" / "Main.ini"; + iniFilePath.Parent().MakeDir(); + imguiIniFilename = iniFilePath.String(); + io.IniFilename = imguiIniFilename.c_str(); + } else { + io.IniFilename = nullptr; + } ImFontConfig defaultFontConfig; defaultFontConfig.SizePixels = Internal::defaultFontSize; io.FontDefault = io.Fonts->AddFontDefaultVector(&defaultFontConfig); From c74c6223641e64c9487cd308de35f8382eba5de0 Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 11 Jul 2026 17:40:13 +0800 Subject: [PATCH 2/2] fix: dx12 version editor crash --- Editor/Src/EditorWindow.cpp | 6 +-- .../Include/RHI/DirectX12/BindGroup.h | 10 ++++- .../Include/RHI/DirectX12/BindGroupLayout.h | 3 +- .../Include/RHI/DirectX12/PipelineLayout.h | 6 ++- Engine/Source/RHI-DirectX12/Src/BindGroup.cpp | 4 +- .../RHI-DirectX12/Src/BindGroupLayout.cpp | 9 ++++- .../RHI-DirectX12/Src/CommandRecorder.cpp | 22 ++++++----- .../RHI-DirectX12/Src/PipelineLayout.cpp | 24 +++++++++--- Engine/Source/RHI/Include/RHI/BindGroup.h | 6 ++- Engine/Source/RHI/Src/BindGroup.cpp | 6 ++- .../Render/Include/Render/RenderCache.h | 1 + Engine/Source/Render/Src/RenderCache.cpp | 6 +++ Engine/Source/Render/Src/RenderGraph.cpp | 11 +++--- .../RHI-ParallelCompute/ParallelCompute.cpp | 6 +-- Sample/RHI-SSAO/SSAOApplication.cpp | 38 +++++++++---------- Sample/RHI-TexSampling/TexSampling.cpp | 6 +-- 16 files changed, 105 insertions(+), 59 deletions(-) diff --git a/Editor/Src/EditorWindow.cpp b/Editor/Src/EditorWindow.cpp index bbb223f5..da72033f 100644 --- a/Editor/Src/EditorWindow.cpp +++ b/Editor/Src/EditorWindow.cpp @@ -540,9 +540,9 @@ namespace Editor { auto bindGroup = GetDevice().CreateBindGroup( RHI::BindGroupCreateInfo(imguiBindGroupLayout.Get(), "imguiBindGroup") - .AddEntry(RHI::BindGroupEntry(imguiPixelShaderCompileOutput.reflectionData.QueryResourceBindingChecked("imageTex").second, &inTextureView)) - .AddEntry(RHI::BindGroupEntry(imguiPixelShaderCompileOutput.reflectionData.QueryResourceBindingChecked("imageSampler").second, imguiImageSampler.Get())) - .AddEntry(RHI::BindGroupEntry(imguiVertexShaderCompileOutput.reflectionData.QueryResourceBindingChecked("passParams").second, imguiPassParamsBufferView.Get()))); + .AddEntry(RHI::BindGroupEntry(imguiPixelShaderCompileOutput.reflectionData.QueryResourceBindingChecked("imageTex").second, RHI::ShaderStageBits::sPixel, &inTextureView)) + .AddEntry(RHI::BindGroupEntry(imguiPixelShaderCompileOutput.reflectionData.QueryResourceBindingChecked("imageSampler").second, RHI::ShaderStageBits::sPixel, imguiImageSampler.Get())) + .AddEntry(RHI::BindGroupEntry(imguiVertexShaderCompileOutput.reflectionData.QueryResourceBindingChecked("passParams").second, RHI::ShaderStageBits::sVertex, imguiPassParamsBufferView.Get()))); auto* result = bindGroup.Get(); imguiFrameTextureBindGroups.emplace(&inTextureView, std::move(bindGroup)); return result; diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroup.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroup.h index 3b3583f3..a6041286 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroup.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroup.h @@ -14,6 +14,12 @@ namespace RHI::DirectX12 { class DX12BindGroupLayout; + struct NativeBinding { + HlslBinding binding; + ShaderStageFlags shaderVisibility; + CD3DX12_CPU_DESCRIPTOR_HANDLE cpuDescriptorHandle; + }; + class DX12BindGroup final : public BindGroup { public: NonCopyable(DX12BindGroup) @@ -21,13 +27,13 @@ namespace RHI::DirectX12 { ~DX12BindGroup() override; DX12BindGroupLayout& GetBindGroupLayout() const; - const std::vector>& GetNativeBindings(); + const std::vector& GetNativeBindings(); private: void SaveBindGroupLayout(const BindGroupCreateInfo& inCreateInfo); void CacheBindings(const BindGroupCreateInfo& inCreateInfo); DX12BindGroupLayout* bindGroupLayout; - std::vector> nativeBindings; + std::vector nativeBindings; }; } diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroupLayout.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroupLayout.h index 85234dde..3173a4c2 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroupLayout.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/BindGroupLayout.h @@ -17,8 +17,9 @@ namespace RHI::DirectX12 { BindingType bindingType; uint8_t layoutIndex; HlslBinding binding; + ShaderStageFlags shaderVisibility; - RootParameterKeyInfo(BindingType inBindingType, uint8_t inLayoutIndex, HlslBinding inBinding); + RootParameterKeyInfo(BindingType inBindingType, uint8_t inLayoutIndex, HlslBinding inBinding, ShaderStageFlags inShaderVisibility); }; class DX12BindGroupLayout final : public BindGroupLayout { diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/PipelineLayout.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/PipelineLayout.h index 8be0ace6..4d8f3e1d 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/PipelineLayout.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/PipelineLayout.h @@ -20,6 +20,7 @@ namespace RHI::DirectX12 { struct RootParameterKey { uint8_t layoutIndex; HlslBinding binding; + ShaderStageFlags shaderVisibility; bool operator==(const RootParameterKey& inOther) const; }; @@ -38,7 +39,10 @@ namespace RHI::DirectX12 { DX12PipelineLayout(DX12Device& inDevice, const PipelineLayoutCreateInfo& inCreateInfo); ~DX12PipelineLayout() override; - std::optional QueryRootDescriptorParameterIndex(uint8_t inLayoutIndex, const HlslBinding& inBinding); + std::optional QueryRootDescriptorParameterIndex( + uint8_t inLayoutIndex, + const HlslBinding& inBinding, + ShaderStageFlags inShaderVisibility); RootParameterIndex QueryRootConstantParameterIndex(uint32_t inPipelineConstantIndex) const; ID3D12RootSignature* GetNative() const; diff --git a/Engine/Source/RHI-DirectX12/Src/BindGroup.cpp b/Engine/Source/RHI-DirectX12/Src/BindGroup.cpp index 84438414..14d25429 100644 --- a/Engine/Source/RHI-DirectX12/Src/BindGroup.cpp +++ b/Engine/Source/RHI-DirectX12/Src/BindGroup.cpp @@ -47,7 +47,7 @@ namespace RHI::DirectX12 { return *bindGroupLayout; } - const std::vector>& DX12BindGroup::GetNativeBindings() + const std::vector& DX12BindGroup::GetNativeBindings() { return nativeBindings; } @@ -65,7 +65,7 @@ namespace RHI::DirectX12 { const auto& entry = inCreateInfo.entries[i]; CD3DX12_CPU_DESCRIPTOR_HANDLE handle = GetDescriptorCpuHandle(entry); - nativeBindings.emplace_back(std::get(entry.binding.platformBinding), handle); + nativeBindings.emplace_back(std::get(entry.binding.platformBinding), entry.shaderVisibility, handle); } } } diff --git a/Engine/Source/RHI-DirectX12/Src/BindGroupLayout.cpp b/Engine/Source/RHI-DirectX12/Src/BindGroupLayout.cpp index 32fc2a9c..ffd5efb6 100644 --- a/Engine/Source/RHI-DirectX12/Src/BindGroupLayout.cpp +++ b/Engine/Source/RHI-DirectX12/Src/BindGroupLayout.cpp @@ -19,10 +19,15 @@ namespace RHI::DirectX12 { } namespace RHI::DirectX12 { - RootParameterKeyInfo::RootParameterKeyInfo(const BindingType inBindingType, const uint8_t inLayoutIndex, const HlslBinding inBinding) + RootParameterKeyInfo::RootParameterKeyInfo( + const BindingType inBindingType, + const uint8_t inLayoutIndex, + const HlslBinding inBinding, + const ShaderStageFlags inShaderVisibility) : bindingType(inBindingType) , layoutIndex(inLayoutIndex) , binding(inBinding) + , shaderVisibility(inShaderVisibility) { } @@ -64,7 +69,7 @@ namespace RHI::DirectX12 { nativeDescriptorRanges.back().Init(EnumCast(hlslBinding.rangeType), 1, hlslBinding.index, inCreateInfo.layoutIndex); nativeRootParameters.back().InitAsDescriptorTable(1, &nativeDescriptorRanges.back(), GetShaderVisibility(entry.shaderVisibility)); - rootParameterKeyInfos.emplace_back(entry.binding.type, inCreateInfo.layoutIndex, hlslBinding); + rootParameterKeyInfos.emplace_back(entry.binding.type, inCreateInfo.layoutIndex, hlslBinding, entry.shaderVisibility); } } } diff --git a/Engine/Source/RHI-DirectX12/Src/CommandRecorder.cpp b/Engine/Source/RHI-DirectX12/Src/CommandRecorder.cpp index 8d196ffe..7b0cf831 100644 --- a/Engine/Source/RHI-DirectX12/Src/CommandRecorder.cpp +++ b/Engine/Source/RHI-DirectX12/Src/CommandRecorder.cpp @@ -209,17 +209,18 @@ namespace RHI::DirectX12 { void DX12ComputePassCommandRecorder::SetBindGroup(const uint8_t inLayoutIndex, BindGroup* inBindGroup) { auto* bindGroup = static_cast(inBindGroup); + Assert(computePipeline && bindGroup); const auto& bindGroupLayout = bindGroup->GetBindGroupLayout(); auto& pipelineLayout = computePipeline->GetPipelineLayout(); Assert(inLayoutIndex == bindGroupLayout.GetLayoutIndex()); - Assert(computePipeline); - for (const auto& bindings= bindGroup->GetNativeBindings(); - const auto& [hlslBinding, cpuDescriptorHandle] : bindings) { - std::optional t = pipelineLayout.QueryRootDescriptorParameterIndex(inLayoutIndex, hlslBinding); + for (const auto& bindings = bindGroup->GetNativeBindings(); + const auto& [hlslBinding, shaderVisibility, cpuDescriptorHandle] : bindings) { + std::optional t = pipelineLayout.QueryRootDescriptorParameterIndex(inLayoutIndex, hlslBinding, shaderVisibility); + Assert(t.has_value()); if (!t.has_value()) { - return; + continue; } commandBuffer.GetNativeCmdList()->SetComputeRootDescriptorTable(t.value().second, commandBuffer.GetRuntimeDescriptorHeaps()->NewGpuDescriptorHandle(hlslBinding.rangeType, cpuDescriptorHandle)); } @@ -317,17 +318,18 @@ namespace RHI::DirectX12 { void DX12RasterPassCommandRecorder::SetBindGroup(const uint8_t inLayoutIndex, BindGroup* inBindGroup) { auto* bindGroup = static_cast(inBindGroup); + Assert(rasterPipeline && bindGroup); const auto& bindGroupLayout = bindGroup->GetBindGroupLayout(); auto& pipelineLayout = rasterPipeline->GetPipelineLayout(); Assert(inLayoutIndex == bindGroupLayout.GetLayoutIndex()); - Assert(rasterPipeline); - for (const auto& bindings= bindGroup->GetNativeBindings(); - const auto& [hlslBinding, cpuDescriptorHandle] : bindings) { - std::optional t = pipelineLayout.QueryRootDescriptorParameterIndex(inLayoutIndex, hlslBinding); + for (const auto& bindings = bindGroup->GetNativeBindings(); + const auto& [hlslBinding, shaderVisibility, cpuDescriptorHandle] : bindings) { + std::optional t = pipelineLayout.QueryRootDescriptorParameterIndex(inLayoutIndex, hlslBinding, shaderVisibility); + Assert(t.has_value()); if (!t.has_value()) { - return; + continue; } commandBuffer.GetNativeCmdList()->SetGraphicsRootDescriptorTable(t.value().second, commandBuffer.GetRuntimeDescriptorHeaps()->NewGpuDescriptorHandle(hlslBinding.rangeType, cpuDescriptorHandle)); } diff --git a/Engine/Source/RHI-DirectX12/Src/PipelineLayout.cpp b/Engine/Source/RHI-DirectX12/Src/PipelineLayout.cpp index 4948da8c..48feb40d 100644 --- a/Engine/Source/RHI-DirectX12/Src/PipelineLayout.cpp +++ b/Engine/Source/RHI-DirectX12/Src/PipelineLayout.cpp @@ -2,6 +2,7 @@ // Created by johnk on 11/3/2022. // +#include #include #include @@ -16,12 +17,19 @@ namespace RHI::DirectX12 { { return layoutIndex == inOther.layoutIndex && binding.rangeType == inOther.binding.rangeType - && binding.index == inOther.binding.index; + && binding.index == inOther.binding.index + && shaderVisibility == inOther.shaderVisibility; } size_t RootParameterKeyHashProvider::operator()(const RootParameterKey& inKey) const { - return Common::HashUtils::CityHash(&inKey, sizeof(RootParameterKey)); + const std::array values = { + inKey.layoutIndex, + static_cast(inKey.binding.rangeType), + inKey.binding.index, + inKey.shaderVisibility.Value() + }; + return Common::HashUtils::CityHash(values.data(), values.size()); } DX12PipelineLayout::DX12PipelineLayout(DX12Device& inDevice, const PipelineLayoutCreateInfo& inCreateInfo) : PipelineLayout(inCreateInfo) @@ -31,9 +39,12 @@ namespace RHI::DirectX12 { DX12PipelineLayout::~DX12PipelineLayout() = default; - std::optional DX12PipelineLayout::QueryRootDescriptorParameterIndex(uint8_t inLayoutIndex, const HlslBinding& inBinding) + std::optional DX12PipelineLayout::QueryRootDescriptorParameterIndex( + const uint8_t inLayoutIndex, + const HlslBinding& inBinding, + const ShaderStageFlags inShaderVisibility) { - const auto iter = rootParameterIndexMap.find(RootParameterKey {inLayoutIndex, inBinding }); + const auto iter = rootParameterIndexMap.find(RootParameterKey { inLayoutIndex, inBinding, inShaderVisibility }); if (iter == rootParameterIndexMap.end()) { return {}; } @@ -67,8 +78,9 @@ namespace RHI::DirectX12 { rootParameters.emplace_back(pendingRootParameters[j]); const auto& keyInfo = keyInfos[j]; - auto rootParameterKey = RootParameterKey { keyInfo.layoutIndex, keyInfo.binding }; - rootParameterIndexMap[rootParameterKey] = { keyInfo.bindingType, index }; + auto rootParameterKey = RootParameterKey { keyInfo.layoutIndex, keyInfo.binding, keyInfo.shaderVisibility }; + const bool inserted = rootParameterIndexMap.emplace(rootParameterKey, BindingTypeAndRootParameterIndex { keyInfo.bindingType, index }).second; + Assert(inserted); } } rootConstantParameterIndices.reserve(inCreateInfo.pipelineConstantLayouts.size()); diff --git a/Engine/Source/RHI/Include/RHI/BindGroup.h b/Engine/Source/RHI/Include/RHI/BindGroup.h index a6d42e19..a21c8d69 100644 --- a/Engine/Source/RHI/Include/RHI/BindGroup.h +++ b/Engine/Source/RHI/Include/RHI/BindGroup.h @@ -18,9 +18,13 @@ namespace RHI { struct BindGroupEntry { ResourceBinding binding; + ShaderStageFlags shaderVisibility; std::variant entity; - BindGroupEntry(const ResourceBinding& inBinding, const std::variant& inEntity); + BindGroupEntry( + const ResourceBinding& inBinding, + ShaderStageFlags inShaderVisibility, + const std::variant& inEntity); }; struct BindGroupCreateInfo { diff --git a/Engine/Source/RHI/Src/BindGroup.cpp b/Engine/Source/RHI/Src/BindGroup.cpp index f8142da3..bbb32248 100644 --- a/Engine/Source/RHI/Src/BindGroup.cpp +++ b/Engine/Source/RHI/Src/BindGroup.cpp @@ -7,8 +7,12 @@ #include namespace RHI { - BindGroupEntry::BindGroupEntry(const ResourceBinding& inBinding, const std::variant& inEntity) + BindGroupEntry::BindGroupEntry( + const ResourceBinding& inBinding, + const ShaderStageFlags inShaderVisibility, + const std::variant& inEntity) : binding(inBinding) + , shaderVisibility(inShaderVisibility) , entity(inEntity) { } diff --git a/Engine/Source/Render/Include/Render/RenderCache.h b/Engine/Source/Render/Include/Render/RenderCache.h index 7742552f..6c5e0240 100644 --- a/Engine/Source/Render/Include/Render/RenderCache.h +++ b/Engine/Source/Render/Include/Render/RenderCache.h @@ -151,6 +151,7 @@ namespace Render { const RHI::ResourceBinding* GetBinding(const std::string& name); const RHI::ResourceBinding* GetBinding(const std::string& name, RHI::ShaderStageBits shaderStage) const; + const std::pair* GetBindingInfo(const std::string& name) const; RHI::BindGroupLayout* GetRHI() const; private: diff --git a/Engine/Source/Render/Src/RenderCache.cpp b/Engine/Source/Render/Src/RenderCache.cpp index 700a885f..6e82a5f3 100644 --- a/Engine/Source/Render/Src/RenderCache.cpp +++ b/Engine/Source/Render/Src/RenderCache.cpp @@ -434,6 +434,12 @@ namespace Render { return &iter->second.second; } + const std::pair* BindGroupLayout::GetBindingInfo(const std::string& name) const + { + const auto iter = bindings.find(name); + return iter == bindings.end() ? nullptr : &iter->second; + } + RHI::BindGroupLayout* BindGroupLayout::GetRHI() const { return rhiHandle.Get(); diff --git a/Engine/Source/Render/Src/RenderGraph.cpp b/Engine/Source/Render/Src/RenderGraph.cpp index fd1ee17c..6083d13a 100644 --- a/Engine/Source/Render/Src/RenderGraph.cpp +++ b/Engine/Source/Render/Src/RenderGraph.cpp @@ -954,23 +954,24 @@ namespace Render { RHI::BindGroupCreateInfo createInfo(layout->GetRHI()); for (const auto& [name, item] : items) { - const auto* binding = layout->GetBinding(name); - Assert(binding != nullptr); + const auto* bindingInfo = layout->GetBindingInfo(name); + Assert(bindingInfo != nullptr); + const auto& [shaderVisibility, binding] = *bindingInfo; if (item.type == RHI::BindingType::uniformBuffer || item.type == RHI::BindingType::storageBuffer || item.type == RHI::BindingType::rwStorageBuffer) { auto* bufferView = std::get(item.view); if (!devirtualizedResourceViews.contains(bufferView)) { devirtualizedResourceViews.emplace(std::make_pair(bufferView, ResourceViewCache::Get(device).GetOrCreate(GetRHI(bufferView->GetBuffer()), bufferView->desc))); } - createInfo.AddEntry(RHI::BindGroupEntry(*binding, GetRHI(bufferView))); + createInfo.AddEntry(RHI::BindGroupEntry(binding, shaderVisibility, GetRHI(bufferView))); } else if (item.type == RHI::BindingType::texture || item.type == RHI::BindingType::storageTexture || item.type == RHI::BindingType::rwStorageTexture) { auto* textureView = std::get(item.view); if (!devirtualizedResourceViews.contains(textureView)) { devirtualizedResourceViews.emplace(std::make_pair(textureView, ResourceViewCache::Get(device).GetOrCreate(GetRHI(textureView->GetTexture()), textureView->desc))); } - createInfo.AddEntry(RHI::BindGroupEntry(*binding, GetRHI(textureView))); + createInfo.AddEntry(RHI::BindGroupEntry(binding, shaderVisibility, GetRHI(textureView))); } else if (item.type == RHI::BindingType::sampler) { - createInfo.AddEntry(RHI::BindGroupEntry(*binding, std::get(item.view))); + createInfo.AddEntry(RHI::BindGroupEntry(binding, shaderVisibility, std::get(item.view))); } else { Unimplement(); } diff --git a/Sample/RHI-ParallelCompute/ParallelCompute.cpp b/Sample/RHI-ParallelCompute/ParallelCompute.cpp index 9c50476b..37b475d1 100644 --- a/Sample/RHI-ParallelCompute/ParallelCompute.cpp +++ b/Sample/RHI-ParallelCompute/ParallelCompute.cpp @@ -144,8 +144,8 @@ class ParallelCompute final : public Application { bindGroupLayout = device->CreateBindGroupLayout(layoutCreateInfo); const auto bindGroupCreateInfo = BindGroupCreateInfo(bindGroupLayout.Get()) - .AddEntry(BindGroupEntry(csOutPut.reflectionData.QueryResourceBindingChecked("input").second, inputBufferView.Get())) - .AddEntry(BindGroupEntry(csOutPut.reflectionData.QueryResourceBindingChecked("output").second, outputBufferView.Get())); + .AddEntry(BindGroupEntry(csOutPut.reflectionData.QueryResourceBindingChecked("input").second, ShaderStageBits::sCompute, inputBufferView.Get())) + .AddEntry(BindGroupEntry(csOutPut.reflectionData.QueryResourceBindingChecked("output").second, ShaderStageBits::sCompute, outputBufferView.Get())); bindGroup = device->CreateBindGroup(bindGroupCreateInfo); pipelineLayout = device->CreatePipelineLayout(PipelineLayoutCreateInfo().AddBindGroupLayout(bindGroupLayout.Get())); @@ -232,4 +232,4 @@ int main(int argc, char* argv[]) application.ComputeAndSaveResult(); return 0; -} \ No newline at end of file +} diff --git a/Sample/RHI-SSAO/SSAOApplication.cpp b/Sample/RHI-SSAO/SSAOApplication.cpp index 580801a1..8bcc40dc 100644 --- a/Sample/RHI-SSAO/SSAOApplication.cpp +++ b/Sample/RHI-SSAO/SSAOApplication.cpp @@ -282,8 +282,8 @@ class SSAOApplication final : public Application { // per renderable bindGroup bindGroup = device.CreateBindGroup( BindGroupCreateInfo(&bindGroupLayout) - .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("colorTex").second, diffuseColorMapView.Get())) - .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("colorSampler").second, &sampler))); + .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("colorTex").second, ShaderStageBits::sPixel, diffuseColorMapView.Get())) + .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("colorSampler").second, ShaderStageBits::sPixel, &sampler))); } }; @@ -658,41 +658,41 @@ class SSAOApplication final : public Application { { bindGroups.scene = device->CreateBindGroup( BindGroupCreateInfo(bindGroupLayouts.gBuffer.Get()) - .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("passParams").second, uniformBuffers.sceneParams.bufView.Get()))); + .AddEntry(BindGroupEntry(gBufferPsReflectionData.QueryResourceBindingChecked("passParams").second, ShaderStageBits::sVertex | ShaderStageBits::sPixel, uniformBuffers.sceneParams.bufView.Get()))); } // ssao generation { bindGroups.ssao = device->CreateBindGroup( BindGroupCreateInfo(bindGroupLayouts.ssao.Get()) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("posDepthTex").second, gBufferPos.srv.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("normalTex").second, gBufferNormal.srv.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("ssaoNoiseTex").second, noise.view.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("texSampler").second, sampler.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("ssaoNoiseSampler").second, noiseSampler.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("kernalParams").second, uniformBuffers.ssaoKernel.bufView.Get())) - .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("passParams").second, uniformBuffers.ssaoParams.bufView.Get()))); + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("posDepthTex").second, ShaderStageBits::sPixel, gBufferPos.srv.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("normalTex").second, ShaderStageBits::sPixel, gBufferNormal.srv.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("ssaoNoiseTex").second, ShaderStageBits::sPixel, noise.view.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("texSampler").second, ShaderStageBits::sPixel, sampler.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("ssaoNoiseSampler").second, ShaderStageBits::sPixel, noiseSampler.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("kernalParams").second, ShaderStageBits::sPixel, uniformBuffers.ssaoKernel.bufView.Get())) + .AddEntry(BindGroupEntry(ssaoPsReflectionData.QueryResourceBindingChecked("passParams").second, ShaderStageBits::sPixel, uniformBuffers.ssaoParams.bufView.Get()))); } // ssao blur { bindGroups.ssaoBlur = device->CreateBindGroup( BindGroupCreateInfo(bindGroupLayouts.ssaoBlur.Get()) - .AddEntry(BindGroupEntry(ssaoBlurPsReflectionData.QueryResourceBindingChecked("ssaoTex").second, ssaoOutput.srv.Get())) - .AddEntry(BindGroupEntry(ssaoBlurPsReflectionData.QueryResourceBindingChecked("ssaoSampler").second, sampler.Get()))); + .AddEntry(BindGroupEntry(ssaoBlurPsReflectionData.QueryResourceBindingChecked("ssaoTex").second, ShaderStageBits::sPixel, ssaoOutput.srv.Get())) + .AddEntry(BindGroupEntry(ssaoBlurPsReflectionData.QueryResourceBindingChecked("ssaoSampler").second, ShaderStageBits::sPixel, sampler.Get()))); } // composition { bindGroups.composition = device->CreateBindGroup( BindGroupCreateInfo(bindGroupLayouts.composition.Get()) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("posTex").second, gBufferPos.srv.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("normalTex").second, gBufferNormal.srv.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("albedoTex").second, gBufferAlbedo.srv.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("ssaoTex").second, ssaoOutput.srv.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("ssaoBluredTex").second, ssaoBlurOutput.srv.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("texSampler").second, sampler.Get())) - .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("passParams").second, uniformBuffers.ssaoParams.bufView.Get()))); + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("posTex").second, ShaderStageBits::sPixel, gBufferPos.srv.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("normalTex").second, ShaderStageBits::sPixel, gBufferNormal.srv.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("albedoTex").second, ShaderStageBits::sPixel, gBufferAlbedo.srv.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("ssaoTex").second, ShaderStageBits::sPixel, ssaoOutput.srv.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("ssaoBluredTex").second, ShaderStageBits::sPixel, ssaoBlurOutput.srv.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("texSampler").second, ShaderStageBits::sPixel, sampler.Get())) + .AddEntry(BindGroupEntry(compositionPsReflectionData.QueryResourceBindingChecked("passParams").second, ShaderStageBits::sPixel, uniformBuffers.ssaoParams.bufView.Get()))); } } diff --git a/Sample/RHI-TexSampling/TexSampling.cpp b/Sample/RHI-TexSampling/TexSampling.cpp index 99fc2712..2922bcca 100644 --- a/Sample/RHI-TexSampling/TexSampling.cpp +++ b/Sample/RHI-TexSampling/TexSampling.cpp @@ -329,9 +329,9 @@ class TexSamplingApplication final : public Application { bindGroup = device->CreateBindGroup( BindGroupCreateInfo(bindGroupLayout.Get()) - .AddEntry(BindGroupEntry(psReflectionData.QueryResourceBindingChecked("colorTex").second, sampleTextureView.Get())) - .AddEntry(BindGroupEntry(psReflectionData.QueryResourceBindingChecked("colorSampler").second, sampler.Get())) - .AddEntry(BindGroupEntry(vsReflectionData.QueryResourceBindingChecked("passParams").second, uniformBufferView.Get()))); + .AddEntry(BindGroupEntry(psReflectionData.QueryResourceBindingChecked("colorTex").second, ShaderStageBits::sPixel, sampleTextureView.Get())) + .AddEntry(BindGroupEntry(psReflectionData.QueryResourceBindingChecked("colorSampler").second, ShaderStageBits::sPixel, sampler.Get())) + .AddEntry(BindGroupEntry(vsReflectionData.QueryResourceBindingChecked("passParams").second, ShaderStageBits::sVertex, uniformBufferView.Get()))); } void CreatePipelineLayout()