Add gaussian splat compute shader contracts
This commit is contained in:
@@ -37,6 +37,8 @@ constexpr const char* kBuiltinSelectionMaskShaderPath = "builtin://shaders/selec
|
||||
constexpr const char* kBuiltinSelectionOutlineShaderPath = "builtin://shaders/selection-outline";
|
||||
constexpr const char* kBuiltinSkyboxShaderPath = "builtin://shaders/skybox";
|
||||
constexpr const char* kBuiltinGaussianSplatShaderPath = "builtin://shaders/gaussian-splat";
|
||||
constexpr const char* kBuiltinGaussianSplatUtilitiesShaderPath =
|
||||
"builtin://shaders/gaussian-splat-utilities";
|
||||
constexpr const char* kBuiltinVolumetricShaderPath = "builtin://shaders/volumetric";
|
||||
constexpr const char* kBuiltinColorScalePostProcessShaderPath =
|
||||
"builtin://shaders/color-scale-post-process";
|
||||
@@ -71,6 +73,8 @@ constexpr const char* kBuiltinSkyboxShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/skybox.shader";
|
||||
constexpr const char* kBuiltinGaussianSplatShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/gaussian-splat.shader";
|
||||
constexpr const char* kBuiltinGaussianSplatUtilitiesShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/gaussian-splat-utilities.shader";
|
||||
constexpr const char* kBuiltinVolumetricShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/volumetric.shader";
|
||||
constexpr const char* kBuiltinColorScalePostProcessShaderAssetRelativePath =
|
||||
@@ -170,6 +174,9 @@ const char* GetBuiltinShaderAssetRelativePath(const Containers::String& builtinS
|
||||
if (builtinShaderPath == Containers::String(kBuiltinGaussianSplatShaderPath)) {
|
||||
return kBuiltinGaussianSplatShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinGaussianSplatUtilitiesShaderPath)) {
|
||||
return kBuiltinGaussianSplatUtilitiesShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinVolumetricShaderPath)) {
|
||||
return kBuiltinVolumetricShaderAssetRelativePath;
|
||||
}
|
||||
@@ -698,6 +705,9 @@ size_t CalculateBuiltinShaderMemorySize(const Shader& shader) {
|
||||
memorySize += variant.profile.Length();
|
||||
memorySize += variant.sourceCode.Length();
|
||||
memorySize += variant.compiledBinary.Size();
|
||||
for (const ShaderBackendCompiledBinary& record : variant.backendCompiledBinaries) {
|
||||
memorySize += record.payload.Size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,6 +876,10 @@ bool TryGetBuiltinShaderPathByShaderName(
|
||||
outPath = GetBuiltinGaussianSplatShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Gaussian Splat Utilities") {
|
||||
outPath = GetBuiltinGaussianSplatUtilitiesShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Volumetric") {
|
||||
outPath = GetBuiltinVolumetricShaderPath();
|
||||
return true;
|
||||
@@ -957,6 +971,10 @@ Containers::String GetBuiltinGaussianSplatShaderPath() {
|
||||
return Containers::String(kBuiltinGaussianSplatShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinGaussianSplatUtilitiesShaderPath() {
|
||||
return Containers::String(kBuiltinGaussianSplatUtilitiesShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinVolumetricShaderPath() {
|
||||
return Containers::String(kBuiltinVolumetricShaderPath);
|
||||
}
|
||||
@@ -1077,6 +1095,8 @@ LoadResult CreateBuiltinShaderResource(const Containers::String& path) {
|
||||
shader = BuildBuiltinSkyboxShader(path);
|
||||
} else if (path == GetBuiltinGaussianSplatShaderPath()) {
|
||||
shader = BuildBuiltinGaussianSplatShader(path);
|
||||
} else if (path == GetBuiltinGaussianSplatUtilitiesShaderPath()) {
|
||||
shader = TryLoadBuiltinShaderFromAsset(path);
|
||||
} else if (path == GetBuiltinVolumetricShaderPath()) {
|
||||
shader = BuildBuiltinVolumetricShader(path);
|
||||
} else if (path == GetBuiltinColorScalePostProcessShaderPath()) {
|
||||
|
||||
@@ -192,8 +192,9 @@ void ImportConcretePass(Shader& shader, const ShaderPass& sourcePass) {
|
||||
shader.AddPass(sourcePass);
|
||||
}
|
||||
|
||||
bool IsBufferShaderResourceType(ShaderResourceType type) {
|
||||
return type == ShaderResourceType::StructuredBuffer ||
|
||||
bool IsScannedAuthoringResourceType(ShaderResourceType type) {
|
||||
return type == ShaderResourceType::ConstantBuffer ||
|
||||
type == ShaderResourceType::StructuredBuffer ||
|
||||
type == ShaderResourceType::RawBuffer ||
|
||||
type == ShaderResourceType::RWStructuredBuffer ||
|
||||
type == ShaderResourceType::RWRawBuffer;
|
||||
@@ -239,10 +240,13 @@ Core::uint32 FindNextBindingInSet(
|
||||
return nextBinding;
|
||||
}
|
||||
|
||||
bool TryParseHlslBufferResourceLine(
|
||||
bool TryParseHlslAuthoringResourceLine(
|
||||
const std::string& line,
|
||||
ShaderResourceType& outType,
|
||||
Containers::String& outName) {
|
||||
static const std::regex kConstantBufferPattern(
|
||||
R"(^\s*cbuffer\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*register\s*\([^\)]*\))?\s*(?:\{\s*)?$)",
|
||||
std::regex::ECMAScript);
|
||||
static const std::regex kStructuredPattern(
|
||||
R"(^\s*(?:globallycoherent\s+)?(RWStructuredBuffer|StructuredBuffer)\s*<[^;\r\n>]+>\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*register\s*\([^\)]*\))?\s*;)",
|
||||
std::regex::ECMAScript);
|
||||
@@ -251,6 +255,12 @@ bool TryParseHlslBufferResourceLine(
|
||||
std::regex::ECMAScript);
|
||||
|
||||
std::smatch match;
|
||||
if (std::regex_match(line, match, kConstantBufferPattern) && match.size() >= 2u) {
|
||||
outType = ShaderResourceType::ConstantBuffer;
|
||||
outName = match[1].str().c_str();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (std::regex_match(line, match, kStructuredPattern) && match.size() >= 3u) {
|
||||
outType =
|
||||
match[1].str() == "RWStructuredBuffer"
|
||||
@@ -272,7 +282,7 @@ bool TryParseHlslBufferResourceLine(
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppendScannedBufferResourceBindings(
|
||||
void AppendScannedAuthoringResourceBindings(
|
||||
const Containers::String& sourceText,
|
||||
Containers::Array<ShaderResourceBindingDesc>& ioBindings) {
|
||||
if (sourceText.Empty()) {
|
||||
@@ -286,11 +296,11 @@ void AppendScannedBufferResourceBindings(
|
||||
const std::string line = Internal::StripAuthoringLineComment(rawLine);
|
||||
ShaderResourceType resourceType = ShaderResourceType::ConstantBuffer;
|
||||
Containers::String resourceName;
|
||||
if (!TryParseHlslBufferResourceLine(line, resourceType, resourceName)) {
|
||||
if (!TryParseHlslAuthoringResourceLine(line, resourceType, resourceName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsBufferShaderResourceType(resourceType) ||
|
||||
if (!IsScannedAuthoringResourceType(resourceType) ||
|
||||
resourceName.Empty() ||
|
||||
HasResourceBindingNamed(ioBindings, resourceName)) {
|
||||
continue;
|
||||
@@ -354,7 +364,7 @@ ShaderPass BuildConcretePass(
|
||||
}
|
||||
}
|
||||
}
|
||||
AppendScannedBufferResourceBindings(strippedCombinedSource, shaderPass.resources);
|
||||
AppendScannedAuthoringResourceBindings(strippedCombinedSource, shaderPass.resources);
|
||||
const std::vector<ShaderKeywordSet> keywordSets =
|
||||
BuildShaderKeywordVariantSets(pass.keywordDeclarations);
|
||||
|
||||
@@ -615,6 +625,9 @@ size_t CalculateShaderMemorySize(const Shader& shader) {
|
||||
memorySize += variant.profile.Length();
|
||||
memorySize += variant.sourceCode.Length();
|
||||
memorySize += variant.compiledBinary.Size();
|
||||
for (const ShaderBackendCompiledBinary& record : variant.backendCompiledBinaries) {
|
||||
memorySize += record.payload.Size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user