Fix builtin pass layout metadata lifetime
This commit is contained in:
@@ -525,8 +525,7 @@ inline void RefreshBuiltinPassSetLayoutMetadata(BuiltinPassSetLayoutMetadata& se
|
||||
return left.binding < right.binding;
|
||||
});
|
||||
setLayout.shaderVisible = IsBuiltinPassShaderVisibleSet(setLayout.bindings);
|
||||
setLayout.layout.bindings = setLayout.bindings.empty() ? nullptr : setLayout.bindings.data();
|
||||
setLayout.layout.bindingCount = static_cast<Core::uint32>(setLayout.bindings.size());
|
||||
setLayout.SyncLayoutView();
|
||||
}
|
||||
|
||||
inline void RefreshBuiltinPassSetLayouts(std::vector<BuiltinPassSetLayoutMetadata>& setLayouts) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <XCEngine/Resources/Shader/Shader.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -142,6 +143,81 @@ struct BuiltinPassSetLayoutMetadata {
|
||||
bool usesSampler = false;
|
||||
bool usesLinearClampSampler = false;
|
||||
bool usesShadowMapSampler = false;
|
||||
|
||||
BuiltinPassSetLayoutMetadata() = default;
|
||||
|
||||
BuiltinPassSetLayoutMetadata(const BuiltinPassSetLayoutMetadata& other)
|
||||
: bindings(other.bindings)
|
||||
, materialBufferBindings(other.materialBufferBindings) {
|
||||
CopyFlagsFrom(other);
|
||||
SyncLayoutView();
|
||||
}
|
||||
|
||||
BuiltinPassSetLayoutMetadata(BuiltinPassSetLayoutMetadata&& other) noexcept
|
||||
: bindings(std::move(other.bindings))
|
||||
, materialBufferBindings(std::move(other.materialBufferBindings)) {
|
||||
CopyFlagsFrom(other);
|
||||
SyncLayoutView();
|
||||
other.layout = {};
|
||||
}
|
||||
|
||||
BuiltinPassSetLayoutMetadata& operator=(const BuiltinPassSetLayoutMetadata& other) {
|
||||
if (this != &other) {
|
||||
bindings = other.bindings;
|
||||
materialBufferBindings = other.materialBufferBindings;
|
||||
CopyFlagsFrom(other);
|
||||
SyncLayoutView();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BuiltinPassSetLayoutMetadata& operator=(BuiltinPassSetLayoutMetadata&& other) noexcept {
|
||||
if (this != &other) {
|
||||
bindings = std::move(other.bindings);
|
||||
materialBufferBindings = std::move(other.materialBufferBindings);
|
||||
CopyFlagsFrom(other);
|
||||
SyncLayoutView();
|
||||
other.layout = {};
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SyncLayoutView() {
|
||||
layout.bindings = bindings.empty() ? nullptr : bindings.data();
|
||||
layout.bindingCount = static_cast<Core::uint32>(bindings.size());
|
||||
}
|
||||
|
||||
private:
|
||||
void CopyFlagsFrom(const BuiltinPassSetLayoutMetadata& other) {
|
||||
heapType = other.heapType;
|
||||
shaderVisible = other.shaderVisible;
|
||||
usesPerObject = other.usesPerObject;
|
||||
usesMaterial = other.usesMaterial;
|
||||
usesLighting = other.usesLighting;
|
||||
usesShadowReceiver = other.usesShadowReceiver;
|
||||
usesEnvironment = other.usesEnvironment;
|
||||
usesPassConstants = other.usesPassConstants;
|
||||
usesMaterialBuffers = other.usesMaterialBuffers;
|
||||
usesVolumeField = other.usesVolumeField;
|
||||
usesGaussianSplatSortDistanceBuffer = other.usesGaussianSplatSortDistanceBuffer;
|
||||
usesGaussianSplatOrderBuffer = other.usesGaussianSplatOrderBuffer;
|
||||
usesGaussianSplatPositionBuffer = other.usesGaussianSplatPositionBuffer;
|
||||
usesGaussianSplatOtherBuffer = other.usesGaussianSplatOtherBuffer;
|
||||
usesGaussianSplatColorBuffer = other.usesGaussianSplatColorBuffer;
|
||||
usesGaussianSplatSHBuffer = other.usesGaussianSplatSHBuffer;
|
||||
usesGaussianSplatViewDataBuffer = other.usesGaussianSplatViewDataBuffer;
|
||||
usesTexture = other.usesTexture;
|
||||
usesBaseColorTexture = other.usesBaseColorTexture;
|
||||
usesSourceColorTexture = other.usesSourceColorTexture;
|
||||
usesSkyboxPanoramicTexture = other.usesSkyboxPanoramicTexture;
|
||||
usesSkyboxTexture = other.usesSkyboxTexture;
|
||||
usesShadowMapTexture = other.usesShadowMapTexture;
|
||||
usesSampler = other.usesSampler;
|
||||
usesLinearClampSampler = other.usesLinearClampSampler;
|
||||
usesShadowMapSampler = other.usesShadowMapSampler;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
Reference in New Issue
Block a user