From aab094c00f0d7084bf89ed511d985fa2e8a139e3 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Thu, 15 Aug 2024 11:11:13 -0400 Subject: [PATCH] Replace MemSpan with llvm::ArrayRef. --- .../DxilContainerValidation.cpp | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/DxilValidation/DxilContainerValidation.cpp b/lib/DxilValidation/DxilContainerValidation.cpp index a00c3a46ed..6477c017d0 100644 --- a/lib/DxilValidation/DxilContainerValidation.cpp +++ b/lib/DxilValidation/DxilContainerValidation.cpp @@ -77,22 +77,16 @@ static void emitDxilDiag(LLVMContext &Ctx, const char *str) { hlsl::dxilutil::EmitErrorOnContext(Ctx, str); } -struct MemSpan { - uint32_t *Ptr = nullptr; - uint32_t Size = 0; - bool isEmpty() { return Size == 0; } -}; - struct SimpleViewIDState { unsigned NumInputSigScalars = 0; unsigned NumOutputSigScalars[DXIL::kNumOutputStreams] = {0, 0, 0, 0}; unsigned NumPCOrPrimSigScalars = 0; - MemSpan InputToOutputTable[DXIL::kNumOutputStreams]; - MemSpan InputToPCOutputTable; - MemSpan PCInputToOutputTable; - MemSpan ViewIDOutputMask[DXIL::kNumOutputStreams]; - MemSpan ViewIDPCOutputMask; + ArrayRef InputToOutputTable[DXIL::kNumOutputStreams]; + ArrayRef InputToPCOutputTable; + ArrayRef PCInputToOutputTable; + ArrayRef ViewIDOutputMask[DXIL::kNumOutputStreams]; + ArrayRef ViewIDPCOutputMask; bool IsValid = true; SimpleViewIDState(std::vector &Data, PSVShaderKind, bool UsesViewID); @@ -163,9 +157,9 @@ class PSVContentVerifier { void VerifyResource(PSVResourceBindInfo0 *, PSVResourceBindInfo1 *, DxilResourceBase &); void VerifyViewIDDependence(PSVRuntimeInfo1 *PSV1); - void VerifyViewIDMask(PSVComponentMask &&, MemSpan &, + void VerifyViewIDMask(PSVComponentMask &&, ArrayRef &, unsigned NumOutputScalars); - void VerifyDependencyTable(PSVDependencyTable &&, MemSpan &, + void VerifyDependencyTable(PSVDependencyTable &&, ArrayRef &, unsigned NumInputScalars, unsigned NumOutputScalars); void VerifyEntryProperties(const ShaderModel *SM, PSVRuntimeInfo0 *PSV0, @@ -188,10 +182,10 @@ class PSVContentVerifier { }; void PSVContentVerifier::VerifyDependencyTable(PSVDependencyTable &&Tab, - MemSpan &Mem, + ArrayRef &Mem, unsigned NumInputScalars, unsigned NumOutputScalars) { - if (Tab.InputVectors == 0 && Tab.OutputVectors == 0 && Mem.isEmpty()) + if (Tab.InputVectors == 0 && Tab.OutputVectors == 0 && Mem.empty()) return; if (Tab.InputVectors != (PSVALIGN4(NumInputScalars) >> 2)) @@ -199,28 +193,29 @@ void PSVContentVerifier::VerifyDependencyTable(PSVDependencyTable &&Tab, if (Tab.OutputVectors != (PSVALIGN4(NumOutputScalars) >> 2)) EmitFormatError("Number of OutputVectors for PSVDependencyTable"); - if (Mem.Size != NumInputScalars * RoundUpToUINT(NumOutputScalars)) { + if (Mem.size() != NumInputScalars * RoundUpToUINT(NumOutputScalars)) { EmitFormatError("Size of PSVDependencyTable"); return; } - if (memcmp(Mem.Ptr, Tab.Table, 4 * Mem.Size) != 0) { + if (memcmp(Mem.data(), Tab.Table, 4 * Mem.size()) != 0) { EmitFormatError("PSVDependencyTable"); } } -void PSVContentVerifier::VerifyViewIDMask(PSVComponentMask &&Mask, MemSpan &Mem, +void PSVContentVerifier::VerifyViewIDMask(PSVComponentMask &&Mask, + ArrayRef &Mem, unsigned NumOutputScalars) { - if (Mask.NumVectors == 0 && Mem.isEmpty()) + if (Mask.NumVectors == 0 && Mem.empty()) return; if (Mask.NumVectors != (PSVALIGN4(NumOutputScalars) >> 2)) EmitFormatError("NumVectors of PSVComponentMask"); - if (Mem.Size != RoundUpToUINT(NumOutputScalars)) { + if (Mem.size() != RoundUpToUINT(NumOutputScalars)) { EmitFormatError("Size of PSVComponentMask"); return; } - if (memcmp(Mem.Ptr, Mask.Mask, 4 * Mem.Size) != 0) { + if (memcmp(Mem.data(), Mask.Mask, 4 * Mem.size()) != 0) { EmitFormatError("PSVComponentMask"); } }