forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDxcContainerBuilder.h
More file actions
85 lines (73 loc) · 3.08 KB
/
DxcContainerBuilder.h
File metadata and controls
85 lines (73 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
///////////////////////////////////////////////////////////////////////////////
// //
// DxcContainerBuilder.h //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// Implements the Dxil Container Builder //
// //
///////////////////////////////////////////////////////////////////////////////
#pragma once
// Include Windows header early for DxilHash.h.
#include "dxc/Support/Global.h"
#include "dxc/Support/WinIncludes.h"
#include "dxc/DxilContainer/DxilContainer.h"
#include "dxc/DxilHash/DxilHash.h"
#include "dxc/Support/microcom.h"
#include "dxc/dxcapi.h"
#include "llvm/ADT/SmallVector.h"
using namespace hlsl;
namespace hlsl {
class AbstractMemoryStream;
}
class DxcContainerBuilder : public IDxcContainerBuilder {
public:
// Loads DxilContainer to the builder
HRESULT STDMETHODCALLTYPE Load(IDxcBlob *pDxilContainerHeader) override;
// Add the given part with fourCC
HRESULT STDMETHODCALLTYPE AddPart(UINT32 fourCC, IDxcBlob *pSource) override;
// Remove the part with fourCC
HRESULT STDMETHODCALLTYPE RemovePart(UINT32 fourCC) override;
// Builds a container of the given container builder state
HRESULT STDMETHODCALLTYPE
SerializeContainer(IDxcOperationResult **ppResult) override;
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
DXC_MICROCOM_TM_CTOR(DxcContainerBuilder)
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
void **ppvObject) override {
return DoBasicQueryInterface<IDxcContainerBuilder>(this, riid, ppvObject);
}
void Init() {
m_RequireValidation = false;
m_HasPrivateData = false;
m_HashFunction = nullptr;
}
protected:
DXC_MICROCOM_TM_REF_FIELDS()
private:
class DxilPart {
public:
UINT32 m_fourCC;
CComPtr<IDxcBlob> m_Blob;
DxilPart(UINT32 fourCC, IDxcBlob *pSource)
: m_fourCC(fourCC), m_Blob(pSource) {}
};
typedef llvm::SmallVector<DxilPart, 8> PartList;
PartList m_parts;
CComPtr<IDxcBlob> m_pContainer;
bool m_RequireValidation;
bool m_HasPrivateData;
// Function to compute hash when valid dxil container is built
// This is nullptr if loaded container has invalid hash
HASH_FUNCTION_PROTO *m_HashFunction;
void DetermineHashFunctionFromContainerContents(
const DxilContainerHeader *ContainerHeader);
void HashAndUpdate(DxilContainerHeader *ContainerHeader);
UINT32 ComputeContainerSize();
HRESULT UpdateContainerHeader(AbstractMemoryStream *pStream,
uint32_t containerSize);
HRESULT UpdateOffsetTable(AbstractMemoryStream *pStream);
HRESULT UpdateParts(AbstractMemoryStream *pStream);
void AddPart(DxilPart &&part);
};