Skip to content

Commit

Permalink
Add "bindless" SRG member reflected attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Ong <jcong@amazon.com>
  • Loading branch information
jeremyong-az committed Mar 20, 2022
1 parent ec7e239 commit a31b462
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bin/*
src/generated/*.interp
src/generated/*.tokens
src/generated/java/
src/dist
.vs
build
/src/.antlr/azslLexer.interp
Expand All @@ -14,4 +15,4 @@ build
/src/.antlr/azslParser.interp
/src/.antlr/azslParser.java
/src/.antlr/azslParser.tokens
/tests/testfuncs.pyc
/tests/testfuncs.pyc
2 changes: 1 addition & 1 deletion prepare_solution_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ REM

set platform=win
set architecture=x64
set generator="Visual Studio 16 2019"
set generator="Visual Studio 17 2022"

set curr_dir=%~dp0
set src_path=%curr_dir%\src
Expand Down
8 changes: 7 additions & 1 deletion src/AzslcBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ namespace AZ::ShaderCompiler
int count = 1;
RootParamType paramType = RootParamType::SrgConstantCB; // this is the default because when "kind" is not "Variable", this function is used on symbols of "kind" "SRG"
bool isUnboundedArray = false;
bool isBindlessArray = false;
if (kind == Kind::Variable)
{
const auto* memberInfo = m_ir->GetSymbolSubAs<VarInfo>(id.m_name);
Expand All @@ -564,6 +565,11 @@ namespace AZ::ShaderCompiler
}
}

if (memberInfo->GetArrayDimensions().IsArray())
{
isBindlessArray = m_ir->m_symbols.GetAttribute(id, "bindless").has_value();
}

if (shouldCheckForValidArraySize)
{
CheckHasOneFoldedDimensionOrThrow(memberInfo->GetArrayDimensions(), "CodeEmitter::BuildSignatureDescription");
Expand All @@ -573,7 +579,7 @@ namespace AZ::ShaderCompiler
}

auto regType = RootParamTypeToBindingType(paramType);
auto srgElementDesc = RootSigDesc::SrgParamDesc{ id, paramType, bindInfo.GetCurrent(regType), count, -1, isUnboundedArray};
auto srgElementDesc = RootSigDesc::SrgParamDesc{ id, paramType, bindInfo.GetCurrent(regType), count, -1, isUnboundedArray, isBindlessArray};
rootSig.m_descriptorMap.emplace(id, srgElementDesc);
bindInfo.SignalRegisterIncrement(regType, count);
return srgElementDesc;
Expand Down
1 change: 1 addition & 0 deletions src/AzslcBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace AZ::ShaderCompiler
// of 1 and at the same time We do not forget that m_uid refers
// to an unbounded array.
bool m_isUnboundedArray = false;
bool m_isBindlessArray = false;
};

struct SrgDesc
Expand Down
1 change: 1 addition & 0 deletions src/AzslcReflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ namespace AZ::ShaderCompiler
output["space"] = bindInfo.m_registerBinding.m_pair[BindingPair::Set::Untainted].m_logicalSpace;
output["index-merged"] = bindInfo.m_registerBinding.m_pair[BindingPair::Set::Merged].m_registerIndex;
output["space-merged"] = bindInfo.m_registerBinding.m_pair[BindingPair::Set::Merged].m_logicalSpace;
output["bindless"] = bindInfo.m_isBindlessArray;
}

void CodeReflection::DumpSRGLayout(const Options& options) const
Expand Down
3 changes: 3 additions & 0 deletions tests/Advanced/emission-tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def doTests(compiler, silent, azdxcpath):
if testhelper.verifyEmissionPatterns(os.path.abspath(os.path.join(workDir, "../Samples/UnboundedArrays.azsl_manual")), compiler, silent, ["--use-spaces",]) : result += 1
else: resultFailed += 1

if testhelper.verifyEmissionPatterns(os.path.abspath(os.path.join(workDir, "../Samples/Bindless.azsl")), compiler, silent, ["--srg",]) : result += 1
else: resultFailed += 1

for base, dirs, files in os.walk(os.path.join(workDir, "../Emission/")):
for f in files:
if f.endswith(".azsl"):
Expand Down
9 changes: 9 additions & 0 deletions tests/Samples/Bindless.azsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ShaderResourceGroupSemantic BindlessGroup
{
FrequencyId = 10;
};

ShaderResourceGroup BindlessTextures : BindlessGroup
{
[bindless] Texture2D textures[];
};
2 changes: 2 additions & 0 deletions tests/Samples/Bindless.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Srg layout produced with azslc.exe Bindless.azsl --srg
"\"bindless\": true"

0 comments on commit a31b462

Please sign in to comment.