Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions tools/clang/unittests/HLSLExec/HlslExecTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,30 @@ void addUAVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width,
Op->Resources.push_back(Res);
}

void addRootUAV(st::ShaderOp *Op, UINT Index, const char *ResName) {
void addSRVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width,
const char *Init) {
st::ShaderOpResource Res = {};
Res.Name = Op->Strings.insert(Name);
Res.Init = Op->Strings.insert(Init);
Res.ReadBack = FALSE;

Res.HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
Res.HeapFlags = D3D12_HEAP_FLAG_NONE;
Res.Desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
Res.Desc.Width = Width;
Res.Desc.Height = 1;
Res.Desc.DepthOrArraySize = 1;
Res.Desc.MipLevels = 1;
Res.Desc.SampleDesc.Count = 1;
Res.Desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
Res.Desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
Res.InitialResourceState = D3D12_RESOURCE_STATE_COPY_DEST;
Res.TransitionTo = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;

Op->Resources.push_back(Res);
}

void addRootView(st::ShaderOp *Op, UINT Index, const char *ResName) {
st::ShaderOpRootValue RV = {};
RV.ResName = Op->Strings.insert(ResName);
RV.HeapName = nullptr;
Expand Down Expand Up @@ -751,7 +774,7 @@ void compileShader(dxc::SpecificDllLoader &DxcSupport, const char *Source,

if (VerboseLogging) {
hlsl_test::LogCommentFmt(L"Shader Source:");
hlsl_test::LogCommentFmt(L"%c", Source);
hlsl_test::LogCommentFmt(L"%S", Source);
}

hlsl_test::LogCommentFmt(LogFlags.str().c_str());
Expand Down
8 changes: 6 additions & 2 deletions tools/clang/unittests/HLSLExec/HlslExecTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ createComputeOp(const char *Source, const char *Target, const char *RootSig,
void addUAVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width,
bool ReadBack, const char *Init = "zero");

/// Bind a resource to a root UAV parameter by index.
void addRootUAV(st::ShaderOp *Op, UINT Index, const char *ResName);
/// Add a SRV buffer resource to a ShaderOp.
void addSRVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width,
const char *Init = "zero");

/// Bind a resource to a root view parameter by index.
void addRootView(st::ShaderOp *Op, UINT Index, const char *ResName);

/// Run a programmatically-built ShaderOp and return the result.
std::shared_ptr<st::ShaderOpTestResult>
Expand Down
Loading
Loading