Skip to content

Commit

Permalink
Replace MemSpan with llvm::ArrayRef<uint32_t>.
Browse files Browse the repository at this point in the history
  • Loading branch information
python3kgae committed Aug 15, 2024
1 parent 2044de3 commit aab094c
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions lib/DxilValidation/DxilContainerValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> InputToOutputTable[DXIL::kNumOutputStreams];
ArrayRef<uint32_t> InputToPCOutputTable;
ArrayRef<uint32_t> PCInputToOutputTable;
ArrayRef<uint32_t> ViewIDOutputMask[DXIL::kNumOutputStreams];
ArrayRef<uint32_t> ViewIDPCOutputMask;
bool IsValid = true;
SimpleViewIDState(std::vector<uint32_t> &Data, PSVShaderKind,
bool UsesViewID);
Expand Down Expand Up @@ -163,9 +157,9 @@ class PSVContentVerifier {
void VerifyResource(PSVResourceBindInfo0 *, PSVResourceBindInfo1 *,
DxilResourceBase &);
void VerifyViewIDDependence(PSVRuntimeInfo1 *PSV1);
void VerifyViewIDMask(PSVComponentMask &&, MemSpan &,
void VerifyViewIDMask(PSVComponentMask &&, ArrayRef<uint32_t> &,
unsigned NumOutputScalars);
void VerifyDependencyTable(PSVDependencyTable &&, MemSpan &,
void VerifyDependencyTable(PSVDependencyTable &&, ArrayRef<uint32_t> &,
unsigned NumInputScalars,
unsigned NumOutputScalars);
void VerifyEntryProperties(const ShaderModel *SM, PSVRuntimeInfo0 *PSV0,
Expand All @@ -188,39 +182,40 @@ class PSVContentVerifier {
};

void PSVContentVerifier::VerifyDependencyTable(PSVDependencyTable &&Tab,
MemSpan &Mem,
ArrayRef<uint32_t> &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))
EmitFormatError("Number of InputVectors for PSVDependencyTable");
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<uint32_t> &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");
}
}
Expand Down

0 comments on commit aab094c

Please sign in to comment.