Skip to content

Commit cad9137

Browse files
PipelineStateCreateInfoX: copy internal create info
1 parent 2b1ee82 commit cad9137

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

Graphics/GraphicsEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ set(SOURCE
9595
src/EngineMemory.cpp
9696
src/EngineFactoryBase.cpp
9797
src/FramebufferBase.cpp
98+
src/GraphicsTypesX.cpp
9899
src/PipelineResourceSignatureBase.cpp
99100
src/PipelineStateBase.cpp
100101
src/PipelineStateCacheBase.cpp

Graphics/GraphicsEngine/interface/GraphicsTypesX.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <utility>
3434
#include <string>
3535
#include <unordered_set>
36+
#include <memory>
3637

3738
#include "RenderPass.h"
3839
#include "InputLayout.h"
@@ -1196,6 +1197,8 @@ struct BottomLevelASDescX : DeviceObjectAttribsX<BottomLevelASDescX, BottomLevel
11961197
std::unordered_set<std::string> StringPool;
11971198
};
11981199

1200+
std::unique_ptr<Uint8[]> CopyPSOCreateInternalInfo(void* pData);
1201+
11991202
/// C++ wrapper over PipelineStateCreateInfo
12001203

12011204
template <typename DerivedType, typename CreateInfoType>
@@ -1206,14 +1209,16 @@ struct PipelineStateCreateInfoX : CreateInfoType
12061209

12071210
PipelineStateCreateInfoX(const CreateInfoType& CI) noexcept :
12081211
CreateInfoType{CI},
1209-
ResourceLayout{CI.PSODesc.ResourceLayout}
1212+
ResourceLayout{CI.PSODesc.ResourceLayout},
1213+
InternalData{CopyPSOCreateInternalInfo(CI.pInternalData)}
12101214
{
12111215
SetName(this->PSODesc.Name);
12121216
for (size_t i = 0; i < CI.ResourceSignaturesCount; ++i)
12131217
AddSignature(CI.ppResourceSignatures[i]);
12141218
if (CI.pPSOCache != nullptr)
12151219
SetPipelineStateCache(CI.pPSOCache);
12161220
this->PSODesc.ResourceLayout = ResourceLayout;
1221+
this->pInternalData = InternalData.get();
12171222
}
12181223

12191224
explicit PipelineStateCreateInfoX(const char* Name)
@@ -1364,6 +1369,7 @@ struct PipelineStateCreateInfoX : CreateInfoType
13641369
std::unordered_set<std::string> StringPool;
13651370
std::vector<RefCntAutoPtr<IDeviceObject>> Objects;
13661371
std::vector<IPipelineResourceSignature*> Signatures;
1372+
std::unique_ptr<Uint8[]> InternalData;
13671373
};
13681374

13691375

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2024 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#include "GraphicsTypesX.hpp"
28+
#include "PipelineStateBase.hpp"
29+
30+
namespace Diligent
31+
{
32+
33+
std::unique_ptr<Uint8[]> CopyPSOCreateInternalInfo(void* pData)
34+
{
35+
std::unique_ptr<Uint8[]> pCopy;
36+
if (pData != nullptr)
37+
{
38+
static_assert(std::is_trivially_destructible<PSOCreateInternalInfo>::value, "PSOCreateInternalInfo must be trivially destructible");
39+
pCopy = std::make_unique<Uint8[]>(sizeof(PSOCreateInternalInfo));
40+
memcpy(pCopy.get(), pData, sizeof(PSOCreateInternalInfo));
41+
}
42+
43+
return pCopy;
44+
}
45+
46+
} // namespace Diligent

0 commit comments

Comments
 (0)