core: Update Hillshade Algorithms and add Color-Relief Layer support (#3965)

This commit is contained in:
Andrew Calcutt
2026-02-25 20:50:06 -05:00
committed by GitHub
parent 9682e09ae4
commit 369af13ead
187 changed files with 8804 additions and 2352 deletions

View File

@@ -502,6 +502,10 @@ void ShaderProgram::analyzeShaderBindings(const std::string& source, WGPUShaderS
if (colonPos == std::string::npos) {
break;
}
// Extract the variable name
const auto varName = trimString(std::string_view(source.data() + afterVar, colonPos - afterVar));
size_t typeStart = colonPos + 1;
size_t typeEnd = typeStart;
while (typeEnd < source.size()) {
@@ -517,7 +521,19 @@ void ShaderProgram::analyzeShaderBindings(const std::string& source, WGPUShaderS
if (typeName.find("sampler") != std::string::npos) {
type = BindingType::Sampler;
} else if (typeName.find("texture") != std::string::npos) {
type = BindingType::Texture;
// Check if this texture is used with textureLoad (unfilterable) or textureSample (filterable)
// Look for textureLoad(varName, which indicates it's used without filtering
std::string textureLoadPattern = std::string("textureLoad(") + std::string(varName);
std::string textureSamplePattern = std::string("textureSample(") + std::string(varName);
bool usesTextureLoad = source.find(textureLoadPattern) != std::string::npos;
bool usesTextureSample = source.find(textureSamplePattern) != std::string::npos;
// If only textureLoad is used (not textureSample), mark as unfilterable
if (usesTextureLoad && !usesTextureSample) {
type = BindingType::UnfilterableTexture;
} else {
type = BindingType::Texture;
}
}
}
@@ -600,6 +616,11 @@ void ShaderProgram::rebuildBindGroupLayouts() {
layoutEntry.texture.viewDimension = WGPUTextureViewDimension_2D;
layoutEntry.texture.multisampled = false;
break;
case BindingType::UnfilterableTexture:
layoutEntry.texture.sampleType = WGPUTextureSampleType_UnfilterableFloat;
layoutEntry.texture.viewDimension = WGPUTextureViewDimension_2D;
layoutEntry.texture.multisampled = false;
break;
}
layoutEntries.push_back(layoutEntry);